https://gcc.gnu.org/bugzilla/show_bug.cgi?id=129193

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The bug is in
    case NOT:
      /* (not FOO) is (xor FOO CONST), so if FOO is an LSHIFTRT, we can do the
         same as the XOR case above.  Ensure that the constant we form is not
         wider than the mode of X.  */

      if (GET_CODE (XEXP (x, 0)) == LSHIFTRT
          && CONST_INT_P (XEXP (XEXP (x, 0), 1))
          && INTVAL (XEXP (XEXP (x, 0), 1)) >= 0
          && (INTVAL (XEXP (XEXP (x, 0), 1)) + floor_log2 (mask)
              < GET_MODE_PRECISION (xmode))
          && INTVAL (XEXP (XEXP (x, 0), 1)) < HOST_BITS_PER_WIDE_INT)
        {
          temp = gen_int_mode (mask << INTVAL (XEXP (XEXP (x, 0), 1)), xmode);
          temp = simplify_gen_binary (XOR, xmode, XEXP (XEXP (x, 0), 0), temp);
          x = simplify_gen_binary (LSHIFTRT, xmode,
                                   temp, XEXP (XEXP (x, 0), 1));

          return force_to_mode (x, mode, mask, next_select);
        }
I wonder if that shouldn't be
          && (INTVAL (XEXP (XEXP (x, 0), 1)) + floor_log2 (mask)
              < MIN (GET_MODE_PRECISION (xmode), HOST_BITS_PER_WIDE_INT))
without the last test.
This is when trying to simplify
(set (reg:DI 113)
    (lshiftrt:DI (subreg:DI (not:TI (lshiftrt:TI (reg:TI 106 [ x ])
                    (const_int 27 [0x1b]))) 0)
        (const_int 63 [0x3f])))
Because we care only about a single bit, when processing the NOT in there we
have
mask 0x8000000000000000.  But TImode (xmode) is not HWI_COMPUTABLE_MODE_P, so
when
we try to shift left that mask by 27, we get just 0 and so optimize away the
XOR.

Wonder if similar problem doesn't exist for the IOR/XOR cases.

Reply via email to