diff options
author | Chris Lattner <sabre@nondot.org> | 2004-04-17 18:44:09 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-04-17 18:44:09 +0000 |
commit | a814080025420fb8f90fa0e4da0e1dfca2c069a3 (patch) | |
tree | a136748dca08f41fe1cd0f88d945860efa081395 /llvm/lib/Transforms | |
parent | 4021d1af5a1108f36456969b6d9aa2199514bc2d (diff) | |
download | bcm5719-llvm-a814080025420fb8f90fa0e4da0e1dfca2c069a3.tar.gz bcm5719-llvm-a814080025420fb8f90fa0e4da0e1dfca2c069a3.zip |
If the loop executes a constant number of times, try a bit harder to replace
exit values.
llvm-svn: 13018
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp index fa81f81f743..d5eb668107d 100644 --- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/llvm/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; |