Bootstrapped & tested on x86_64-unknown-linux-gnu, applied.

Richard.

2019-11-12  Richard Biener  <rguent...@suse.de>

        PR tree-optimization/92461
        * tree-vect-loop.c (vect_create_epilog_for_reduction): Update
        stmt after propagation.

        * gcc.dg/torture/pr92461.c: New testcase.

Index: gcc/tree-vect-loop.c
===================================================================
--- gcc/tree-vect-loop.c        (revision 278081)
+++ gcc/tree-vect-loop.c        (working copy)
@@ -5300,8 +5300,11 @@ vect_create_epilog_for_reduction (stmt_v
           orig_name = PHI_RESULT (exit_phi);
           scalar_result = scalar_results[k];
           FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, orig_name)
-            FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter)
-              SET_USE (use_p, scalar_result);
+           {
+             FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter)
+               SET_USE (use_p, scalar_result);
+             update_stmt (use_stmt);
+           }
         }
 
       phis.release ();
Index: gcc/testsuite/gcc.dg/torture/pr92461.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr92461.c      (nonexistent)
+++ gcc/testsuite/gcc.dg/torture/pr92461.c      (working copy)
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-ftree-vectorize" } */
+
+short int zb;
+
+void
+gs (void)
+{
+  while (zb < 1)
+    {
+      int at;
+
+      zb %= 1;
+
+      for (at = 0; at < 56; ++at)
+       zb += zb;
+
+      ++zb;
+    }
+}

Reply via email to