Created attachment 34964 [details] Testcase showing change in behaviour. The ARM backend no longer supports -mno-lra so only the LRA is available. This has also removed the Thumb mode optimiziation introduced in https://gcc.gnu.org/ml/gcc-patches/2005-08/msg01140.html to fix PR 23436. This turns sequences like mov r3, r9 mov r2, r10 ldr r0, [r3, r2] into mov r3, r9 add r3, r3, r10 ldr r0, [r3] which saves a register. Attached is a contrived test case. Compiling with gcc-4.9 with -mthumb -mno-lra (at -O1 and higher) produces the second (better) sequence. Compiling with gcc-4.9 or gcc-trunk with -mthumb (at -O1 and higher) produces the first sequence. The sequences appear after the 'nop' gcc-4.9 is arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 4.9.3 20141119 (release) [ARM/embedded-4_9-branch revision 218278] trunk is: arm-none-eabi-gcc (unknown) 5.0.0 20150217 (experimental)
In this specific case, thumb_legitimize_address will generate ldr r0, [r9, r10] pattern(after IRA). However, this pattern only allows LO_REGS. During reload, r9&r10 will be spilled into LO_REGS, that's where those two mov instructions come from. (In reply to Matthew Wahab from comment #0) > Created attachment 34964 [details] > Testcase showing change in behaviour. > > The ARM backend no longer supports -mno-lra so only the LRA is available. > This > has also removed the Thumb mode optimiziation introduced in > https://gcc.gnu.org/ml/gcc-patches/2005-08/msg01140.html to fix PR 23436. > > This turns sequences like > mov r3, r9 > mov r2, r10 > ldr r0, [r3, r2] > into > mov r3, r9 > add r3, r3, r10 > ldr r0, [r3] > which saves a register. > > Attached is a contrived test case. Compiling with gcc-4.9 with -mthumb > -mno-lra > (at -O1 and higher) produces the second (better) sequence. Compiling with > gcc-4.9 or gcc-trunk with -mthumb (at -O1 and higher) produces the first > sequence. The sequences appear after the 'nop' > > gcc-4.9 is > arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 4.9.3 20141119 > (release) [ARM/embedded-4_9-branch revision 218278] > > trunk is: > arm-none-eabi-gcc (unknown) 5.0.0 20150217 (experimental)