aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-04-17 18:44:09 +0000
committerChris Lattner <sabre@nondot.org>2004-04-17 18:44:09 +0000
commit20aa098ba694aa7e3f5fb5a52d22dba7c1e857ae (patch)
tree272b6d4ab1ba3ddafcf0f5c76e9d600d197d1f4b /lib
parent7980fb9007b7e13446053daa6a5110aeeb7016dd (diff)
downloadexternal_llvm-20aa098ba694aa7e3f5fb5a52d22dba7c1e857ae.zip
external_llvm-20aa098ba694aa7e3f5fb5a52d22dba7c1e857ae.tar.gz
external_llvm-20aa098ba694aa7e3f5fb5a52d22dba7c1e857ae.tar.bz2
If the loop executes a constant number of times, try a bit harder to replace
exit values. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13018 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Scalar/IndVarSimplify.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp
index fa81f81..d5eb668 100644
--- a/lib/Transforms/Scalar/IndVarSimplify.cpp
+++ b/lib/Transforms/Scalar/IndVarSimplify.cpp
@@ -276,6 +276,8 @@ void IndVarSimplify::RewriteLoopExitValues(Loop *L) {
BasicBlock::iterator InsertPt = BlockToInsertInto->begin();
while (isa<PHINode>(InsertPt)) ++InsertPt;
+ bool HasConstantItCount = isa<SCEVConstant>(SE->getIterationCount(L));
+
std::set<Instruction*> InstructionsToDelete;
for (unsigned i = 0, e = L->getBlocks().size(); i != e; ++i)
@@ -284,7 +286,8 @@ void IndVarSimplify::RewriteLoopExitValues(Loop *L) {
for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I)
if (I->getType()->isInteger()) { // Is an integer instruction
SCEVHandle SH = SE->getSCEV(I);
- if (SH->hasComputableLoopEvolution(L)) { // Varies predictably
+ if (SH->hasComputableLoopEvolution(L) || // Varies predictably
+ HasConstantItCount) {
// Find out if this predictably varying value is actually used
// outside of the loop. "extra" as opposed to "intra".
std::vector<User*> ExtraLoopUsers;
@@ -296,7 +299,7 @@ void IndVarSimplify::RewriteLoopExitValues(Loop *L) {
// Okay, this instruction has a user outside of the current loop
// and varies predictably in this loop. Evaluate the value it
// contains when the loop exits, and insert code for it.
- SCEVHandle ExitValue = SE->getSCEVAtScope(I,L->getParentLoop());
+ SCEVHandle ExitValue = SE->getSCEVAtScope(I, L->getParentLoop());
if (!isa<SCEVCouldNotCompute>(ExitValue)) {
Changed = true;
++NumReplaced;