]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[RTL-ree] PR rtl-optimization/68194: Restrict copy instruction in presence of conditi...
authorKyrylo Tkachov <kyrylo.tkachov@arm.com>
Tue, 24 Nov 2015 14:27:51 +0000 (14:27 +0000)
committerKyrylo Tkachov <ktkachov@gcc.gnu.org>
Tue, 24 Nov 2015 14:27:51 +0000 (14:27 +0000)
Backport from mainline
2015-11-24  Bernd Schmidt <bschmidt@redhat.com>
            Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

PR rtl-optimization/68194
PR rtl-optimization/68328
PR rtl-optimization/68185
* ree.c (combine_reaching_defs): Reject copy_needed case if
copies_list is not empty.

* gcc.c-torture/execute/pr68185.c: New test.
* gcc.c-torture/execute/pr68328.c: Likewise.

From-SVN: r230813

gcc/ChangeLog
gcc/ree.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr68185.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/execute/pr68328.c [new file with mode: 0644]

index 33584acf3515fb53d5d26189126ec381cf98bf25..f6cab87bb7de73139638491b9450dfd361d55b30 100644 (file)
@@ -1,3 +1,15 @@
+2015-11-24  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+
+       Backport from mainline
+       2015-11-24  Bernd Schmidt <bschmidt@redhat.com>
+                   Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+
+       PR rtl-optimization/68194
+       PR rtl-optimization/68328
+       PR rtl-optimization/68185
+       * ree.c (combine_reaching_defs): Reject copy_needed case if
+       copies_list is not empty.
+
 2015-11-23  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
        Backport from mainline
index 7d00d816d4001a7b26f0b15f6331fded98995804..60af8eadeac16ca5f5503f8fcb039fb3dada2b1f 100644 (file)
--- a/gcc/ree.c
+++ b/gcc/ree.c
@@ -783,6 +783,12 @@ combine_reaching_defs (ext_cand *cand, const_rtx set_pat, ext_state *state)
       if (state->defs_list.length () != 1)
        return false;
 
+      /* We don't have the structure described above if there are
+        conditional moves in between the def and the candidate,
+        and we will not handle them correctly.  See PR68194.  */
+      if (state->copies_list.length () > 0)
+       return false;
+
       /* We require the candidate not already be modified.  It may,
         for example have been changed from a (sign_extend (reg))
         into (zero_extend (sign_extend (reg))).
index 08984f016cd06c3df4a438a5be1a8a60257633c6..04a458433e7cfd6cb20525ba0343d0aa174c7568 100644 (file)
@@ -1,3 +1,14 @@
+2015-11-24  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+
+       Backport from mainline
+       2015-11-24  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+
+       PR rtl-optimization/68194
+       PR rtl-optimization/68328
+       PR rtl-optimization/68185
+       * gcc.c-torture/execute/pr68185.c: New test.
+       * gcc.c-torture/execute/pr68328.c: Likewise.
+
 2015-11-23  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
        Backport from mainline
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr68185.c b/gcc/testsuite/gcc.c-torture/execute/pr68185.c
new file mode 100644 (file)
index 0000000..826531b
--- /dev/null
@@ -0,0 +1,29 @@
+int a, b, d = 1, e, f, o, u, w = 1, z;
+short c, q, t;
+
+int
+main ()
+{
+  char g;
+  for (; d; d--)
+    {
+      while (o)
+       for (; e;)
+         {
+           c = b;
+           int h = o = z;
+           for (; u;)
+             for (; a;)
+               ;
+         }
+      if (t < 1)
+       g = w;
+      f = g;
+      g && (q = 1);
+    }
+
+  if (q != 1)
+    __builtin_abort ();
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr68328.c b/gcc/testsuite/gcc.c-torture/execute/pr68328.c
new file mode 100644 (file)
index 0000000..edf244b
--- /dev/null
@@ -0,0 +1,44 @@
+int a, b, c = 1, d = 1, e;
+
+__attribute__ ((noinline, noclone))
+     int foo (void)
+{
+  asm volatile ("":::"memory");
+  return 4195552;
+}
+
+__attribute__ ((noinline, noclone))
+     void bar (int x, int y)
+{
+  asm volatile (""::"g" (x), "g" (y):"memory");
+  if (y == 0)
+    __builtin_abort ();
+}
+
+int
+baz (int x)
+{
+  char g, h;
+  int i, j;
+
+  foo ();
+  for (;;)
+    {
+      if (c)
+       h = d;
+      g = h < x ? h : 0;
+      i = (signed char) ((unsigned char) (g - 120) ^ 1);
+      j = i > 97;
+      if (a - j)
+       bar (0x123456, 0);
+      if (!b)
+       return e;
+    }
+}
+
+int
+main ()
+{
+  baz (2);
+  return 0;
+}