https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67391
--- Comment #16 from Oleg Endo <olegendo at gcc dot gnu.org> --- Created attachment 36396 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36396&action=edit Another trail, works with LRA (In reply to Oleg Endo from comment #15) > > I'm now trying to come up with something that is between your patch and my > patch to make it work with LRA. However, somehow I think we are just > desperately wallpapering LRA deficits here. It looks a bit fragile. We > should try to avoid that if possible. This patch is a mix of the patches attachment 36387 and attachment 36393. It works with LRA (tested only by compiling the CSiBE set) and keeps the code size improvement without LRA. First, the original addsi3 expander looks a bit wrong. It should be "arith_reg_dest" for operands[0], because also the SHmedia patterns only accept "arith_reg_dest". operands[1] should be "arith_reg_operand". This should be sufficient and no need to use "force_reg" on it (for SHmedia case), because usually constants are put in operands[2], not operands[1] when the insn is expanded. Then, there's is messy thing with 3 addsi3 patterns ... the order is very important. They must be in exactly this order, or else we don't get the code size improvement without LRA and with LRA it will ICE/segfault... I've tested this patch with make -k check RUNTESTFLAGS="--target_board=sh-sim\{-m2/-ml,-m2/-mb,-m2a/-mb,-m4/-ml,-m4/-mb,-m4a/-ml,-m4a/-mb}" and no new failures. I'll test it with -mlra enabled by default later. Kaz, does this patch fix the issue in c#11 ?