diff options
| author | Dan Gohman <gohman@apple.com> | 2009-05-20 00:34:08 +0000 |
|---|---|---|
| committer | Dan Gohman <gohman@apple.com> | 2009-05-20 00:34:08 +0000 |
| commit | 7248923a5da4244e426b74205402df78b607ea54 (patch) | |
| tree | 7d6aa237fb69c28bc01b6d6238d7c53858ab9f17 /llvm/lib/Transforms | |
| parent | 414dc16ab9c4184a0c924ae84aec087ba69d18f2 (diff) | |
| download | bcm5719-llvm-7248923a5da4244e426b74205402df78b607ea54.tar.gz bcm5719-llvm-7248923a5da4244e426b74205402df78b607ea54.zip | |
Suppress the IV reversal transformation in the case that the RHS
of the comparison is defined inside the loop. This fixes a
use-before-def problem, because the transformation puts a use
of the RHS outside the loop.
llvm-svn: 72149
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 3a71d279772..adfa5272a9c 100644 --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -2456,6 +2456,11 @@ void LoopStrengthReduce::OptimizeLoopCountIV(Loop *L) { SCEVHandle One = SE->getIntegerSCEV(1, BackedgeTakenCount->getType()); if (!AR || !AR->isAffine() || AR->getStepRecurrence(*SE) != One) return; + // If the RHS of the comparison is defined inside the loop, the rewrite + // cannot be done. + if (Instruction *CR = dyn_cast<Instruction>(Cond->getOperand(1))) + if (L->contains(CR->getParent())) + return; // Make sure the IV is only used for counting. Value may be preinc or // postinc; 2 uses in either case. |

