From: Richard Biener Date: Thu, 13 Nov 2025 10:20:31 +0000 (+0100) Subject: Make simple_dce_from_worklist remove unused call LHSs X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c9108d4dccb4b91e2ee4b8968891abe8ad7958a1;p=thirdparty%2Fgcc.git 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 --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 (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