The following makes sure we analyze live LC PHIs not part of a double reduction.
Bootstrap and regtest running on x86_64-unknown-linux-gnu. PR tree-optimization/121126 * tree-vect-stmts.cc (vect_analyze_stmt): Analyze the live lane extract for LC PHIs that are vect_internal_def. * gcc.dg/vect/pr121126.c: New testcase. --- gcc/testsuite/gcc.dg/vect/pr121126.c | 30 ++++++++++++++++++++++++++++ gcc/tree-vect-stmts.cc | 3 ++- 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/vect/pr121126.c diff --git a/gcc/testsuite/gcc.dg/vect/pr121126.c b/gcc/testsuite/gcc.dg/vect/pr121126.c new file mode 100644 index 00000000000..ae6603bb1e5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr121126.c @@ -0,0 +1,30 @@ +/* { dg-additional-options "--param vect-partial-vector-usage=2" } */ + +#include "tree-vect.h" + +unsigned char a; +unsigned b; +int r[11]; +static void __attribute__((noipa)) +c(int e, unsigned s[][11][11]) +{ + for (int u = -(e ? 2000424973 : 0) - 2294542319; u < 7; u += 4) + for (int x = 0; x < 300000011; x += 4) + for (int y = 0; y < (0 < s[u][4][1]) + 11; y += 3) { + a = a ?: 1; + b = r[2]; + } +} +long long ab; +int e = 1; +unsigned s[11][11][11]; +int main() +{ + check_vect (); + for (int t = 0; t < 11; ++t) + r[t] = 308100; + c(e,s); + ab = b; + if (ab != 308100) + __builtin_abort (); +} diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index f0d31058372..2e9b3d2e686 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -13378,7 +13378,8 @@ vect_analyze_stmt (vec_info *vinfo, need extra handling, except for vectorizable reductions. */ if (!bb_vinfo && STMT_VINFO_TYPE (stmt_info) != reduc_vec_info_type - && STMT_VINFO_TYPE (stmt_info) != lc_phi_info_type + && (STMT_VINFO_TYPE (stmt_info) != lc_phi_info_type + || STMT_VINFO_DEF_TYPE (stmt_info) == vect_internal_def) && (!node->ldst_lanes || SLP_TREE_CODE (node) == VEC_PERM_EXPR) && !can_vectorize_live_stmts (as_a <loop_vec_info> (vinfo), node, node_instance, -- 2.43.0