[PATCH] D109762: [NewPM][SimpleLoopUnswitch] Add DivergenceInfo

Brendon Cahoon via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 16 09:59:40 PDT 2021


bcahoon added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp:2803
+    Function *F = L.getHeader()->getParent();
+    PostDominatorTree PDT(*F);
+    DivergenceInfo DI(*F, DT, PDT, LI, TTI, /*KnownReducible*/ true);
----------------
aeubanks wrote:
> bcahoon wrote:
> > arsenm wrote:
> > > Constructing your own PostDominatorTree seems not good. Should this be a pass dependency for divergent targets?
> > I agree that it's not good, but I believe the only way to do this as a dependency/required is to have all the loop passes update the post-dominator tree info when needed (which is what's done for dominators and several other loop analyses).
> See the loop analyses part of https://llvm.org/docs/NewPassManager.html#using-analyses for limitations on accessing function analyses in a loop pass.
Thanks for that reference.  If I understand correctly, another approach to adding divergence analysis would be to add an entry to LoopStandardAnalysisResults for DivergenceAnalysisInfo (but, at least initially, without the guarantee that loop passes update it).  That way it can be accessed by SimpleLoopUnswtich.

Then, in PassBuilder.cpp add an instance of the DivergeranceAnalysis prior to SimpleLoopUnswitch. This also requires a call to createFunctionToLoopPassAdaptor between DivergenceAnalysis and SimpleLoopUnswitch.  We could do this only for targets that have branch divergence so that the pass pipeline remains the same for other targets.

This approach seems most similar to how the legacy pass manager works. My main hesitation is adding DivergenceAnalysis to LoopStandardAnalysisResults.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109762/new/

https://reviews.llvm.org/D109762



More information about the llvm-commits mailing list