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

--- Comment #4 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:256fa1df0ed0e4ba955a1ea24b4b2b4a8325efa5

commit r16-4741-g256fa1df0ed0e4ba955a1ea24b4b2b4a8325efa5
Author: Andrew Pinski <[email protected]>
Date:   Tue Oct 28 20:29:45 2025 -0700

    forwprop: Improve simple dse slightly more for eh but multiple incoming
edges (phi) [PR122247]

    In this case we have a phi node for the use so we need to see if
    the result of the phi is a single usage with the clobber.

    That is the following IR:
    ```
      # .MEM_6 = VDEF <.MEM_5(D)>
      inner = outer;
      # .MEM_7 = VDEF <.MEM_6>
      p (outer);

      <bb 3> :
    ...
      # .MEM_8 = VDEF <.MEM_7>
      g (_3, _2, _1);

      <bb 4> :
      # .MEM_9 = VDEF <.MEM_8>
      inner ={v} {CLOBBER(eos)};
    ...

      <bb 5> :
      # .MEM_4 = PHI <.MEM_7(2), .MEM_8(3)>
    <L0>:
      # .MEM_10 = VDEF <.MEM_4>
      inner ={v} {CLOBBER(eos)};
    ```

    The two two clobber can be considered the same.
    So starting at `bb 4`'s. Bofore we walk back to the call of g statement
    and would notice that the use in the phi node of `bb5` and that would cause
    the walk to stop. But in this case since he phi node has a single use of
the
    clobber and the clobber matches the original clobber it can be considered
the
    same "one". So with the patch now, we walk back one more statement and
allow it.
    Similar to the at the call to p statement.

    Bootstrapped and tested on x86_64-linux-gnu.

            PR tree-optimization/122247

    gcc/ChangeLog:

            * tree-ssa-forwprop.cc (do_simple_agr_dse): Allow phi node for the
usage
            if the usage of the phi result is just the "same" as the original
clobber.

    gcc/testsuite/ChangeLog:

            * g++.dg/tree-ssa/copy-prop-aggregate-sra-2.C: New test.

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

Reply via email to