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

--- Comment #11 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:7fe86bb107f7f8c40820ce61572204307266618b

commit r16-4369-g7fe86bb107f7f8c40820ce61572204307266618b
Author: Andrew Pinski <[email protected]>
Date:   Wed Sep 10 22:05:26 2025 -0700

    forwprop: Add a simple DSE after a clobber

    After copy propagation for aggregates patches we might end up with
    now:
    ```
    tmp = a;
    b = a; // was b = tmp;
    tmp = {CLOBBER};
    ```
    To help out ESRA, it would be a good idea to remove the `tmp = a` statement
as
    there is no DSE between frowprop and ESRA. copy-prop-aggregate-sra-1.c is
an example
    where the removal of the copy helps ESRA.

    This adds a simple DSE which is only designed to remove the `tmp = a`
statement.
    This shows up a few times in many C++ code including the code from the
javascript
    interpreter in ladybird, and in the "fake" testcase in PR 108653 and in the
aarch64
    specific PR 89967.

    This is disabled for -Og as we don't do dse there either.
    intent_optimize_10.f90 testcase needed to be updated as the constant
    shows up in a debug statement now.

    Changes since v1:
    * v2: Add much more comments in the code instead of just relying on the
commit message.
          Count the maybe_use towards the aliasing lookup limit (increase the
non-full walk limit to 4
            to account for that).
          Use direct comparison instead of operand_equal_p since we are
comparing against a DECL.

    Bootstrapped and tested on x86_64-linux-gnu.

    gcc/ChangeLog:

            * tree-ssa-forwprop.cc (do_simple_agr_dse): New function.
            (pass_forwprop::execute): Call do_simple_agr_dse for clobbers.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/intent_optimize_10.f90: Update so -g won't fail.
            * gcc.dg/tree-ssa/copy-prop-aggregate-sra-1.c: New testcase.

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

Reply via email to