aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-05-20 00:34:08 +0000
committerDan Gohman <gohman@apple.com>2009-05-20 00:34:08 +0000
commit15745212e19496734b6aceee431fe5bb701010cb (patch)
tree25cd0e30047437ef0512bc27f93bdb32e9ab2816 /lib/Transforms
parentff36a835a6fabfad1da001bd33e04bac9859c61c (diff)
downloadexternal_llvm-15745212e19496734b6aceee431fe5bb701010cb.zip
external_llvm-15745212e19496734b6aceee431fe5bb701010cb.tar.gz
external_llvm-15745212e19496734b6aceee431fe5bb701010cb.tar.bz2
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72149 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/LoopStrengthReduce.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index 3a71d27..adfa527 100644
--- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/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.