re PR rtl-optimization/80500 (ICE: internal consistency failure (error: invalid rtl...
authorJakub Jelinek <jakub@redhat.com>
Tue, 25 Apr 2017 07:27:01 +0000 (09:27 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 25 Apr 2017 07:27:01 +0000 (09:27 +0200)
PR rtl-optimization/80500
* loop-unroll.c (combine_var_copies_in_loop_exit): Call copy_rtx on
sum's initial value.

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

From-SVN: r247126

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

index 9b389a0630fc750da6dc1ced48aa4aa9beabaae2..1138786b99672c80833df8ec34a819c89e614141 100644 (file)
@@ -1,3 +1,9 @@
+2017-04-25  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/80500
+       * loop-unroll.c (combine_var_copies_in_loop_exit): Call copy_rtx on
+       sum's initial value.
+
 2017-04-25  Julian Brown  <julian@codesourcery.com>
            Naveen H.S  <Naveen.Hurugalawadi@cavium.com>
 
index dd5bdc519b01ccafaecf21dccd0fb6c310f6d9a9..3d48a8fb7bc5f0e9e9f6d0a2dfd89d8485ba3eb6 100644 (file)
@@ -1913,6 +1913,9 @@ combine_var_copies_in_loop_exit (struct var_to_expand *ve, basic_block place)
   if (ve->var_expansions.length () == 0)
     return;
 
+  /* ve->reg might be SUBREG or some other non-shareable RTL, and we use
+     it both here and as the destination of the assignment.  */
+  sum = copy_rtx (sum);
   start_sequence ();
   switch (ve->op)
     {
index 4fb111ebe904f0206a9e97ea4f8a815f8cc17da5..96f33f0475539f972a825b527b7add6ef0baad7e 100644 (file)
@@ -1,3 +1,8 @@
+2017-04-25  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/80500
+       * gcc.dg/pr80500.c: New test.
+
 2017-04-25  Marc Glisse  <marc.glisse@inria.fr>
 
        * gcc.dg/tree-ssa/cmpmul-1.c: New file.
diff --git a/gcc/testsuite/gcc.dg/pr80500.c b/gcc/testsuite/gcc.dg/pr80500.c
new file mode 100644 (file)
index 0000000..ae3ac01
--- /dev/null
@@ -0,0 +1,15 @@
+/* PR rtl-optimization/80500 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -funroll-loops -ftree-loop-if-convert -fvariable-expansion-in-unroller" } */
+
+signed char v;
+
+void
+foo (int x)
+{
+  while (x != 0)
+    {
+      v = (x >= 0) + 1;
+      ++x;
+    }
+}