The following fixes SLP live lane generation for load-lanes which
fails to analyze for gcc.dg/vect/vect-live-slp-3.c because the
VLA division doesn't work out but it would also wrongly use the
transposed vector defs I think. The following properly disables
the actual load-lanes SLP node from live lane processing and instead
relies on the SLP permute node representing the live lane where we
can use extract-last to extract the last lane.
Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
PR tree-optimization/117556
* tree-vect-stmts.cc (vect_analyze_stmt): Do not analyze
the SLP load-lanes node for live lanes, but only the
permute node.
(vect_transform_stmt): Likewise for the transform.
* gcc.dg/vect/vect-live-slp-3.c: Expect us to SLP even for
VLA vectors (in single-lane mode).
---
gcc/testsuite/gcc.dg/vect/vect-live-slp-3.c | 2 +-
gcc/tree-vect-stmts.cc | 6 +++++-
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/gcc/testsuite/gcc.dg/vect/vect-live-slp-3.c
b/gcc/testsuite/gcc.dg/vect/vect-live-slp-3.c
index e3782240675..3caeea71ad7 100644
--- a/gcc/testsuite/gcc.dg/vect/vect-live-slp-3.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-live-slp-3.c
@@ -73,5 +73,5 @@ main (void)
}
/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 4 "vect" } } */
-/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 4 "vect" {
xfail vect_variable_length } } } */
+/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 4 "vect" }
} */
/* { dg-final { scan-tree-dump-times "vec_stmt_relevant_p: stmt live but not
relevant" 4 "vect" } } */
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 66eda7d5ace..baf49ec4cf1 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -13594,6 +13594,7 @@ vect_analyze_stmt (vec_info *vinfo,
if (!bb_vinfo
&& STMT_VINFO_TYPE (stmt_info) != reduc_vec_info_type
&& STMT_VINFO_TYPE (stmt_info) != lc_phi_info_type
+ && (!node || !node->ldst_lanes || SLP_TREE_CODE (node) == VEC_PERM_EXPR)
&& !can_vectorize_live_stmts (as_a <loop_vec_info> (vinfo),
stmt_info, node, node_instance,
false, cost_vec))
@@ -13756,7 +13757,10 @@ vect_transform_stmt (vec_info *vinfo,
if (!slp_node && vec_stmt)
gcc_assert (STMT_VINFO_VEC_STMTS (stmt_info).exists ());
- if (STMT_VINFO_TYPE (stmt_info) != store_vec_info_type)
+ if (STMT_VINFO_TYPE (stmt_info) != store_vec_info_type
+ && (!slp_node
+ || !slp_node->ldst_lanes
+ || SLP_TREE_CODE (slp_node) == VEC_PERM_EXPR))
{
/* Handle stmts whose DEF is used outside the loop-nest that is
being vectorized. */
--
2.43.0