On 6/12/2026 9:37 PM, Andrew Pinski wrote: > This is in preparation for adding factoring out loads > for phiopt were we want to loop over all 3 factoring > cases if one of them made a change so that a load elimination > might allow for a store elimination. > > This moves the cs-elim limited loop into the factoring out > operation into the same loop. > > Bootstrapped and tested on x86_64-linux-gnu. > > gcc/ChangeLog: > > * tree-ssa-phiopt.cc (factor_out_all): New function. > (pass_phiopt::execute): Call factor_out_all isntead > of factor_out_conditional_operation and > cond_if_else_store_replacement_limited. s/isntead/instead/
OK with the ChangeLog and one formatting nit below fixed. > > Signed-off-by: Andrew Pinski <[email protected]> > --- > gcc/tree-ssa-phiopt.cc | 75 ++++++++++++++++++++++++++---------------- > 1 file changed, 47 insertions(+), 28 deletions(-) > > diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc > index 82e67dc15d7..e926aa8200d 100644 > --- a/gcc/tree-ssa-phiopt.cc > +++ b/gcc/tree-ssa-phiopt.cc > @@ -3649,6 +3649,47 @@ cond_if_else_store_replacement (basic_block then_bb, > basic_block else_bb, > return ok; > } > > +/* Factor out operations and stores from the phi of the MERGE block coming > + in from the edges E1 and E2 if possible. COND_STMT is the conditional > + statement of the origin block. DIAMOND_P says that both E1 and E2 src > + are not the origin block but rather 2 middle BBs. EARLY_P is true if > + this was the early phi-opt. > + Returns true if a factoring happened. */ > +static bool > +factor_out_all (edge e1, edge e2, basic_block merge, > + gcond *cond_stmt, bool diamond_p, bool early_p) > +{ > + bool changed = false; > + bool do_over; > + basic_block bb1 = e1->src; > + basic_block bb2 = e2->src; > + do > + { > + do_over = false; > + if (diamond_p && get_virtual_phi (merge)) > + { > + if (cond_if_else_store_replacement_limited (bb1, bb2, merge)) > + { > + changed = true; > + do_over = true; > + continue; > + } Formatting nit. Guessing the close brace, probably a spaces vs tab issue.
