From 6ec6dfe49a0209abdd1f4c80548e6f61d6d12ceb Mon Sep 17 00:00:00 2001 From: yroux Date: Fri, 22 Aug 2014 11:41:54 +0000 Subject: [PATCH] gcc/ 2014-08-22 Yvan Roux Backport from trunk r212927, r213304. 2014-07-30 Jiong Wang * config/arm/arm.c (arm_get_frame_offsets): Adjust condition for Thumb2. 2014-07-23 Jiong Wang * config/arm/arm.c (arm_get_frame_offsets): If both r3 and other callee-saved registers are available for padding purpose and r3 is not mandatory, then prefer use those callee-saved instead of r3. gcc/testsuite/ 2014-08-22 Yvan Roux Backport from trunk r212927. 2014-07-23 Jiong Wang * gcc.dg/ira-shrinkwrap-prep-1.c (target): Add arm_nothumb. * gcc.dg/ira-shrinkwrap-prep-2.c (target): Likewise. * gcc.dg/pr10474.c (target): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/linaro@214314 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc-4_9-branch/gcc/ChangeLog.linaro | 15 ++++++++ gcc-4_9-branch/gcc/config/arm/arm.c | 45 +++++++++++++++------- gcc-4_9-branch/gcc/testsuite/ChangeLog.linaro | 9 +++++ .../gcc/testsuite/gcc.dg/ira-shrinkwrap-prep-1.c | 2 +- .../gcc/testsuite/gcc.dg/ira-shrinkwrap-prep-2.c | 2 +- gcc-4_9-branch/gcc/testsuite/gcc.dg/pr10474.c | 2 +- 6 files changed, 58 insertions(+), 17 deletions(-) diff --git a/gcc-4_9-branch/gcc/ChangeLog.linaro b/gcc-4_9-branch/gcc/ChangeLog.linaro index 39fbd71da99..37815824c0c 100644 --- a/gcc-4_9-branch/gcc/ChangeLog.linaro +++ b/gcc-4_9-branch/gcc/ChangeLog.linaro @@ -1,5 +1,20 @@ 2014-08-22 Yvan Roux + Backport from trunk r212927, r213304. + 2014-07-30 Jiong Wang + + * config/arm/arm.c (arm_get_frame_offsets): Adjust condition for + Thumb2. + + 2014-07-23 Jiong Wang + + * config/arm/arm.c (arm_get_frame_offsets): If both r3 and other + callee-saved registers are available for padding purpose + and r3 is not mandatory, then prefer use those callee-saved + instead of r3. + +2014-08-22 Yvan Roux + Backport from trunk r211717, r213692. 2014-08-07 Kugan Vivekanandarajah diff --git a/gcc-4_9-branch/gcc/config/arm/arm.c b/gcc-4_9-branch/gcc/config/arm/arm.c index 2f88c1c895a..a9c53dc5f54 100644 --- a/gcc-4_9-branch/gcc/config/arm/arm.c +++ b/gcc-4_9-branch/gcc/config/arm/arm.c @@ -20772,30 +20772,47 @@ arm_get_frame_offsets (void) { int reg = -1; + /* Register r3 is caller-saved. Normally it does not need to be + saved on entry by the prologue. However if we choose to save + it for padding then we may confuse the compiler into thinking + a prologue sequence is required when in fact it is not. This + will occur when shrink-wrapping if r3 is used as a scratch + register and there are no other callee-saved writes. + + This situation can be avoided when other callee-saved registers + are available and r3 is not mandatory if we choose a callee-saved + register for padding. */ + bool prefer_callee_reg_p = false; + /* 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 (! any_sibcall_could_use_r3 () && arm_size_return_regs () <= 12 && (offsets->saved_regs_mask & (1 << 3)) == 0 - && (TARGET_THUMB2 + && (TARGET_THUMB2 || !(TARGET_LDRD && current_tune->prefer_ldrd_strd))) { reg = 3; + if (!TARGET_THUMB2) + prefer_callee_reg_p = true; + } + if (reg == -1 + || prefer_callee_reg_p) + { + for (i = 4; i <= (TARGET_THUMB1 ? LAST_LO_REGNUM : 11); i++) + { + /* Avoid fixed registers; they may be changed at + arbitrary times so it's unsafe to restore them + during the epilogue. */ + if (!fixed_regs[i] + && (offsets->saved_regs_mask & (1 << i)) == 0) + { + reg = i; + break; + } + } } - else - for (i = 4; i <= (TARGET_THUMB1 ? LAST_LO_REGNUM : 11); i++) - { - /* Avoid fixed registers; they may be changed at - arbitrary times so it's unsafe to restore them - during the epilogue. */ - if (!fixed_regs[i] - && (offsets->saved_regs_mask & (1 << i)) == 0) - { - reg = i; - break; - } - } if (reg != -1) { diff --git a/gcc-4_9-branch/gcc/testsuite/ChangeLog.linaro b/gcc-4_9-branch/gcc/testsuite/ChangeLog.linaro index cfe89afd304..a033dbd6e2e 100644 --- a/gcc-4_9-branch/gcc/testsuite/ChangeLog.linaro +++ b/gcc-4_9-branch/gcc/testsuite/ChangeLog.linaro @@ -1,3 +1,12 @@ +2014-08-22 Yvan Roux + + Backport from trunk r212927. + 2014-07-23 Jiong Wang + + * gcc.dg/ira-shrinkwrap-prep-1.c (target): Add arm_nothumb. + * gcc.dg/ira-shrinkwrap-prep-2.c (target): Likewise. + * gcc.dg/pr10474.c (target): Likewise. + 2014-08-14 Yvan Roux GCC Linaro 4.9-2014.08 released. diff --git a/gcc-4_9-branch/gcc/testsuite/gcc.dg/ira-shrinkwrap-prep-1.c b/gcc-4_9-branch/gcc/testsuite/gcc.dg/ira-shrinkwrap-prep-1.c index 54d3e761573..1025218b22d 100644 --- a/gcc-4_9-branch/gcc/testsuite/gcc.dg/ira-shrinkwrap-prep-1.c +++ b/gcc-4_9-branch/gcc/testsuite/gcc.dg/ira-shrinkwrap-prep-1.c @@ -1,4 +1,4 @@ -/* { dg-do compile { target { { x86_64-*-* && lp64 } || { powerpc*-*-* && lp64 } } } } */ +/* { dg-do compile { target { { x86_64-*-* && lp64 } || { { powerpc*-*-* && lp64 } || arm_nothumb } } } } */ /* { dg-options "-O3 -fdump-rtl-ira -fdump-rtl-pro_and_epilogue" } */ long __attribute__((noinline, noclone)) diff --git a/gcc-4_9-branch/gcc/testsuite/gcc.dg/ira-shrinkwrap-prep-2.c b/gcc-4_9-branch/gcc/testsuite/gcc.dg/ira-shrinkwrap-prep-2.c index ed08494cfa0..e945835f64c 100644 --- a/gcc-4_9-branch/gcc/testsuite/gcc.dg/ira-shrinkwrap-prep-2.c +++ b/gcc-4_9-branch/gcc/testsuite/gcc.dg/ira-shrinkwrap-prep-2.c @@ -1,4 +1,4 @@ -/* { dg-do compile { target { { x86_64-*-* && lp64 } || { powerpc*-*-* && lp64 } } } } */ +/* { dg-do compile { target { { x86_64-*-* && lp64 } || { { powerpc*-*-* && lp64 } || arm_nothumb } } } } */ /* { dg-options "-O3 -fdump-rtl-ira -fdump-rtl-pro_and_epilogue" } */ long __attribute__((noinline, noclone)) diff --git a/gcc-4_9-branch/gcc/testsuite/gcc.dg/pr10474.c b/gcc-4_9-branch/gcc/testsuite/gcc.dg/pr10474.c index 77ccc4606ed..803fa108506 100644 --- a/gcc-4_9-branch/gcc/testsuite/gcc.dg/pr10474.c +++ b/gcc-4_9-branch/gcc/testsuite/gcc.dg/pr10474.c @@ -1,4 +1,4 @@ -/* { dg-do compile { target { { x86_64-*-* && lp64 } || { powerpc*-*-* && lp64 } } } } */ +/* { dg-do compile { target { { x86_64-*-* && lp64 } || { { powerpc*-*-* && lp64 } || arm_nothumb } } } } */ /* { dg-options "-O3 -fdump-rtl-pro_and_epilogue" } */ void f(int *i) -- 2.11.4.GIT