[PATCH] D44676: [SCEV] Make exact taken count calculation more optimistic

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 23 03:14:25 PDT 2018


fhahn added inline comments.


================
Comment at: lib/Analysis/ScalarEvolution.cpp:6673
+  // All exits we have collected must dominate the only latch.
+  if (!Latch)
+    return SE->getCouldNotCompute();
----------------
mkazantsev wrote:
> mkazantsev wrote:
> > fhahn wrote:
> > > Another thing to double check. Are you sure we only compute exit counts when we have a single loop latch that dominates all exiting nodes? I had a quick look but could not find the place where we ensure that (computeBackedgeTakenCount states that the loop latch may be null). In that case we might miss a case when all exit counts are equal.
> > > 
> > The latch should be dominated by all exiting blocks, yes. It follows from current implementation of computeBackedgeTakenCount . It currently has *very* strict limitations that in practice say that the exit should actually be the latch (its successors being the loop's header and its chain of single predecessors also leads to header), so this requirement exists but implicit. If you look at https://reviews.llvm.org/D44677, here I tried to explain that the current requirement set is actually noting but a small subset of all situations when all exits dominate the latch. And in this patch, this requirement replaces all odd logic and becomes explicit.
> Besides, single latch is a canonical form, and any multiple-latch loop can be easily converted to it (and LLVM does it).
Right , thanks for making this clearer and more explicit in this patch and D44677 :)


https://reviews.llvm.org/D44676





More information about the llvm-commits mailing list