This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PR rtl-optimization/25196
- From: Steven Bosscher <steven dot bosscher at gmail dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Ian Lance Taylor <ian at airs dot com>
- Date: Tue, 10 Jan 2006 19:05:01 +0100
- Subject: PR rtl-optimization/25196
Hi,
My fix for PR25196 has been on the trunk and on the GCC 4.1 branch
for a few weeks now without problems. I tested it on the GCC 4.0
branch too since I commited it. Is this OK to backport to the 4.0
branch?
Thanks,
Gr.
Steven
gcc/
* postreload-gcse.c (record_last_set_info): Notice stack pointer
changes in push insns without REG_INC notes.
testsuite/
* gcc.dg/pr25130.c: New test.
Index: postreload-gcse.c
===================================================================
--- postreload-gcse.c (revision 109471)
+++ postreload-gcse.c (working copy)
@@ -672,10 +672,18 @@ record_last_set_info (rtx dest, rtx sett
if (REG_P (dest))
record_last_reg_set_info (last_set_insn, REGNO (dest));
- else if (MEM_P (dest)
- /* Ignore pushes, they clobber nothing. */
- && ! push_operand (dest, GET_MODE (dest)))
- record_last_mem_set_info (last_set_insn);
+ else if (MEM_P (dest))
+ {
+ /* Ignore pushes, they don't clobber memory. They may still
+ clobber the stack pointer though. Some targets do argument
+ pushes without adding REG_INC notes. See e.g. PR25196,
+ where a pushsi2 on i386 doesn't have REG_INC notes. Note
+ such changes here too. */
+ if (! push_operand (dest, GET_MODE (dest)))
+ record_last_mem_set_info (last_set_insn);
+ else
+ record_last_reg_set_info (last_set_insn, STACK_POINTER_REGNUM);
+ }
}
Index: testsuite/gcc.dg/pr25196.c
===================================================================
--- testsuite/gcc.dg/pr25196.c (revision 0)
+++ testsuite/gcc.dg/pr25196.c (revision 0)
@@ -0,0 +1,34 @@
+/* { dg-do run { target i?86-*-* x86_64-*-* } } */
+/* { dg-require-effective-target ilp32 } */
+/* { dg-options "-march=i386 -O3 -fomit-frame-pointer" } */
+
+/* For this test case, we used to do an invalid load motion after
+ reload, because we missed autoincrements of the stack pointer. */
+
+extern void abort (void);
+
+static int j;
+
+static void __attribute__((noinline))
+f1 (int a, int b, int c, int d, int e)
+{
+ j = a;
+}
+
+int __attribute__((noinline))
+f2 (int a, int b, int c, int d, int e)
+{
+ if ((b & 0x1111) != 1)
+ f1 (a, b, c, d, e);
+ return 0;
+}
+
+int
+main (void)
+{
+ f2 (123, 0, 0, 0, 0);
+ if (j != 123)
+ abort ();
+ return 0;
+}
+