This fixes expansion of VECTOR_BOOLEAN_TYPE_P VECTOR_CSTs which
when using an integer mode are not always "mask-mode" but may
be using an integer mode when there's no supported vector mode.
The patch makes sure to only go the mask-mode expansion if
the elements do not line up to cover the full integer mode
(when they do and the mode was an actual mask-mode there's
no actual difference in both expansions).
2020-10-22 Richard Biener <rguenther@suse.de>
PR middle-end/97521
* expr.c (expand_expr_real_1): Be more careful when
expanding a VECTOR_BOOLEAN_TYPE_P VECTOR_CSTs.
* gcc.target/i386/pr97521.c: New testcase.
scalar_int_mode int_mode;
if (is_int_mode (mode, &int_mode))
{
- if (VECTOR_BOOLEAN_TYPE_P (TREE_TYPE (exp)))
+ if (VECTOR_BOOLEAN_TYPE_P (TREE_TYPE (exp))
+ && maybe_ne (TYPE_PRECISION (TREE_TYPE (TREE_TYPE (exp)))
+ * TYPE_VECTOR_SUBPARTS (TREE_TYPE (exp)),
+ GET_MODE_PRECISION (int_mode)))
return const_scalar_mask_from_tree (int_mode, exp);
else
{
--- /dev/null
+/* { dg-do run } */
+/* { dg-options "-O -mno-sse2" } */
+
+typedef unsigned char __attribute__ ((__vector_size__ (8))) V;
+typedef unsigned long long __attribute__ ((__vector_size__ (16))) W;
+
+V c;
+W d, e;
+
+V
+foo (W f)
+{
+ W g = (W) { 0, 209 } <7 <= (0 < f);
+ W h = e + g + d;
+ V j = (V) (h[0]) + (V) c;
+ return j;
+}
+
+int
+main (void)
+{
+ V x = foo ((W) { 3 });
+ for (unsigned i = 0; i < sizeof (x); i++)
+ if (x[i] != 0xff)
+ __builtin_abort ();
+ return 0;
+}