On 27/02/15 09:41, Richard Earnshaw wrote:
On 19/02/15 12:19, Matthew Wahab wrote:
The LEGITIMIZE_RELOAD_ADDRESS macro is only needed for reload. Since the
ARM backend no longer supports reload, this macro is not needed and this
patch removes it.

gcc/
2015-02-19  Matthew Wahab  <matthew.wa...@arm.com>

     * config/arm/arm.h (LEGITIMIZE_RELOAD_ADDRESS): Remove.
     (ARM_LEGITIMIZE_RELOAD_ADDRESS): Remove.
     (THUMB_LEGITIMIZE_RELOAD_ADDRESS): Remove.
     * config/arm/arm.c (arm_legitimize_reload_address): Remove.
     (thumb_legitimize_reload_address): Remove.
     * config/arm/arm-protos.h (arm_legitimize_reload_address):
     Remove.
     (thumb_legitimize_reload_address): Remove.


This is OK for stage 1.

I have one open question: can LRA generate the optimizations that these
hooks used to provide through reload?  If not, please could you file
some bugzilla reports so that we don't lose them.

Thanks,
R.

arm_legitimize_reload_address was added by https://gcc.gnu.org/ml/gcc-patches/2011-04/msg00605.html. From config/arm/arm.c, the optimization turns
                 add t1, r2, #4096
                 ldr r0, [t1, #4]
                 add t2, r2, #4096
                 ldr r1, [t2, #8]
into
                 add t1, r2, #4096
                 ldr r0, [t1, #4]
                 ldr r1, [t1, #8]

As far as I can tell, LRA does do this. Compiling the following with -O1:
----
int bar(int, int, int);
int test1(int* buf)
{
  int a = buf[41000];
  int b = buf[41004];
  int c = buf[41008];
  bar(a, b, c);
  return a +  b + c;
}
----
gcc version 4.5.1 (Sourcery G++ Lite 2010.09-51), which predates the optimization, produces
        ldr     r3, .L2
        ldr     r4, [r0, r3]
        add     r3, r3, #16
        ldr     r5, [r0, r3]
        add     r3, r3, #16
        ldr     r6, [r0, r3]

gcc version 4.9.3 20141119 with and without -mno-lra produce
        add     r0, r0, #163840
        ldr     r4, [r0, #160]
        ldr     r6, [r0, #176]
        ldr     r5, [r0, #192]
so it looks the better sequence gets generated.

thumb_legitimize_reload_address was added by https://gcc.gnu.org/ml/gcc-patches/2005-08/msg01140.html to fix PR 23436. It replaces sequences like
        mov     r3, r9
        mov     r2, r10
        ldr     r0, [r3, r2]
with
        mov     r3, r9
        add     r3, r3, r10
        ldr     r0, [r3]

This looks like it's missing from trunk so I'll open a bugzilla report for it.

It's quite possible that I've got this all wrong so if I've missed something or you'd like me to open a bugzilla report for the ARM optimization as well, let me know.

Matthew


Reply via email to