On Mon, Nov 16, 2020 at 10:57 AM Philipp Tomsich <philipp.toms...@vrull.eu> wrote:
> 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. > This has the risk of breaking some user code. I've seen people write code for RISC-V knowing that the hardware truncates shift counts, and so not doing the full calculation to get the right value but just letting the compiler/hardware calculate it for them via truncation. Of course this code has implemented defined result, but there is no reason to break it unnecessarily. Jim