The following teaches simple_dce_from_worklist to remove the LHS
from calls like DCE does.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

        * tree-ssa-dce.cc (simple_dce_from_worklist): For calls
        with side-effects remove their LHS.
---
 gcc/tree-ssa-dce.cc | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/gcc/tree-ssa-dce.cc b/gcc/tree-ssa-dce.cc
index 160c28cb807..53bbd7584fd 100644
--- a/gcc/tree-ssa-dce.cc
+++ b/gcc/tree-ssa-dce.cc
@@ -2399,7 +2399,15 @@ simple_dce_from_worklist (bitmap worklist, bitmap 
need_eh_cleanup)
 
       gimple *t = SSA_NAME_DEF_STMT (def);
       if (gimple_has_side_effects (t))
-       continue;
+       {
+         if (gcall *call = dyn_cast <gcall *> (t))
+           {
+             gimple_call_set_lhs (call, NULL_TREE);
+             update_stmt (call);
+             release_ssa_name (def);
+           }
+         continue;
+       }
 
       /* The defining statement needs to be defining only this name.
         ASM is the only statement that can define more than one
-- 
2.51.0

Reply via email to