From: Richard Biener Date: Thu, 5 Mar 2026 10:20:44 +0000 (+0100) Subject: Avoid live code-generation for stmts kept as scalars X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=bbb4d007316269bea3a72c2a77cad75945f2433f;p=thirdparty%2Fgcc.git Avoid live code-generation for stmts kept as scalars The following avoids trying to code-generate live lane extracts for scalar defs that we have to keep anyway because they are used in SLP graph leafs as extern inputs. This resolves the known cases of one of the workarounds in live code-generation. * tree-vect-slp.cc (vect_bb_slp_mark_live_stmts): Do not attempt to live code-generate defs that are kept in scalar form anyway. * tree-vect-loop.cc (vectorizable_live_operation): Update comment. --- diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index d41e6eb28fa..43b0606a594 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -10420,8 +10420,7 @@ vectorizable_live_operation (vec_info *vinfo, stmt_vec_info stmt_info, /* ??? This can happen when the live lane ends up being rooted in a vector construction code-generated by an external SLP node (and code-generation for that already - happened). See gcc.dg/vect/bb-slp-47.c or - gcc.dg/vect/pr97173.c or gcc.dg/vect/bb-slp-pr115777.c. + happened). Doing this is what would happen if that vector CTOR were not code-generated yet so it is not too bad. ??? In fact we'd likely want to avoid this situation diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc index 34b752bc0ef..fbfbd01c26f 100644 --- a/gcc/tree-vect-slp.cc +++ b/gcc/tree-vect-slp.cc @@ -8986,6 +8986,12 @@ vect_bb_slp_mark_live_stmts (bb_vec_info bb_vinfo, slp_tree node, && STMT_VINFO_RELATED_STMT (orig_stmt_info) != stmt_info) /* Only the pattern root stmt computes the original scalar value. */ continue; + if (!PURE_SLP_STMT (orig_stmt_info)) + /* Iff the stmt is not part of the vector coverage because it or + uses of it are used by SLP graph leafs as extern input there is + no point in trying to live code-generate from a vector stmt as + the scalar stmt will survive anyway. */ + continue; bool mark_visited = true; gimple *orig_stmt = orig_stmt_info->stmt; ssa_op_iter op_iter;