]> granicus.if.org Git - llvm/commitdiff
[LoopUnrollRuntime] Use SCEV exit count for calculating trip count. NFCI
authorAnna Thomas <anna@azul.com>
Tue, 27 Jun 2017 14:14:35 +0000 (14:14 +0000)
committerAnna Thomas <anna@azul.com>
Tue, 27 Jun 2017 14:14:35 +0000 (14:14 +0000)
Instead of getBackEdgeTakenCount, use getExitCount on the latch exiting block
(which is proven to be the only exiting block in the loop to be unrolled).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306410 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/LoopUnrollRuntime.cpp

index 5f85e17927fa2d77f9430ec4ff89ed483113c0a9..d91583136c63ce0171406d157bdfd78c5d95227c 100644 (file)
@@ -495,7 +495,11 @@ bool llvm::UnrollRuntimeLoopRemainder(Loop *L, unsigned Count,
 
   // Only unroll loops with a computable trip count, and the trip count needs
   // to be an int value (allowing a pointer type is a TODO item).
-  const SCEV *BECountSC = SE->getBackedgeTakenCount(L);
+  // We calculate the backedge count by using getExitCount on the Latch block,
+  // which is proven to be the only exiting block in this loop. This is same as
+  // calculating getBackedgeTakenCount on the loop (which computes SCEV for all
+  // exiting blocks).
+  const SCEV *BECountSC = SE->getExitCount(L, Latch);
   if (isa<SCEVCouldNotCompute>(BECountSC) ||
       !BECountSC->getType()->isIntegerTy())
     return false;