On Thu, 26 Nov 2020, Jakub Jelinek via Gcc-patches wrote:

For signed integers with undefined overflow we already optimize x * y / y
into x, but for signed integers with -fwrapv or unsigned integers we don't.
The following patch allows optimizing that into just x if value ranges
prove that x * y will never overflow.

I've long wanted a helper that checks if VRP thinks an operation could overflow, I think at some point it would make sense to move this code to some function so that it can be easily reused. Maybe also define a matcher so we can write (mult_noovf @0 @1) which would succeed if either overflow is undefined or if VRP can prove that no overflow is happening.

Of course that's all ideas for later, refactoring belongs in the second or third patch using a feature, not the first one :-)

--
Marc Glisse

Reply via email to