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

--- Comment #13 from GCC 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:ee30e2586a3142e63daaf301a561984f1d22d38d

commit r15-7665-gee30e2586a3142e63daaf301a561984f1d22d38d
Author: Richard Biener <rguent...@suse.de>
Date:   Fri Feb 21 09:58:04 2025 +0100

    tree-optimization/118954 - avoid UB on ref created by predcom

    When predicitive commoning moves an invariant ref it makes sure to
    not build a MEM_REF with a base that is negatively offsetted from
    an object.  But in trying to preserve some transforms it does not
    consider association of a constant offset with the address computation
    in DR_BASE_ADDRESS leading to exactly this problem again.  This is
    arguably a problem in data-ref analysis producing such an out-of-bound
    DR_BASE_ADDRESS, but this looks quite involved to fix, so the
    following avoids the association in one more case.  This fixes the
    testcase while preserving the desired transform in
    gcc.dg/tree-ssa/predcom-1.c.

            PR tree-optimization/118954
            * tree-predcom.cc (ref_at_iteration): Make sure to not
            associate the constant offset with DR_BASE_ADDRESS when
            that is an offsetted pointer.

            * gcc.dg/torture/pr118954.c: New testcase.

Reply via email to