emit_cmp_and_jump_insns used GET_MODE (expand_normal (masked_op)) to select the
mask mode. For vector boolean constants that expand to CONST_INT, this produces
VOIDmode and triggers the assert mode != VOID_mode in maybe_legitimize_operand.
Use TYPE_MODE (TREE_TYPE (masked_op)), so the constant can be materialized in
the right mask mode.
gcc/ChangeLog:
PR middle-end/126203
PR middle-end/126221
PR middle-end/126232
* optabs.cc (emit_cmp_and_jump_insns): Take the masked_op mode
from TREE_TYPE (masked_op).
gcc/testsuite/ChangeLog:
PR middle-end/126203
PR middle-end/126221
PR middle-end/126232
* gcc.target/i386/pr126221-1.c: New test.
* gcc.target/i386/pr126221-2.c: Ditto.
* gfortran.dg/pr126221.f90: Ditto.
create_input_operand (&ops[offset + 1], op1c, mode2);
if (masked_op)
{
+ auto mask_mode = TYPE_MODE (TREE_TYPE (masked_op));
rtx mask_op = expand_normal (masked_op);
- auto mask_mode = GET_MODE (mask_op);
create_input_operand (&ops[0], mask_op, mask_mode);
}
else if (len_op)
--- /dev/null
+/* PR middle-end/126221 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=x86-64-v4" } */
+
+int a[5];
+int
+foo (int t)
+{
+ for (int c = 0; c < 5; c++)
+ if (a[c] && c == 0)
+ return 0;
+ return t;
+}
+
--- /dev/null
+/* PR middle-end/126221 */
+/* { dg-do compile { target bitint } } */
+/* { dg-options "-O3 -fvect-cost-model=unlimited --param=vect-partial-vector-usage=2 -mavx10.1" } */
+
+#if __BITINT_MAXWIDTH__ >= 10986
+_BitInt(10986) b;
+char c;
+
+void
+foo (void)
+{
+ int t;
+ if (__builtin_mul_overflow (0xffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffff0000ffffuwb, c, &t))
+ t = 1;
+ b = t;
+}
+
+#endif
--- /dev/null
+! { dg-do compile }
+! { dg-options "-O3" }
+! { dg-additional-options "-mavx10.1 --param=vect-partial-vector-usage=2" { target { i?86-*-* x86_64-*-* } } }
+!
+! PR middle-end/126221
+
+integer A(5,5)
+if (any (A(:,5) /= [9, 9, 9, 9, 5])) STOP
+end