/* See what bits may be nonzero in VAROP. Unlike the general case of
a call to nonzero_bits, here we don't care about bits outside
- MODE. */
+ MODE unless WORD_REGISTER_OPERATIONS is true. */
- nonzero = nonzero_bits (varop, mode) & GET_MODE_MASK (mode);
+ scalar_int_mode tmode = mode;
+ if (WORD_REGISTER_OPERATIONS && GET_MODE_BITSIZE (mode) < BITS_PER_WORD)
+ tmode = word_mode;
+ nonzero = nonzero_bits (varop, tmode) & GET_MODE_MASK (tmode);
/* Turn off all bits in the constant that are known to already be zero.
Thus, if the AND isn't needed at all, we will have CONSTOP == NONZERO_BITS
/* If VAROP is a NEG of something known to be zero or 1 and CONSTOP is
a power of two, we can replace this with an ASHIFT. */
- if (GET_CODE (varop) == NEG && nonzero_bits (XEXP (varop, 0), mode) == 1
+ if (GET_CODE (varop) == NEG && nonzero_bits (XEXP (varop, 0), tmode) == 1
&& (i = exact_log2 (constop)) >= 0)
return simplify_shift_const (NULL_RTX, ASHIFT, mode, XEXP (varop, 0), i);
return op0;
if (HWI_COMPUTABLE_MODE_P (mode))
{
- HOST_WIDE_INT nzop0 = nonzero_bits (trueop0, mode);
+ /* When WORD_REGISTER_OPERATIONS is true, we need to know the
+ nonzero bits in WORD_MODE rather than MODE. */
+ scalar_int_mode tmode = as_a <scalar_int_mode> (mode);
+ if (WORD_REGISTER_OPERATIONS
+ && GET_MODE_BITSIZE (tmode) < BITS_PER_WORD)
+ tmode = word_mode;
+ HOST_WIDE_INT nzop0 = nonzero_bits (trueop0, tmode);
HOST_WIDE_INT nzop1;
if (CONST_INT_P (trueop1))
{
--- /dev/null
+/* PR target/109040 */
+
+typedef unsigned short __attribute__((__vector_size__ (32))) V;
+
+unsigned short a, b, c, d;
+
+void
+foo (V m, unsigned short *ret)
+{
+ V v = 6 > ((V) { 2124, 8 } & m);
+ unsigned short uc = v[0] + a + b + c + d;
+ *ret = uc;
+}
+
+int
+main ()
+{
+ unsigned short x;
+ foo ((V) { 0, 15 }, &x);
+ if (x != (unsigned short) ~0)
+ __builtin_abort ();
+ return 0;
+}
--- /dev/null
+/* PR target/108947 */
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-forward-propagate -Wno-psabi" } */
+
+typedef unsigned short __attribute__((__vector_size__ (2 * sizeof (short)))) V;
+
+__attribute__((__noipa__)) V
+foo (V v)
+{
+ V w = 3 > (v & 3992);
+ return w;
+}
+
+int
+main ()
+{
+ V w = foo ((V) { 0, 9 });
+ if (w[0] != 0xffff || w[1] != 0)
+ __builtin_abort ();
+ return 0;
+}