On Mon, Oct 19, 2020 at 12:36:24PM +0200, Aldy Hernandez via Gcc-patches wrote: > The test is trying to shift by 129, but the underlying type is 128 bits. > This causes low_bits to wrap around to -1 and things go bad really > quick. > > Attached is my proposed solution. > > Andrew, do you have a preference on how to fix this?
Shifts are undefined already when the shift count is equal to the precision. And arbitrarily choosing one of the values as the shift count seems risky to me (and even when used, the most natural would be truncating the excess bits rather than saturating), can't it just punt (return VARYING) for the UB shifts? > > gcc/ChangeLog: > > PR tree-optimization/97488 > * range-op.cc (operator_lshift::op1_range): Handle large right shifts. > > gcc/testsuite/ChangeLog: > > * gcc.dg/pr97488.c: New test. Jakub