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>