[PATCH] D92367: [SCEV] Fix incorrect exit count calculated in error scope

Mindong Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 1 00:40:01 PST 2020


mdchen created this revision.
mdchen added reviewers: nikic, lebedev.ri, fhahn.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
mdchen requested review of this revision.

In computeLoadConstantCompareExitLimit, the specified loop of the
addrec, which is used to compute the exit count, should contain the
loop which the exiting block belongs to.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92367

Files:
  llvm/lib/Analysis/ScalarEvolution.cpp


Index: llvm/lib/Analysis/ScalarEvolution.cpp
===================================================================
--- llvm/lib/Analysis/ScalarEvolution.cpp
+++ llvm/lib/Analysis/ScalarEvolution.cpp
@@ -7822,9 +7822,10 @@
   Idx = getSCEVAtScope(Idx, L);
 
   // We can only recognize very limited forms of loop index expressions, in
-  // particular, only affine AddRec's like {C1,+,C2}.
+  // particular, only affine AddRec's like {C1,+,C2}<L2> where L is inside L2.
   const SCEVAddRecExpr *IdxExpr = dyn_cast<SCEVAddRecExpr>(Idx);
-  if (!IdxExpr || !IdxExpr->isAffine() || isLoopInvariant(IdxExpr, L) ||
+  if (!IdxExpr || !IdxExpr->getLoop()->contains(L) || !IdxExpr->isAffine() ||
+      isLoopInvariant(IdxExpr, L) ||
       !isa<SCEVConstant>(IdxExpr->getOperand(0)) ||
       !isa<SCEVConstant>(IdxExpr->getOperand(1)))
     return getCouldNotCompute();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92367.308562.patch
Type: text/x-patch
Size: 862 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201201/c3eb03dd/attachment.bin>


More information about the llvm-commits mailing list