The reduction guard isn't correct, STMT_VINFO_REDUC_DEF also exists
for nested cycles not part of reductions but there's no reduction
info for them.
PR tree-optimization/121754
* tree-vectorizer.h (vect_reduc_type): Simplify to not ICE
on nested cycles.
* gcc.dg/vect/pr121754.c: New testcase.
* gcc.target/aarch64/vect-pr121754.c: Likewise.
--- /dev/null
+/* { dg-do compile } */
+
+float a;
+void
+fn1 (int b)
+{
+ for (; b < 10; b++)
+ {
+ a = 01.;
+ for (int c = 0; c < 2000; c++)
+ a *= 0.99;
+ }
+}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-vectorize -mcpu=neoverse-v2" } */
+
+float a;
+void
+fn1 (int b)
+{
+ for (; b < 10; b++)
+ {
+ a = 01.;
+ for (int c = 0; c < 2000; c++)
+ a *= 0.99;
+ }
+}
{
if (loop_vec_info loop_vinfo = dyn_cast<loop_vec_info> (vinfo))
{
- stmt_vec_info stmt_info = SLP_TREE_REPRESENTATIVE (node);
- if (STMT_VINFO_REDUC_DEF (stmt_info))
- {
- vect_reduc_info reduc_info
- = info_for_reduction (loop_vinfo, node);
- return int (VECT_REDUC_INFO_TYPE (reduc_info));
- }
+ vect_reduc_info reduc_info = info_for_reduction (loop_vinfo, node);
+ if (reduc_info)
+ return int (VECT_REDUC_INFO_TYPE (reduc_info));
}
return -1;
}