After fixing PR116142 some code started to trigger an ICE with -O3
-march=znver4. Per Richard Biener who actually made this fix:
"supportable_widening_operation fails at transform time - that's likely
because vectorizable_reduction "puns" defs to internal_def"
so the check should use STMT_VINFO_REDUC_DEF instead of checking if
STMT_VINFO_DEF_TYPE is vect_reduction_def.
gcc/ChangeLog:
PR tree-optimization/116348
* tree-vect-stmts.cc (supportable_widening_operation): Use
STMT_VINFO_REDUC_DEF (x) instead of
STMT_VINFO_DEF_TYPE (x) == vect_reduction_def.
gcc/testsuite/ChangeLog:
PR tree-optimization/116348
* gcc.c-torture/compile/pr116438.c: New test.
Co-authored-by: Richard Biener <rguenther@suse.de>
--- /dev/null
+/* { dg-additional-options "-march=znver4" { target x86_64-*-* i?86-*-* } } */
+
+int *a;
+int b;
+long long c, d;
+void
+e (int f)
+{
+ for (; f; f++)
+ {
+ d += (long long)a[f] * b;
+ c += (long long)a[f] * 3;
+ }
+}
by STMT is only directly used in the reduction statement. */
tree lhs = gimple_assign_lhs (vect_orig_stmt (stmt_info)->stmt);
stmt_vec_info use_stmt_info = loop_info->lookup_single_use (lhs);
- if (use_stmt_info
- && STMT_VINFO_DEF_TYPE (use_stmt_info) == vect_reduction_def)
+ if (use_stmt_info && STMT_VINFO_REDUC_DEF (use_stmt_info))
return true;
}
c1 = VEC_WIDEN_MULT_LO_EXPR;