> Jeff Law wrote:
> OK with the appropropriate ChangeLog entires.  THe original for
> ira-costs.c was fine, so you just need the trivial one for the testcase.

ChangeLog below - Jiong, could you commit for me please?

2014-12-02  Wilco Dijkstra  <wdijk...@arm.com>

        * gcc/ira-costs.c (scan_one_insn): Improve spill cost adjustment.
        * gcc/testsuite/gcc.target/aarch64/remat1.c: New testcase.
---
 gcc/ira-costs.c                           |  5 ++---
 gcc/testsuite/gcc.target/aarch64/remat1.c | 20 ++++++++++++++++++++
 2 files changed, 22 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/aarch64/remat1.c

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..999577e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/remat1.c
@@ -0,0 +1,20 @@
+/* { 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 } } */
+
-- 
1.9.1

Reply via email to