https://gcc.gnu.org/g:d47f2b280cb4aaf4368d79bd52d03c1056b536a9
commit r17-5578-gd47f2b280cb4aaf4368d79bd52d03c1056b536a9 Author: Richard Biener <[email protected]> Date: Mon Oct 26 12:56:53 2026 +0100 tree-optimization/128132 - induction SLP with different induction kinds The following is a minimal fix for PR128132 without addressing the SLP discovery issue that we fail to distinguish the effectively different def types in vect_get_and_check_slp_defs. PR tree-optimization/128132 * tree-vect-loop.cc (vectorizable_induction): Reject SLP groups with different induction subtype. * gcc.dg/vect/vect-pr128132.c: New testcase. Diff: --- gcc/testsuite/gcc.dg/vect/vect-pr128132.c | 23 +++++++++++++++++++++++ gcc/tree-vect-loop.cc | 8 ++++++++ 2 files changed, 31 insertions(+) diff --git a/gcc/testsuite/gcc.dg/vect/vect-pr128132.c b/gcc/testsuite/gcc.dg/vect/vect-pr128132.c new file mode 100644 index 000000000000..6b05173a2244 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-pr128132.c @@ -0,0 +1,23 @@ +#include "tree-vect.h" + +int __attribute__((noipa)) +f(int j) +{ + int s = 0, k = 1; + for (int i = 0; i < 16; i++) + { + s += j + k; + j += 1; + k *= 2; + } + return s; +} + +int main(void) +{ + check_vect (); + + if (f (0) != 65655) + __builtin_abort (); + return 0; +} diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc index dbb677c44bd5..1f22aeeb03d2 100644 --- a/gcc/tree-vect-loop.cc +++ b/gcc/tree-vect-loop.cc @@ -9679,6 +9679,14 @@ vectorizable_induction (loop_vec_info loop_vinfo, if (STMT_VINFO_DEF_TYPE (stmt_info) != vect_induction_def) return false; + for (auto phi_info : SLP_TREE_SCALAR_STMTS (slp_node)) + if (phi_info) + { + gcc_assert (STMT_VINFO_DEF_TYPE (phi_info) == vect_induction_def); + if (STMT_VINFO_LOOP_PHI_EVOLUTION_TYPE (phi_info) != induction_type) + return false; + } + /* Handle nonlinear induction in a separate place. */ if (induction_type != vect_step_op_add) return vectorizable_nonlinear_induction (loop_vinfo, stmt_info,
