]> git.ipfire.org Git - thirdparty/gcc.git/commit
forwprop: Improve simple dse slightly more for eh but multiple incoming edges (phi...
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Wed, 29 Oct 2025 03:29:45 +0000 (20:29 -0700)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Thu, 30 Oct 2025 15:10:12 +0000 (08:10 -0700)
commit256fa1df0ed0e4ba955a1ea24b4b2b4a8325efa5
tree1da975678de5fa1d85e90705c940a318d05c35b2
parent5558fa14d999c4d67a1efbba5ca1fe6d6f7ab3ae
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 <andrew.pinski@oss.qualcomm.com>
gcc/testsuite/g++.dg/tree-ssa/copy-prop-aggregate-sra-2.C [new file with mode: 0644]
gcc/tree-ssa-forwprop.cc