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

--- Comment #3 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:597b50abb0d2fc1f123a99e1b4beb89ad6259d9e

commit r16-3887-g597b50abb0d2fc1f123a99e1b4beb89ad6259d9e
Author: Andrew Pinski <[email protected]>
Date:   Sat Sep 6 21:49:18 2025 -0700

    forwprop: Handle memcpy for copy prop [PR121418, PR121417]

    It turns out easy to add support for memcpy copy prop when the memcpy
    has changed into `MEM<char[N]>` copy.
    Instead of rejecting right out we need to figure out that
    `a` and `MEM<char[N]>[&a]` are equivalent in terms of address and size.
    And then create a VIEW_CONVER_EXPR from the original src to the new type.

    Note this also allows for `a.b` and `a` being considered equivalent if b is
the
    only field (PR 121751).

    Changes since v1:
    * v2: Move check for IMAG/REAL and BFR earlier.
          Add a wrapping function around get_inner_reference and use that
instead
         of get_addr_base_and_unit_offset.

    Bootstrapped and tested on x86_64-linux-gnu.

            PR tree-optimization/121751
            PR tree-optimization/121418
            PR tree-optimization/121417
    gcc/ChangeLog:

            * tree-ssa-forwprop.cc (split_core_and_offset_size): New function.
            (optimize_agr_copyprop_1): Allow for the same
            address but different type accesses via a VCE.

    gcc/testsuite/ChangeLog:

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

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

Reply via email to