[PATCH] D136233: [SimpleLoopUnswitch] Inject loop-invariant conditions and unswitch them when it's profitable

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 9 21:37:45 PST 2023


mkazantsev added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp:3089-3090
+  DenseMap<Value *, SmallVector<CompareDesc, 4> > CandidatesULT;
+  for (auto *DTN = DT.getNode(Latch); L.contains(DTN->getBlock());
+       DTN = DTN->getIDom()) {
+    ICmpInst::Predicate Pred;
----------------
mkazantsev wrote:
> apilipenko wrote:
> > mkazantsev wrote:
> > > apilipenko wrote:
> > > > Why do you limit the transform to conditions that dominate the latch?
> > > Because I prove implications, and the implication can only be proven from something that must execute before the implied condition.
> > But what you need in fact is dominance between the two branches, not between the branches and the latch.
> > 
> > BTW, do you need to worry about implicit control flow/must execute property here?
> All branches that dominate the latch also dominate each other (if traversed up-down), because they all are in the same path in dom tree (specifically from latch to header).
> BTW, do you need to worry about implicit control flow/must execute property here?

No, all that matters is that we work with branches that all dominate the latch (and therfore must execute if backedge is taken). Implicit control flow such as experimental.guard is not supported (and hopefully we can get rid of it).


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

https://reviews.llvm.org/D136233



More information about the llvm-commits mailing list