On 11/16/20 11:57 AM, Philipp Tomsich wrote: > From: Philipp Tomsich <p...@gnu.org> > > While most shifts wider than the bitwidth of a type will be caught by > other passes, it is possible that these show up for VRP. > Consider the following example: > int func (int a, int b, int c) > { > return (a << ((b && c) - 1)); > } > > This adds simplify_using_ranges::simplify_lshift_using_ranges to > detect and rewrite such cases. If the intersection of meaningful > shift amounts for the underlying type and the value-range computed > for the shift-amount (whether an integer constant or a variable) is > empty, the statement is replaced with the zero-constant of the same > precision as the result. > > gcc/ChangeLog: > > * vr-values.h (simplify_using_ranges): Declare. > * vr-values.c (simplify_lshift_using_ranges): New function. > (simplify): Use simplify_lshift_using_ranges for LSHIFT_EXPR.
Umm, isn't this a shift wider than the bitwidth undefined behavior? We should be generating warnings for that, not trying to further optimize it :-) jeff