On 2014-12-17 8:00 PM, Kaz Kojima wrote:
This patch adds a target macro discussed in PR55212
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55212#c76
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55212#c78
is to avoid bad codes on SH.
SH has very limited base+displacement addressing and it looks
that the old reload has some mechanism so to split
Yes, that is probably last thing of reload missed in LRA. As I remember
Joern wrote this very long ago specifically for SH. postreload pass
also has some code to deal with different displacements and their costs
(if there are no constraints on the constants).
reg := mem[base + bad_displacement]
to
new_base := base + (bad_displacement - legitimate_displacement)
reg := mem[new_base + legitimate_displacement]
The new target macro is to give same effect on LRA.
This helps SH especially for the address like stack_pointer + offset
where offset has 4-bit except for SH2A.
I've tried to define this target macro for ARM thumb and found
only one CSiBE test replaypc-0.4.0.preproc/build-ndx is improved
at 4 bytes with -Os. I guess that 8-bit offset field for sp+offset
addressing on ARM thumb is very good for this issue.
Again it would be better if something can cover this case without
new target macros.
--
* lra-constraints.c (process_address_1): Try if target can split
displacement with targetm.legitimize_address_displacement.
* target.def (legitimize_address_displacement): New hook.
* targhooks.c (default_legitimize_address_displacement): New function.
* targhooks.h (default_legitimize_address_displacement): Declare.
* config/sh/sh.c (sh_legitimize_address_displacement): New function.
(TARGET_LEGITIMIZE_ADDRESS_DISPLACEMENT): Define.
* doc/tm.texi.in (TARGET_LEGITIMIZE_ADDRESS_DISPLACEMENT): New hook.
* doc/tm.texi: Regenerate.
It is an interesting solution.
The patch is ok for me.
One more thing though. The patches you propose affect very sensitive
parts of LRA. They might break other ports currently using LRA. If it
happens, please, revert a breaking patch as I can not be a help next 2
weeks.