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

--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <[email protected]>:

https://gcc.gnu.org/g:adfe96eb612feeb6abb2ecac267325243039a0f8

commit r16-3567-gadfe96eb612feeb6abb2ecac267325243039a0f8
Author: Andrew Pinski <[email protected]>
Date:   Tue Aug 26 22:04:06 2025 -0700

    forwprop: Improve the reject case for copy prop [PR107051]

    Currently the code rejects:
    ```
    tmp = *a;
    *b = tmp;
    ```
    (unless *a == *b). This can be improved such that if a and b are known to
    share the same base, then only reject it if they overlap; that is the
    difference of the offsets (from the base) is maybe less than the size.

    This fixes the testcase in comment #0 of PR 107051.

    Changes since v1:
    * v2: Use ranges_maybe_overlap_p instead of manually checking the overlap.
          Allow for the case where the alignment is known to be greater than
          the size.

            PR tree-optimization/107051

    gcc/ChangeLog:

            * tree-ssa-forwprop.cc (optimize_agr_copyprop_1): Allow for
            memory sharing the same base if they known not to overlap over
            the size.

    gcc/testsuite/ChangeLog:

            * gcc.dg/tree-ssa/copy-prop-aggregate-union-1.c: New test.

    Signed-off-by: Andrew Pinski <[email protected]>

Reply via email to