This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Improve reload's handling of classes with only fixed registers

The ARM port supports instructions of the form "add reg, sp, #const"
with "k" constraints, which allow only only the stack pointer register,
on some alternatives.  It has to strongly discourage these with "!"
constraints, since otherwise it is conceivable that reload would choose
such an alternative, and try to reload a value into the stack pointer -
not good.  However, this means such an alternative will never be chosen
unless it already matches exactly.

The following patch improves reload's handling of such register classes.
 A new array, class_only_fixed_regs is used to determine if an
alternative can be used for reloading.  Currently, if an alternative
allows any kind of register, it is considered good; with this patch, the
existing operand either has to match the class already (which should be
the case for SP), or the class has to allow nonfixed registers.

Typical results for Thumb-1 code:
-       mov     r3, sp
-       add     r3, r3, #24
+       add     r3, sp, #24

or even

-       mov     r1, #138
-       lsl     r1, r1, #1
-       add     r1, r1, sp
+       add     r1, sp, #276

Bootstrapped and regression tested on i686-linux.  Also regression
tested for arm-linux (same options as usual).  Given the reload part,
the rest of the patch seems obvious, so I've committed it.


Attachment: reload-fixedregs.diff
Description: Text document

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]