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

--- Comment #13 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rgue...@gcc.gnu.org>:

https://gcc.gnu.org/g:560a3e35fe01c499bd5b1e95ddc4c3e958cf5abd

commit r14-785-g560a3e35fe01c499bd5b1e95ddc4c3e958cf5abd
Author: Richard Biener <rguent...@suse.de>
Date:   Thu May 11 14:28:11 2023 +0200

    tree-optimization/109791 - simplify (unsigned)&foo - (unsigned)(&foo + o)

    The following adds another variant of address difference simplification.
    The utility ptr_difference_const only handles constant differences
    (we also cannot code generate anything else), so exposing a possible
    POINTER_PLUS_EXPR in the match and computing the difference on the
    base only makes it possible to handle one case of a variable offset.
    This simplifies

    (unsigned long) &MEM <char[3]> [(void *)&str + 2B] - (unsigned long) (&str
+ (_69 + 1))

    down to (1 - (unsigned long) _69) during niter analysis, allowing
    ranger to eliminate a condition later and avoiding a bogus
    -Wstringop-overflow diagnostic for the testcase in the PR.

            PR tree-optimization/109791
            * match.pd (minus (convert ADDR_EXPR@0) (convert (pointer_plus @1
@2))):
            New pattern.
            (minus (convert (pointer_plus @1 @2)) (convert ADDR_EXPR@0)):
            Likewise.

Reply via email to