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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #2)
> looking into this slightly more, there needs to have a check on
> INTEGER_CST@1 if less than the size of the array if o is an array.
> (otherwise only allow 1).

Yeah, we don't necessarily want to bring back "optimistic" back-conversion to
pointer arithmetic from integer one.

I'd instead have approached this one from re-association as well where
for both signed integer and pointer add/sub chains we can perform
elimination if we then rewrite the result to a no-overflow variant.

Your pattern would only solve the issue for address of decl bases.  You
also have to be careful to make sure the decl binds locally given
a DSO override might cause the arithmetic to spill over to another decl
and integer arithmetic for that would have been valid!

Reply via email to