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

--- Comment #6 from Roger Sayle <roger at nextmovesoftware dot com> ---
Created attachment 62550
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=62550&action=edit
proposed patch

The attached patch appears to resolve the problem.  Currently bootstrapping and
regression testing.

Apologies for the noise/confusion in comment #4.  GDB was getting confused (by
agressive inlining?) and failed to report that simplify_shift_const_1 was
returning a modified expression.  The point where things broke is in there:

          /* If we are doing an arithmetic right shift and discarding all but
             the sign bit copies, this is equivalent to doing a shift by the
             bitsize minus one.  Convert it into that shift because it will
             often allow other simplifications.  */

          if (code == ASHIFTRT
              && (count + num_sign_bit_copies (varop, shift_unit_mode)
                  >= GET_MODE_PRECISION (shift_unit_mode)))
            count = GET_MODE_PRECISION (shift_unit_mode) - 1;

where num_sign_bit_copies is returning an inappropriate value due to an
overflow of the last_set_sign_bit_copies field.

Reply via email to