On 11/26/20 3:52 AM, Jakub Jelinek wrote:
Hi!
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.
It uses the global SSA_NAME_RANGE_INFO only, because like mentioned
in another PR we don't currently have a way to tell the ranger from match.pd
the use stmt (and we'd need in that case to tell ranger to only follow
SSA_NAME_DEF_STMTs + SSA_NAME_RANGE_INFO and never go in the other
direction, as following immediate uses seems forbidden in match.pd).
as an FYI, ranger only uses immediate-uses to try to track non-null
pointer references. so
a) if its not a pointer, it'll never follow immediate uses, and
b) we can look at disabling that functionality as needed, or better
yet, replace the non-null pointer processing facility to eventually not
need immediate_uses. I will add that to the worklist.
Andrew