summaryrefslogtreecommitdiff
path: root/lib/Analysis
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-12-04 08:12:47 +0000
committerChris Lattner <sabre@nondot.org>2001-12-04 08:12:47 +0000
commit621c9920c7343d2a74e2541871a1e56da41781dc (patch)
treeca62d9fab1c522b3ee3ffca35ae7ad5e4a6bfefd /lib/Analysis
parent394437ff7eaccfe1de92fe14d0022ca0addf3e41 (diff)
downloadllvm-621c9920c7343d2a74e2541871a1e56da41781dc.tar.gz
llvm-621c9920c7343d2a74e2541871a1e56da41781dc.tar.bz2
llvm-621c9920c7343d2a74e2541871a1e56da41781dc.tar.xz
Fix a pessimization due to sucky LI testing
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1412 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r--lib/Analysis/InductionVariable.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/Analysis/InductionVariable.cpp b/lib/Analysis/InductionVariable.cpp
index 339bc3862a..a340a77196 100644
--- a/lib/Analysis/InductionVariable.cpp
+++ b/lib/Analysis/InductionVariable.cpp
@@ -130,6 +130,21 @@ InductionVariable::InductionVariable(PHINode *P, cfg::LoopInfo *LoopInfo) {
const Type *ETy = Phi->getType();
if (ETy->isPointerType()) ETy = Type::ULongTy;
Step = (Value*)(StepE.Offset ? StepE.Offset : ConstantInt::get(ETy, 0));
+ } else { // We were able to get a step value, simplify with expr analysis
+ ExprType StepE = analysis::ClassifyExpression(Step);
+ if (StepE.ExprTy == ExprType::Linear && StepE.Offset == 0) {
+ // No offset from variable? Grab the variable
+ Step = StepE.Var;
+ } else if (StepE.ExprTy == ExprType::Constant) {
+ if (StepE.Offset)
+ Step = (Value*)StepE.Offset;
+ else
+ Step = Constant::getNullConstant(Step->getType());
+ }
+
+ const Type *ETy = Phi->getType();
+ if (ETy->isPointerType()) ETy = Type::ULongTy;
+ Step = (Value*)(StepE.Offset ? StepE.Offset : ConstantInt::get(ETy, 0));
}
}