On Thu, Nov 26, 2020 at 09:21:53AM +0000, Richard Biener wrote:
> Btw, when looking I figured that int_const_binop loses the sign
> of arg2 when folding a signed shift by an unsigned shift amount
> and thus these out-of-bound shifts get interpreted as signed
> by wide_int_binop even though they are not. That said,
>
> case RSHIFT_EXPR:
> if (wi::neg_p (arg2))
> return false;
>
> will, for wide_int, always return true for values with MSB set
> (we implicitely pass SIGNED to the signop operand here). That
> will now yield "inconsistent" behavior for X >> 1000 vs
> X >> -1u for example. The old behavior wasn't really better
> in principle but consistent in the final result. A fix would
> be to pass in an explicit sign of the second argument.
Or return false; even if arg2 is bigger or equal to precision (and we should
have the precision from the precision of arg1).
That would be my preference, but I think we want first the path isolation
changes.
Jakub