This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[aarch64] Add legitimize_address hook
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 16 Oct 2014 17:21:01 +0100
- Subject: [aarch64] Add legitimize_address hook
- Authentication-results: sourceware.org; auth=none
AArch64 currently does not have a legitimize address hook to find better
solutions for loading from addresses that are not valid. The current
approach 'gets away with it' much of the time because we currently split
constants during expand. We might change that soon, since it is
inhibits other optimizations. Even so, there are some cases where we
don't get code that is as good as it can be. Consider:
typedef double t;
t f(char *a)
{
return *(t*)(a+4093) + *(t*)(a+4266);
}
This currently expands to
add x1, x0, 4093
add x0, x0, 4096
ldr d1, [x1]
ldr d0, [x0,170]
fadd d0, d1, d0
ret
With the patch, we now get
add x0, x0, 4096
ldr d1, [x0,-3]
ldr d0, [x0,170]
fadd d0, d1, d0
ret
Saving us an instruction.
* aarch64.c (aarch64_legitimize_address): New function
(TARGET_LEGITIMIZE_ADDRESS): Redefine.
Bootstrapped and tested; committed to trunk.
R.