On Tue, Nov 26, 2019 at 09:07:11AM +0100, Richard Biener wrote:
> OK.
>
> It just occured to me - what if we'd use the type of the non-constant
> argument for creating the adjusted constant? Wouldn't that avoid
> the issue as well?
No, the type type of the non-constant argument is NULLPTR_TYPE too.
I guess we could have some VRP optimization that range of NULLPTR_TYPE is
[0, 0], but I think we don't really perform VRP on
non-INTEGRAL/POINTER_TYPE_P, still, phiopt couldn't rely on that.
What could work is checking the PHI args earlier if at least one of them
matches the non-constant one, but I think that would break the
if (a <= u)
b = MAX (a, d);
x = PHI <b, u>
opt. In particular, on this exact testcase the EQ/NE transformation to
non-equality comparison is useless, as it will not really match. But say
with pointers it could hit even if it is not useless.
Jakub