re PR rtl-optimization/57003 (gcc breaks -O2 optimization with Wine(64) - links/info...
authorJakub Jelinek <jakub@redhat.com>
Thu, 25 Apr 2013 21:49:22 +0000 (23:49 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 25 Apr 2013 21:49:22 +0000 (23:49 +0200)
PR rtl-optimization/57003
* regcprop.c (copyprop_hardreg_forward_1): If ksvd.ignore_set_reg,
call note_stores with kill_clobbered_value callback again after
killing regs_invalidated_by_call.

* gcc.target/i386/pr57003.c: New test.

From-SVN: r198320

gcc/ChangeLog
gcc/regcprop.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr57003.c [new file with mode: 0644]

index 6985a051f24e03a829cce0d99e67d791e9e0c16e..847b1e6128e1c6d1347eb8a630b6bff3954f284b 100644 (file)
@@ -1,3 +1,10 @@
+2013-04-25  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/57003
+       * regcprop.c (copyprop_hardreg_forward_1): If ksvd.ignore_set_reg,
+       call note_stores with kill_clobbered_value callback again after
+       killing regs_invalidated_by_call.
+
 2013-04-25  James Greenhalgh  <james.greenhalgh@arm.com>
 
        * config/aarch64/aarch64-simd.md
index 97a023fc12a2a4fd427e6c5b45903207a0db576a..896902f30121d8ca2d1ed48bbe0adc62326b95d2 100644 (file)
@@ -1015,6 +1015,13 @@ copyprop_hardreg_forward_1 (basic_block bb, struct value_data *vd)
          EXECUTE_IF_SET_IN_HARD_REG_SET (regs_invalidated_by_call, 0, regno, hrsi)
            if (regno < set_regno || regno >= set_regno + set_nregs)
              kill_value_regno (regno, 1, vd);
+
+         /* If SET was seen in CALL_INSN_FUNCTION_USAGE, and SET_SRC
+            of the SET isn't in regs_invalidated_by_call hard reg set,
+            but instead among CLOBBERs on the CALL_INSN, we could wrongly
+            assume the value in it is still live.  */
+         if (ksvd.ignore_set_reg)
+           note_stores (PATTERN (insn), kill_clobbered_value, vd);
        }
 
       /* Notice stores.  */
index bcfc726fbb267caa38243c512e25657ba1b3b84c..9cc5ce1f534a34ea8dbb8bacf38e0a0f8ea3f2cd 100644 (file)
@@ -1,3 +1,8 @@
+2013-04-25  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/57003
+       * gcc.target/i386/pr57003.c: New test.
+
 2013-04-25  Marek Polacek  <polacek@redhat.com>
 
        PR tree-optimization/57066
diff --git a/gcc/testsuite/gcc.target/i386/pr57003.c b/gcc/testsuite/gcc.target/i386/pr57003.c
new file mode 100644 (file)
index 0000000..dfa6b8b
--- /dev/null
@@ -0,0 +1,54 @@
+/* PR rtl-optimization/57003 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#define N 2001
+unsigned short *b, *c, *d;
+
+__attribute__ ((noinline, noclone)) unsigned
+bar (void)
+{
+  asm volatile ("" : : : "memory");
+  return N;
+}
+
+__attribute__ ((noinline, noclone)) unsigned short *
+baz (unsigned long x)
+{
+  if (x != N * sizeof (unsigned short) + 20)
+    __builtin_abort ();
+  asm volatile ("" : : : "memory");
+  return d;
+}
+
+__attribute__ ((ms_abi, noinline, noclone))
+foo (void)
+{
+  unsigned d;
+  unsigned short *e;
+  if ((d = bar ()))
+    {
+      e = baz (d * sizeof (unsigned short) + 20);
+      __builtin_memcpy (e, b, d * sizeof (unsigned short));
+      c = e;
+    }
+}
+
+int
+main ()
+{
+  unsigned short a[2 * N];
+  int i;
+  for (i = 0; i < 2 * N; i++)
+    a[i] = i + 1;
+  b = a;
+  d = a + N;
+  asm volatile ("" : : : "memory");
+  foo ();
+  for (i = 0; i < N; i++)
+    if (a[i] != i + 1 || a[i + N] != i + 1)
+      __builtin_abort ();
+  if (c != a + N)
+    __builtin_abort ();
+  return 0;
+}