diff options
author | Chris Lattner <sabre@nondot.org> | 2001-12-04 08:12:47 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-12-04 08:12:47 +0000 |
commit | 54794fe11f99a9d1535211838bd618fe8e3075b8 (patch) | |
tree | 70cdb1f816944c73d6ed1faca23602989e4bc0e2 /llvm/lib/Analysis/InductionVariable.cpp | |
parent | 91daaabb5603f474a8c0c4ad24b136f482be3a96 (diff) | |
download | bcm5719-llvm-54794fe11f99a9d1535211838bd618fe8e3075b8.tar.gz bcm5719-llvm-54794fe11f99a9d1535211838bd618fe8e3075b8.zip |
Fix a pessimization due to sucky LI testing
llvm-svn: 1412
Diffstat (limited to 'llvm/lib/Analysis/InductionVariable.cpp')
-rw-r--r-- | llvm/lib/Analysis/InductionVariable.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/InductionVariable.cpp b/llvm/lib/Analysis/InductionVariable.cpp index 339bc3862ae..a340a771963 100644 --- a/llvm/lib/Analysis/InductionVariable.cpp +++ b/llvm/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)); } } |