From: Richard Biener Date: Thu, 5 Feb 2026 10:09:59 +0000 (+0100) Subject: tree-optimization/123983 - only update IV on the requested edge X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=856ba1d7f786b0b5e53042e292296391ae1b0da4;p=thirdparty%2Fgcc.git tree-optimization/123983 - only update IV on the requested edge 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. --- diff --git a/gcc/testsuite/gcc.dg/vect/vect-pr123983.c b/gcc/testsuite/gcc.dg/vect/vect-pr123983.c new file mode 100644 index 00000000000..797c0074f68 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-pr123983.c @@ -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; +} diff --git a/gcc/tree-vect-loop-manip.cc b/gcc/tree-vect-loop-manip.cc index f28d89ce2d1..cd1ea746ae4 100644 --- a/gcc/tree-vect-loop-manip.cc +++ b/gcc/tree-vect-loop-manip.cc @@ -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); } }