From: Andrew Pinski Date: Sun, 8 Jun 2025 18:12:46 +0000 (-0700) Subject: cselim: Use get_virtual_phi instead of a loop in cond_if_else_store_replacement X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e4d3ffc1992c74abdac9361169a29761bc158f20;p=thirdparty%2Fgcc.git cselim: Use get_virtual_phi instead of a loop in cond_if_else_store_replacement Don't inline finding of the virtual op phi node, instead use get_virtual_phi. This is based on the review of a different patch (https://gcc.gnu.org/pipermail/gcc-patches/2025-June/686076.html). Pushed as obvious after a bootstrap/test on x86_64-linux-gnu. gcc/ChangeLog: * tree-ssa-phiopt.cc (cond_if_else_store_replacement): Use get_virtual_phi instead of inlining it. Signed-off-by: Andrew Pinski --- diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc index 2e4f9dad327..381c048fc3d 100644 --- a/gcc/tree-ssa-phiopt.cc +++ b/gcc/tree-ssa-phiopt.cc @@ -3773,14 +3773,7 @@ cond_if_else_store_replacement (basic_block then_bb, basic_block else_bb, /* Handle the case with single store in THEN_BB and ELSE_BB. That is cheap enough to always handle as it allows us to elide dependence checking. */ - gphi *vphi = NULL; - for (gphi_iterator si = gsi_start_phis (join_bb); !gsi_end_p (si); - gsi_next (&si)) - if (virtual_operand_p (gimple_phi_result (si.phi ()))) - { - vphi = si.phi (); - break; - } + gphi *vphi = get_virtual_phi (join_bb); if (!vphi) return false; tree then_vdef = PHI_ARG_DEF_FROM_EDGE (vphi, single_succ_edge (then_bb));