[PATCH] D116499: [SCEV] Compute exit count from overflow check expressed w/ x.with.overflow intrinsics

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 3 08:50:23 PST 2022


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

LG with some nits



================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:8101
+    if (EVI->getNumIndices() == 1 && EVI->getIndices()[0] == 1)
+      if (auto *WO = dyn_cast<WithOverflowInst>(EVI->getAggregateOperand())) {
+        const APInt *C;
----------------
I'd write these three conditions as `match(ExitCond, m_ExtractValue<1>(m_WithOverflowInst(WO))`.


================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:8111
+          if (!ExitIfTrue)
+            Pred = ICmpInst::getInversePredicate(Pred);
+          auto *LHS = getSCEV(WO->getLHS());
----------------
I didn't spot where this case is tested. Can you please add one where the successors are swapped? I see some tests using `xor -1`, but that doesn't appear to be supported by SCEV right now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116499



More information about the llvm-commits mailing list