re PR rtl-optimization/80903 (ICE: internal consistency failure (error: invalid rtl...
authorJakub Jelinek <jakub@redhat.com>
Fri, 2 Jun 2017 08:07:15 +0000 (10:07 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 2 Jun 2017 08:07:15 +0000 (10:07 +0200)
PR rtl-optimization/80903
* loop-doloop.c (add_test): Unshare sequence.

* gcc.dg/pr80903.c: New test.

From-SVN: r248815

gcc/ChangeLog
gcc/loop-doloop.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr80903.c [new file with mode: 0644]

index 3700ebc087a5bf567cd1da3f8a393fa924560c2d..f44c2b829f6a94f7849d6cf99e28fb4447176b0f 100644 (file)
@@ -1,3 +1,8 @@
+2017-06-02  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/80903
+       * loop-doloop.c (add_test): Unshare sequence.
+
 2017-06-02  Bernd Edlinger  <bernd.edlinger@hotmail.de>
 
        * doc/invoke.texi: Document the -Wsizeof-pointer-div warning.
index 3483000aa97cc1099a8e716f3c65623391f1242a..c018e2ce634b99e7e138b355bb8e36946722950b 100644 (file)
@@ -367,6 +367,7 @@ add_test (rtx cond, edge *e, basic_block dest)
     }
 
   seq = get_insns ();
+  unshare_all_rtl_in_chain (seq);
   end_sequence ();
 
   /* There always is at least the jump insn in the sequence.  */
index a111f2b80bcb1ce009879b8b951079fd0075fc21..dc6cdcd36062f77086fef741e5661adbeb29cfc7 100644 (file)
@@ -1,5 +1,8 @@
 2017-06-02  Jakub Jelinek  <jakub@redhat.com>
 
+       PR rtl-optimization/80903
+       * gcc.dg/pr80903.c: New test.
+
        PR fortran/80918
        * gfortran.dg/gomp/pr80918.f90: New test.
 
diff --git a/gcc/testsuite/gcc.dg/pr80903.c b/gcc/testsuite/gcc.dg/pr80903.c
new file mode 100644 (file)
index 0000000..73d44b0
--- /dev/null
@@ -0,0 +1,34 @@
+/* PR rtl-optimization/80903 */
+/* { dg-do compile } */
+/* { dg-options "-O3 -funroll-loops" } */
+
+short int a;
+
+void
+foo (int x, short int y, short int z)
+{
+  if (y != 0)
+    {
+      const short int b = 37;
+      y = 0;
+      while (y < b)
+       {
+         while (y < b)
+           {
+           lab:
+             ++y;
+           }
+         for (y = 0; y < b - 1; ++y)
+           ;
+         if (z != 0)
+           {
+             --a;
+             y *= a;
+           }
+         z = x;
+       }
+      x = 0;
+    }
+
+  goto lab;
+}