]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/95717 - fix SSA update for vectorizer epilogue
authorRichard Biener <rguenther@suse.de>
Wed, 17 Jun 2020 12:57:59 +0000 (14:57 +0200)
committerRichard Biener <rguenther@suse.de>
Wed, 24 Jun 2020 07:01:52 +0000 (09:01 +0200)
This fixes yet another issue with the custom SSA updating in the
vectorizer when we copy from the non-if-converted loop.  We must
not mess with current defs before we updated the BB copies.

2020-06-17  Richard Biener  <rguenther@suse.de>

PR tree-optimization/95717
* tree-vect-loop-manip.c (slpeel_tree_duplicate_loop_to_edge_cfg):
Move BB SSA updating before exit/latch PHI current def copying.

* g++.dg/torture/pr95717.C: New testcase.

(cherry picked from commit d0909f5858ad81e6d8b73fa6193be19cb5e6ed7b)

gcc/testsuite/g++.dg/torture/pr95717.C [new file with mode: 0644]
gcc/tree-vect-loop-manip.c

diff --git a/gcc/testsuite/g++.dg/torture/pr95717.C b/gcc/testsuite/g++.dg/torture/pr95717.C
new file mode 100644 (file)
index 0000000..362dc10
--- /dev/null
@@ -0,0 +1,12 @@
+// { dg-do compile }
+
+bool a;
+extern bool b[];
+long c, d;
+int *f;
+void g(bool h)
+{
+  for (short e = 0; e < c; e = 4)
+    for (; d; d++)
+      b[d] = a = f[d] ? c ? h : 0 : h;
+}
index 0ee1ab45c07d548d8938ae75f5c655b504b74f1e..4bed8e411a07b97a0c11266ac44ce347bcc974b7 100644 (file)
@@ -1052,6 +1052,10 @@ slpeel_tree_duplicate_loop_to_edge_cfg (class loop *loop,
 
   add_phi_args_after_copy (new_bbs, scalar_loop->num_nodes + 1, NULL);
 
+  /* Skip new preheader since it's deleted if copy loop is added at entry.  */
+  for (unsigned i = (at_exit ? 0 : 1); i < scalar_loop->num_nodes + 1; i++)
+    rename_variables_in_bb (new_bbs[i], duplicate_outer_loop);
+
   if (scalar_loop != loop)
     {
       /* If we copied from SCALAR_LOOP rather than LOOP, SSA_NAMEs from
@@ -1129,10 +1133,6 @@ slpeel_tree_duplicate_loop_to_edge_cfg (class loop *loop,
                               loop_preheader_edge (new_loop)->src);
     }
 
-  /* Skip new preheader since it's deleted if copy loop is added at entry.  */
-  for (unsigned i = (at_exit ? 0 : 1); i < scalar_loop->num_nodes + 1; i++)
-    rename_variables_in_bb (new_bbs[i], duplicate_outer_loop);
-
   if (scalar_loop != loop)
     {
       /* Update new_loop->header PHIs, so that on the preheader