This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RE: [PATCH] Improve spillcost of literal pool loads
- From: "Wilco Dijkstra" <wdijkstr at arm dot com>
- To: "'Jeff Law'" <law at redhat dot com>, <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 28 Nov 2014 14:10:24 -0000
- Subject: RE: [PATCH] Improve spillcost of literal pool loads
- Authentication-results: sourceware.org; auth=none
- References: <002201cff37b$5145f560$f3d1e020$ at com> <545152C7 dot 40405 at redhat dot com>
> 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
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 } } */
+
--
1.9.1