[PATCH] D108833: [LoopDeletion] Use max trip count to break backedge in addition to exact one

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 27 14:17:41 PDT 2021


reames added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/LoopDeletion.cpp:399
+    auto *BTC = SE.getBackedgeTakenCount(L);
+    if (!BTC->isZero()) {
+      if (!isa<SCEVCouldNotCompute>(BTC) && SE.isKnownNonZero(BTC))
----------------
nikic wrote:
> I find this extra BTC->isZero() check a bit confusing -- unless I'm missing something, the check against getConstantMaxBackedgeTakenCount() should be strictly more powerful, right? For the exact count to return zero all exits must have a constant BECount of zero, so the constant max BE count must also be zero.
> 
> (We might also want to drop the isKnownNonZero optimization, as IIRC it had no real impact in practice, but that's a different matter.)
You're correct - in theory.  I'm very hesitant to introduce an assumption of max=0 ==> exact=0 though as I don't see that properly asserted anywhere in the existing code.   We could today compute somewhere in the TC logic a zero max with a non-zero exact, and nothing would care.  


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108833



More information about the llvm-commits mailing list