https://gcc.gnu.org/g:c9108d4dccb4b91e2ee4b8968891abe8ad7958a1

commit r16-5214-gc9108d4dccb4b91e2ee4b8968891abe8ad7958a1
Author: Richard Biener <[email protected]>
Date:   Thu Nov 13 11:20:31 2025 +0100

    Make simple_dce_from_worklist remove unused call LHSs
    
    The following teaches simple_dce_from_worklist to remove the LHS
    from calls like DCE does.
    
            * tree-ssa-dce.cc (simple_dce_from_worklist): For calls
            with side-effects remove their LHS.

Diff:
---
 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 160c28cb807e..53bbd7584fd8 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

Reply via email to