Commit 437b3c09 by Richard Stallman

(simplify_shift_const): Inhibit hacks based on

num_sign_bit_copies if shift_mode differs from the mode of varop.

From-SVN: r4994
parent fa1a4543
...@@ -7122,25 +7122,31 @@ simplify_shift_const (x, code, result_mode, varop, count) ...@@ -7122,25 +7122,31 @@ simplify_shift_const (x, code, result_mode, varop, count)
else if (count < 0) else if (count < 0)
abort (); abort ();
/* An arithmetic right shift of a quantity known to be -1 or 0 /* If we have replaced VAROP with something wider
is a no-op. */ (such as, the SUBREG_REG), then this won't work;
if (code == ASHIFTRT num_sign_bit_copies will give the wrong answer in that case. */
&& (num_sign_bit_copies (varop, shift_mode) if (shift_mode == GET_MODE (varop))
== GET_MODE_BITSIZE (shift_mode))) {
{ /* An arithmetic right shift of a quantity known to be -1 or 0
count = 0; is a no-op. */
break; if (code == ASHIFTRT
} && (num_sign_bit_copies (varop, shift_mode)
== GET_MODE_BITSIZE (shift_mode)))
{
count = 0;
break;
}
/* If we are doing an arithmetic right shift and discarding all but /* 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 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 bitsize minus one. Convert it into that shift because it will often
allow other simplifications. */ allow other simplifications. */
if (code == ASHIFTRT if (code == ASHIFTRT
&& (count + num_sign_bit_copies (varop, shift_mode) && (count + num_sign_bit_copies (varop, shift_mode)
>= GET_MODE_BITSIZE (shift_mode))) >= GET_MODE_BITSIZE (shift_mode)))
count = GET_MODE_BITSIZE (shift_mode) - 1; count = GET_MODE_BITSIZE (shift_mode) - 1;
}
/* We simplify the tests below and elsewhere by converting /* We simplify the tests below and elsewhere by converting
ASHIFTRT to LSHIFTRT if we know the sign bit is clear. ASHIFTRT to LSHIFTRT if we know the sign bit is clear.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment