diff options
author | Chris Lattner <sabre@nondot.org> | 2011-01-02 20:24:21 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-01-02 20:24:21 +0000 |
commit | 5702a43c094c5b81d3ec9dc81c5a365e8babd33e (patch) | |
tree | 0b0225d6df5a63c313644dc49159d8628356fdb3 /llvm/lib/Transforms | |
parent | 25e6e06e423a14626bf7d650367a07c3c21e08a8 (diff) | |
download | bcm5719-llvm-5702a43c094c5b81d3ec9dc81c5a365e8babd33e.tar.gz bcm5719-llvm-5702a43c094c5b81d3ec9dc81c5a365e8babd33e.zip |
If a loop iterates exactly once (has backedge count = 0) then don't
mess with it. We'd rather peel/unroll it than convert all of its
stores into memsets.
llvm-svn: 122711
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp index 8b022bab83a..57a502b1d25 100644 --- a/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp +++ b/llvm/lib/Transforms/Scalar/LoopIdiomRecognize.cpp @@ -159,6 +159,12 @@ bool LoopIdiomRecognize::runOnLoop(Loop *L, LPPassManager &LPM) { const SCEV *BECount = SE->getBackedgeTakenCount(L); if (isa<SCEVCouldNotCompute>(BECount)) return false; + // If this loop executes exactly one time, then it should be peeled, not + // optimized by this pass. + if (const SCEVConstant *BECst = dyn_cast<SCEVConstant>(BECount)) + if (BECst->getValue()->getValue() == 0) + return false; + // We require target data for now. TD = getAnalysisIfAvailable<TargetData>(); if (TD == 0) return false; |