https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78655

--- Comment #12 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Jeffrey A. Law from comment #11)
> We can assume that the result of a POINTER_PLUS is non-null if either
> argument is non-null.  So X + constant is always non-null.  X + Y would be
> non-null if either X or Y is known to be non-null.
> 
> If we know that X + Y is non-null via some mechanism (for example the result
> was dereferenced), then we know that X and Y are non-null.

Yes, that summarizes it.  Note this only applies when
!targetm.addr_space.zero_address_valid.  There non-null plus a negative offset
may yield null.

Btw, the old VRP did this already, so I wonder whether it isn't already handled
correctly (minus the addr space thing maybe).

Reply via email to