summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuiling Song <ruiling.song@intel.com>2015-02-12 15:02:58 +0800
committerZhigang Gong <zhigang.gong@intel.com>2015-02-12 14:48:11 +0800
commit957b20b4130a7611b637436dcec5c8e15f21dccf (patch)
treea3dc140dae93b732328cc9b32e48a88c337d96a4
parent956c3dddaa9551ea0ed29a75badd6fa3e50bcfea (diff)
GBE: We need use exiting block here.
According to the API explanation, we should use exiting block instead of latch block. llvm 3.6 place an assert on this. v2: Use latch block if it is the exiting block, else use exiting block. Signed-off-by: Ruiling Song <ruiling.song@intel.com> Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
-rw-r--r--backend/src/llvm/llvm_unroll.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/backend/src/llvm/llvm_unroll.cpp b/backend/src/llvm/llvm_unroll.cpp
index 7cd7c355..172e724c 100644
--- a/backend/src/llvm/llvm_unroll.cpp
+++ b/backend/src/llvm/llvm_unroll.cpp
@@ -163,19 +163,25 @@ namespace gbe {
bool handleParentLoops(Loop *L, LPPassManager &LPM) {
Loop *currL = L;
ScalarEvolution *SE = &getAnalysis<ScalarEvolution>();
- BasicBlock *latchBlock = currL->getLoopLatch();
+ BasicBlock *ExitBlock = currL->getLoopLatch();
+ if (!ExitBlock || !L->isLoopExiting(ExitBlock))
+ ExitBlock = currL->getExitingBlock();
+
unsigned currTripCount = 0;
bool shouldUnroll = true;
- if (latchBlock)
- currTripCount = SE->getSmallConstantTripCount(L, latchBlock);
+ if (ExitBlock)
+ currTripCount = SE->getSmallConstantTripCount(L, ExitBlock);
while(currL) {
Loop *parentL = currL->getParentLoop();
unsigned parentTripCount = 0;
if (parentL) {
- BasicBlock *parentLatchBlock = parentL->getLoopLatch();
- if (parentLatchBlock)
- parentTripCount = SE->getSmallConstantTripCount(parentL, parentLatchBlock);
+ BasicBlock *parentExitBlock = parentL->getLoopLatch();
+ if (!parentExitBlock || !parentL->isLoopExiting(parentExitBlock))
+ parentExitBlock = parentL->getExitingBlock();
+
+ if (parentExitBlock)
+ parentTripCount = SE->getSmallConstantTripCount(parentL, parentExitBlock);
}
if ((parentTripCount != 0 && currTripCount / parentTripCount > 16) ||
(currTripCount > 32)) {