]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Make simple_dce_from_worklist remove unused call LHSs
authorRichard Biener <rguenther@suse.de>
Thu, 13 Nov 2025 10:20:31 +0000 (11:20 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 13 Nov 2025 12:08:42 +0000 (13:08 +0100)
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.

gcc/tree-ssa-dce.cc

index 160c28cb807e49f1280b6164f81c505ef298d8c4..53bbd7584fd80f90c1af93aca03c1bf5c67ab971 100644 (file)
@@ -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