This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch, ARM] Prefer using r3 for padding a push/pop for 8-byte stack alignment
- From: Richard Earnshaw <Richard dot Earnshaw at buzzard dot freeserve dot co dot uk>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 02 Jun 2009 08:51:59 +0100
- Subject: [patch, ARM] Prefer using r3 for padding a push/pop for 8-byte stack alignment
When we emit a push/pop multiple instruction we sometimes include an
additional register if it will give us the entire stack-alignment
adjustment needed for the function. Traditionally we have used the next
unused call-saved register for this purpose. However, in Thumb-2 that
might be r8, and r8 might be the only high register other than lr; which
means that we then have to use 32-bit push and pop instructions rather
than 16-bit versions.
This patch re-orders the code slightly to always prefer pushing r3 if it
is available; this is never worse for any execution mode, but in thumb2
might give us slightly more compact code -- indeed it shaves 1.6k off
the CSiBE numbers for thumb2 at -Os.
R.
2009-06-02 Richard Earnshaw <rearnsha@arm.com>
* arm.c (arm_get_frame_offsets): Prefer using r3 for padding a
push/pop multiple to 8-byte alignment.
*** config/arm/arm.c (revision 148108)
--- config/arm/arm.c (local)
*************** arm_get_frame_offsets (void)
*** 12822,12843 ****
{
int reg = -1;
! for (i = 4; i <= (TARGET_THUMB1 ? LAST_LO_REGNUM : 11); i++)
{
- if ((offsets->saved_regs_mask & (1 << i)) == 0)
- {
- reg = i;
- break;
- }
- }
-
- if (reg == -1 && arm_size_return_regs () <= 12
- && !crtl->tail_call_emit)
- {
- /* Push/pop an argument register (r3) if all callee saved
- registers are already being pushed. */
reg = 3;
}
if (reg != -1)
{
--- 12822,12844 ----
{
int reg = -1;
! /* If it is safe to use r3, then do so. This sometimes
! generates better code on Thumb-2 by avoiding the need to
! use 32-bit push/pop instructions. */
! if (!crtl->tail_call_emit
! && arm_size_return_regs () <= 12)
{
reg = 3;
}
+ else
+ for (i = 4; i <= (TARGET_THUMB1 ? LAST_LO_REGNUM : 11); i++)
+ {
+ if ((offsets->saved_regs_mask & (1 << i)) == 0)
+ {
+ reg = i;
+ break;
+ }
+ }
if (reg != -1)
{