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

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 27 13:53:35 PDT 2021


nikic accepted this revision.
nikic added a comment.
This revision is now accepted and ready to land.

LGTM



================
Comment at: llvm/lib/Transforms/Scalar/LoopDeletion.cpp:399
+    auto *BTC = SE.getBackedgeTakenCount(L);
+    if (!BTC->isZero()) {
+      if (!isa<SCEVCouldNotCompute>(BTC) && SE.isKnownNonZero(BTC))
----------------
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.)


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