On Fri, 13 Nov 2026 at 15:39, Jeff Law <[email protected]> wrote: > On 11/12/26 8:34 AM, [email protected] wrote: > > From: Kyrylo Tkachov <[email protected]> > > > > simplify_phi_setup calls simplify_phi_propagate for every phi. That > > walks the list of all phi uses of the phi, to propagate the phi's mode > > to the uses and to check for lower-uid users whose optimistic > > assumptions were wrong. The use_infos on that list belong to many > > different phis, so for a phi network with a large number of inputs the > > walk touches each use_info with poor locality. Nearly all of these > > uses are backedge uses whose assumptions turn out to be valid, so the > > walk almost never changes anything other than the use's mode. > > > > Instead, do the set-up checks from the user side. After all phis have > > been set up, visit the inputs of each phi, which are allocated > > contiguously, and apply the checks that simplify_phi_propagate would > > have applied to the phi's backedge inputs. This is done by a new > > function simplify_phi_backedges, which shares the per-user update logic > > with simplify_phi_propagate through simplify_phi_update_user. Write the > > final phi modes to the phi uses in one pass at the end, rather than as a > > side effect of each propagation. > > > > The set of assumptions that is reached is the same, since the worklist > > phase still revisits any phi whose assumptions or mode changed. > > > > The users of RTL-SSA, such as fold-mem-offsets and the AArch64 load/store > > pair fusion pass, spent more than half of their time in > > simplify_phi_propagate when compiling POVRay fnpovfpu.cpp at -O2. On that > > file this patch alone reduces the compile time by 37%. On top of the > > previous patch, which bounds the number of dispatch copies, it removes a > > further 13% at -O2 and 11% at -O3, and cuts the time in each of > > fold-mem-offsets and machine dependent reorg by 44%. Together the two > > patches reduce the compile time of that file by 80% at -O2, and of the whole > > of 511.povray_r by 13%, leaving it within 1% of compiling with > > -fno-duplicate-switch-dispatch. > > > > Bootstrapped and tested on aarch64-none-linux-gnu > > Ok for trunk? > > Thanks, > > Kyrill > > > > Cc: Richard Sandiford <[email protected]> > > > > gcc/ChangeLog: > > > > PR target/128512 > > * rtl-ssa/functions.h (function_info::simplify_phi_setup): Remove > > the worklist parameter. > > (function_info::simplify_phi_update_user) > > (function_info::simplify_phi_backedges): Declare. > > * rtl-ssa/functions.cc (function_info::simplify_phi_setup): Do not > > call simplify_phi_propagate. > > (function_info::simplify_phi_update_user): New function, split out > > from simplify_phi_propagate. > > (function_info::simplify_phi_backedges): New function. > > (function_info::simplify_phi_propagate): Use > > simplify_phi_update_user. Do not update the modes of the uses. > > (function_info::simplify_phis): Call simplify_phi_backedges for > > each phi after the set-up phase. Update the modes of phi uses > > after the propagation phase. > > > > Signed-off-by: Kyrylo Tkachov <[email protected]> > I'll defer to Richard S. on this. If he doesn't chime in over the next > week, then ping and I'll take it.
Thanks. Mind if we park both parts of this series till mid-December? Andrea noted a while back that late RTL-SSA passes were causing slow behaviour for certain cases, which I'd also identified as being caused by running after uplicate_computed_goto. I was working on a patch that changed how the phis were built and (possibly) how they were simplified. There were various alternatives and I never settled on something that I was happy with. I'd like to compare what I was doing with this patch. I can't remember the details now though and I'm away from my main machine for a few weeks. Richard
