aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ScalarEvolution.cpp
diff options
context:
space:
mode:
authorSanjoy Das <sanjoy@playingwithpointers.com>2016-06-30 02:47:28 +0000
committerSanjoy Das <sanjoy@playingwithpointers.com>2016-06-30 02:47:28 +0000
commit0da2d147668532ce9266b03a29c078359d267f61 (patch)
tree32fcbd3afba58fcc4dbc09bd34bbcbe288ba2f9c /llvm/lib/Analysis/ScalarEvolution.cpp
parent758032726d8e4ed1005c26ef61abde406df124af (diff)
downloadllvm-0da2d147668532ce9266b03a29c078359d267f61.zip
llvm-0da2d147668532ce9266b03a29c078359d267f61.tar.gz
llvm-0da2d147668532ce9266b03a29c078359d267f61.tar.bz2
[SCEV] Compute max be count from shift operator only if all else fails
In particular, check to see if we can compute a precise trip count by exhaustively simulating the loop first. llvm-svn: 274199
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp')
-rw-r--r--llvm/lib/Analysis/ScalarEvolution.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 40274f7..e28587e 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -5948,11 +5948,6 @@ ScalarEvolution::computeExitLimitFromICmp(const Loop *L,
return ItCnt;
}
- ExitLimit ShiftEL = computeShiftCompareExitLimit(
- ExitCond->getOperand(0), ExitCond->getOperand(1), L, Cond);
- if (ShiftEL.hasAnyInfo())
- return ShiftEL;
-
const SCEV *LHS = getSCEV(ExitCond->getOperand(0));
const SCEV *RHS = getSCEV(ExitCond->getOperand(1));
@@ -6018,7 +6013,15 @@ ScalarEvolution::computeExitLimitFromICmp(const Loop *L,
default:
break;
}
- return computeExitCountExhaustively(L, ExitCond, !L->contains(TBB));
+
+ auto *ExhaustiveCount =
+ computeExitCountExhaustively(L, ExitCond, !L->contains(TBB));
+
+ if (!isa<SCEVCouldNotCompute>(ExhaustiveCount))
+ return ExhaustiveCount;
+
+ return computeShiftCompareExitLimit(ExitCond->getOperand(0),
+ ExitCond->getOperand(1), L, Cond);
}
ScalarEvolution::ExitLimit