diff mbox

Improve spillcost of literal pool loads

Message ID 000201d00b15$0dc16020$29442060$@com
State New
Headers show

Commit Message

Wilco Nov. 28, 2014, 2:10 p.m. UTC
> Jeff Law wrote:
> Do you have a testcase that shows the expected improvements from this
> change?  It's OK if it's specific to a target.
> 
> Have you bootstrapped and regression tested this change?
> 
> With a test for the testsuite and assuming it passes bootstrap and
> regression testing, this will almost certainly be OK.

I've added a test, see below. It bootstraps OK on AArch64 and the only
difference in the regression tests after the patch is the one extra pass.

OK for commit?

---
 gcc/ira-costs.c                           |  5 ++---
 gcc/testsuite/gcc.target/aarch64/remat1.c | 19 +++++++++++++++++++
 2 files changed, 21 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/aarch64/remat1.c

Comments

Jeff Law Dec. 1, 2014, 5:31 p.m. UTC | #1
On 11/28/14 07:10, Wilco Dijkstra wrote:
>> Jeff Law wrote:
>> Do you have a testcase that shows the expected improvements from this
>> change?  It's OK if it's specific to a target.
>>
>> Have you bootstrapped and regression tested this change?
>>
>> With a test for the testsuite and assuming it passes bootstrap and
>> regression testing, this will almost certainly be OK.
>
> I've added a test, see below. It bootstraps OK on AArch64 and the only
> difference in the regression tests after the patch is the one extra pass.
>
> OK for commit?
OK with the appropropriate ChangeLog entires.  THe original for 
ira-costs.c was fine, so you just need the trivial one for the testcase.

jeff
diff mbox

Patch

diff --git a/gcc/ira-costs.c b/gcc/ira-costs.c
index 122815b..95d266e 100644
--- a/gcc/ira-costs.c
+++ b/gcc/ira-costs.c
@@ -1462,12 +1462,11 @@  scan_one_insn (rtx_insn *insn)
       && ((MEM_P (XEXP (note, 0))
           && !side_effects_p (SET_SRC (set)))
          || (CONSTANT_P (XEXP (note, 0))
-             && targetm.legitimate_constant_p (GET_MODE (SET_DEST (set)),
-                                               XEXP (note, 0))
+             && (! flag_pic || LEGITIMATE_PIC_OPERAND_P (XEXP (note, 0)))
              && REG_N_SETS (REGNO (SET_DEST (set))) == 1))
       && general_operand (SET_SRC (set), GET_MODE (SET_SRC (set))))
     {
-      enum reg_class cl = GENERAL_REGS;
+      enum reg_class cl = ALL_REGS;
       rtx reg = SET_DEST (set);
       int num = COST_INDEX (REGNO (reg));
 
diff --git a/gcc/testsuite/gcc.target/aarch64/remat1.c b/gcc/testsuite/gcc.target/aarch64/remat1.c
new file mode 100644
index 0000000..f020709
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/remat1.c
@@ -0,0 +1,19 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -fomit-frame-pointer -fcaller-saves -ffixed-d8 -ffixed-d9 -ffixed-d10
-ffixed-d11 -ffixed-d12 -ffixed-d13 -ffixed-d14 -ffixed-d15" } */
+
+/* Under high register pressure FP immediates should be rematerialized
+   as literal loads rather than being caller-saved to the stack.  */
+
+void g (void);
+
+float
+f (float x)
+{
+  x += 3.1f;
+  g ();
+  x *= 3.1f;
+  return x;
+}
+
+/* { dg-final { scan-assembler-times "ldr\ts\[0-9]+, .LC0" 2 } } */
+