]> git.ipfire.org Git - thirdparty/gcc.git/commit
forwprop: Add call stmt support to simple dse [PR122633]
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Mon, 24 Nov 2025 00:42:57 +0000 (16:42 -0800)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Mon, 24 Nov 2025 17:22:11 +0000 (09:22 -0800)
commit73849aef07bd2954a80fbf1c8543d70db9beae6a
treea742903f1714e8fe8edbbfd4a4e7c314e50a138c
parent94ae11aca04a83ffa5120a05e69fa1b8ca0cee23
forwprop: Add call stmt support to simple dse [PR122633]

This adds the ability to the simple dse to remove the lhs of a
call. It can also remove a call if it was pure/const in some cases.

On trampv3, I found this happened a few times during forwprop2, 3
and 4. The one in 4 was a suprise and even more it caused a removal
of a call which gcc was not able to remove before. This is due to
the nature of DSE/DCE needs to be done iteratively together but
we currently don't do that. So it just happens the late forwprop4's
simple dse is able to remove this call.

I will fix the xfail testcases in a followup, basically there exceptions
can get a mismatch in the CLOBBER which I didn't except before and I was
being super cautious when it comes having them match but in reality
the difference in CLOBBERs don't matter.

Bootstrapped and tested on x86_64-linux-gnu

PR tree-optimization/122633
gcc/ChangeLog:

* tree-ssa-forwprop.cc (do_simple_agr_dse): Remove
lhs of dead store for a call (or the whole call stmt).

gcc/testsuite/ChangeLog:

* g++.dg/tree-ssa/simple-dse-1.C: New test.
* g++.dg/tree-ssa/simple-dse-2.C: New test.
* g++.dg/tree-ssa/simple-dse-3.C: New test.
* g++.dg/tree-ssa/simple-dse-4.C: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
gcc/testsuite/g++.dg/tree-ssa/simple-dse-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/tree-ssa/simple-dse-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/tree-ssa/simple-dse-3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/tree-ssa/simple-dse-4.C [new file with mode: 0644]
gcc/tree-ssa-forwprop.cc