]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Avoid live code-generation for stmts kept as scalars
authorRichard Biener <rguenther@suse.de>
Thu, 5 Mar 2026 10:20:44 +0000 (11:20 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 28 Apr 2026 11:33:07 +0000 (13:33 +0200)
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.

gcc/tree-vect-loop.cc
gcc/tree-vect-slp.cc

index d41e6eb28fa96571ad8ff458ca58900ae7e0e911..43b0606a5943205e87bfb8d3d32d540e2d69a49f 100644 (file)
@@ -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
index 34b752bc0ef4504bd04ed13f920f539383ed98f3..fbfbd01c26f8dd6d559173279c6895795f6f9fc5 100644 (file)
@@ -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;