diff options
| author | Dan Gohman <gohman@apple.com> | 2010-02-19 18:12:07 +0000 |
|---|---|---|
| committer | Dan Gohman <gohman@apple.com> | 2010-02-19 18:12:07 +0000 |
| commit | 6b1e2a829ddc65ff988e9e35c151b5d91305f959 (patch) | |
| tree | cf1e0b4d224759a0c5c300facc23df0c580048ee /llvm/lib/Analysis | |
| parent | a3e1e99b05ed4f16a4574e0248a5741a1fb93949 (diff) | |
| download | bcm5719-llvm-6b1e2a829ddc65ff988e9e35c151b5d91305f959.tar.gz bcm5719-llvm-6b1e2a829ddc65ff988e9e35c151b5d91305f959.zip | |
Teach ScalarEvolution how to compute a tripcount for a loop with
true or false as its exit condition. These are usually eliminated by
SimplifyCFG, but the may be left around during a pass which wishes
to preserve the CFG.
llvm-svn: 96683
Diffstat (limited to 'llvm/lib/Analysis')
| -rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index c2284a8ab9b..a0700ba4218 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -3703,6 +3703,19 @@ ScalarEvolution::ComputeBackedgeTakenCountFromExitCond(const Loop *L, if (ICmpInst *ExitCondICmp = dyn_cast<ICmpInst>(ExitCond)) return ComputeBackedgeTakenCountFromExitCondICmp(L, ExitCondICmp, TBB, FBB); + // Check for a constant condition. These are normally stripped out by + // SimplifyCFG, but ScalarEvolution may be used by a pass which wishes to + // preserve the CFG and is temporarily leaving constant conditions + // in place. + if (ConstantInt *CI = dyn_cast<ConstantInt>(ExitCond)) { + if (L->contains(FBB) == !CI->getZExtValue()) + // The backedge is always taken. + return getCouldNotCompute(); + else + // The backedge is never taken. + return getIntegerSCEV(0, CI->getType()); + } + // If it's not an integer or pointer comparison then compute it the hard way. return ComputeBackedgeTakenCountExhaustively(L, ExitCond, !L->contains(TBB)); } |

