The following fixes bad interaction with mask demotion to data
and the code dealing with UB on signed reductions by making sure
to also update compute_vectype when updating vectype.
PR tree-optimization/122370
* tree-vect-loop.cc (vect_create_epilog_for_reduction):
Also update compute_vectype when demoting masks to an
integer vector.
* gcc.dg/vect/vect-pr122370.c: New testcase.
--- /dev/null
+/* { dg-do compile } */
+/* { dg-additional-options "-mavx512vl -mavx512bw" { target { avx512vl && avx512bw } } } */
+
+bool f(bool splat, bool swizzle_splat,
+ int *elems, int length)
+{
+ int input = elems[0];
+ for (int i = 0; i < length; i++)
+ {
+ if (input != elems[i])
+ {
+ splat = false;
+ swizzle_splat = false;
+ }
+ }
+ return (splat && swizzle_splat);
+}
&& VECT_REDUC_INFO_VECTYPE_FOR_MASK (reduc_info)
&& vectype != VECT_REDUC_INFO_VECTYPE_FOR_MASK (reduc_info))
{
- vectype = VECT_REDUC_INFO_VECTYPE_FOR_MASK (reduc_info);
+ compute_vectype = vectype = VECT_REDUC_INFO_VECTYPE_FOR_MASK (reduc_info);
gimple_seq stmts = NULL;
for (unsigned i = 0; i < reduc_inputs.length (); ++i)
reduc_inputs[i] = gimple_build (&stmts, VEC_COND_EXPR, vectype,