summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-01-30 23:52:44 +0000
committerChris Lattner <sabre@nondot.org>2007-01-30 23:52:44 +0000
commit373dee0947957816f01b89a3a4206bbe3b210507 (patch)
tree5303a84021457c180f7ed8fc68478a0cb5ab975c /llvm/lib
parent86e359e5cb1eab5eff7ef93ecd4725dd0af1b454 (diff)
downloadbcm5719-llvm-373dee0947957816f01b89a3a4206bbe3b210507.tar.gz
bcm5719-llvm-373dee0947957816f01b89a3a4206bbe3b210507.zip
The local "ConstantFold" method is now just a watered down version of
ConstantFoldInstOperands. Switch to ConstantFoldInstOperands and remove ConstantFold. llvm-svn: 33683
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Analysis/ScalarEvolution.cpp40
1 files changed, 3 insertions, 37 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index a30eeea4f17..75dabf7cadc 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -1746,41 +1746,6 @@ static bool CanConstantFold(const Instruction *I) {
return false;
}
-/// ConstantFold - Constant fold an instruction of the specified type with the
-/// specified constant operands. This function may modify the operands vector.
-static Constant *ConstantFold(const Instruction *I,
- std::vector<Constant*> &Operands) {
- if (isa<BinaryOperator>(I) || isa<ShiftInst>(I))
- return ConstantExpr::get(I->getOpcode(), Operands[0], Operands[1]);
-
- if (isa<CastInst>(I))
- return ConstantExpr::getCast(I->getOpcode(), Operands[0], I->getType());
-
- switch (I->getOpcode()) {
- case Instruction::Select:
- return ConstantExpr::getSelect(Operands[0], Operands[1], Operands[2]);
- case Instruction::Call:
- if (Function *GV = dyn_cast<Function>(Operands[0])) {
- return ConstantFoldCall(cast<Function>(GV), &Operands[1],
- Operands.size()-1);
- }
- return 0;
- case Instruction::GetElementPtr: {
- Constant *Base = Operands[0];
- Operands.erase(Operands.begin());
- return ConstantExpr::getGetElementPtr(Base, Operands);
- }
- case Instruction::ICmp:
- return ConstantExpr::getICmp(
- cast<ICmpInst>(I)->getPredicate(), Operands[0], Operands[1]);
- case Instruction::FCmp:
- return ConstantExpr::getFCmp(
- cast<FCmpInst>(I)->getPredicate(), Operands[0], Operands[1]);
- }
- return 0;
-}
-
-
/// getConstantEvolvingPHI - Given an LLVM value and a loop, return a PHI node
/// in the loop that V is derived from. We allow arbitrary operations along the
/// way, but the operands of an operation must either be constants or a value
@@ -1841,7 +1806,7 @@ static Constant *EvaluateExpression(Value *V, Constant *PHIVal) {
if (Operands[i] == 0) return 0;
}
- return ConstantFold(I, Operands);
+ return ConstantFoldInstOperands(I, &Operands[0], Operands.size());
}
/// getConstantEvolutionLoopExitValue - If we know that the specified Phi is
@@ -2006,7 +1971,8 @@ SCEVHandle ScalarEvolutionsImpl::getSCEVAtScope(SCEV *V, const Loop *L) {
}
}
}
- return SCEVUnknown::get(ConstantFold(I, Operands));
+ Constant *C =ConstantFoldInstOperands(I, &Operands[0], Operands.size());
+ return SCEVUnknown::get(C);
}
}
OpenPOWER on IntegriCloud