]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/123983 - only update IV on the requested edge
authorRichard Biener <rguenther@suse.de>
Thu, 5 Feb 2026 10:09:59 +0000 (11:09 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 5 Feb 2026 12:58:53 +0000 (13:58 +0100)
The following reverts back to only updating the IV after the
vectorized loop on the requested edge which avoids disrupting
live value vectorization.

PR tree-optimization/123983
* tree-vect-loop-manip.cc (vect_update_ivs_after_vectorizer):
Only update the PHI argument on the requested edge.

* gcc.dg/vect/vect-pr123983.c: New testcase.

gcc/testsuite/gcc.dg/vect/vect-pr123983.c [new file with mode: 0644]
gcc/tree-vect-loop-manip.cc

diff --git a/gcc/testsuite/gcc.dg/vect/vect-pr123983.c b/gcc/testsuite/gcc.dg/vect/vect-pr123983.c
new file mode 100644 (file)
index 0000000..797c007
--- /dev/null
@@ -0,0 +1,28 @@
+/* { dg-additional-options "-O1" } */
+
+#include "tree-vect.h"
+
+unsigned char b;
+unsigned short c;
+
+[[gnu::noipa]]
+void f() {
+  unsigned char bb = b;
+  unsigned short cc = c;
+  do {
+    bb--;
+    cc--;
+    c--;
+  } while (bb);
+  //c = cc;
+  b = bb;
+}
+
+int main()
+{
+  check_vect ();
+  f();
+  if (c != 65280)
+    __builtin_abort();
+  return 0;
+}
index f28d89ce2d10c74aaf9ce556ac1b94adf7ea9d56..cd1ea746ae454e76ed93845b0aabea7bf1636eaf 100644 (file)
@@ -2505,20 +2505,8 @@ vect_update_ivs_after_vectorizer (loop_vec_info loop_vinfo,
          gsi_insert_seq_before (&last_gsi, new_stmts, GSI_SAME_STMT);
        }
 
-      /* Fix phi expressions in all out of loop bb.  */
-      imm_use_iterator imm_iter;
-      gimple *use_stmt;
-      use_operand_p use_p;
-      tree ic_var = PHI_ARG_DEF_FROM_EDGE (phi1, update_e);
-      if (TREE_CODE (ic_var) == SSA_NAME)
-       {
-         FOR_EACH_IMM_USE_STMT (use_stmt, imm_iter, ic_var)
-           if (!flow_bb_inside_loop_p (loop, gimple_bb (use_stmt)))
-             FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter)
-               SET_USE (use_p, ni_name);
-       }
-      else
-       adjust_phi_and_debug_stmts (phi1, update_e, ni_name);
+      /* Update the PHI argument on the requested edge.  */
+      adjust_phi_and_debug_stmts (phi1, update_e, ni_name);
     }
 }