[llvm-commits] [llvm] r38457 - in /llvm/trunk: include/llvm/Analysis/ScalarEvolutionExpressions.h lib/Analysis/ScalarEvolution.cpp
Dan Gohman
djg at cray.com
Mon Jul 9 08:25:18 PDT 2007
Author: djg
Date: Mon Jul 9 10:25:17 2007
New Revision: 38457
URL: http://llvm.org/viewvc/llvm-project?rev=38457&view=rev
Log:
Move the APInt form of SCEVUnknown::getIntegerSCEV to SCEVConstant::get, and
use SCEVConstant::get instead of SCEVUnknown::get when constructing a SCEV
for a ConstantInt.
Modified:
llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h
llvm/trunk/lib/Analysis/ScalarEvolution.cpp
Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h?rev=38457&r1=38456&r2=38457&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h (original)
+++ llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h Mon Jul 9 10:25:17 2007
@@ -33,13 +33,14 @@
///
class SCEVConstant : public SCEV {
ConstantInt *V;
- SCEVConstant(ConstantInt *v) : SCEV(scConstant), V(v) {}
+ explicit SCEVConstant(ConstantInt *v) : SCEV(scConstant), V(v) {}
virtual ~SCEVConstant();
public:
/// get method - This just gets and returns a new SCEVConstant object.
///
static SCEVHandle get(ConstantInt *V);
+ static SCEVHandle get(const APInt& Val);
ConstantInt *getValue() const { return V; }
@@ -511,7 +512,6 @@
/// getIntegerSCEV - Given an integer or FP type, create a constant for the
/// specified signed integer value and return a SCEV for the constant.
static SCEVHandle getIntegerSCEV(int Val, const Type *Ty);
- static SCEVHandle getIntegerSCEV(const APInt& Val);
Value *getValue() const { return V; }
Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=38457&r1=38456&r2=38457&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon Jul 9 10:25:17 2007
@@ -183,6 +183,10 @@
return R;
}
+SCEVHandle SCEVConstant::get(const APInt& Val) {
+ return get(ConstantInt::get(Val));
+}
+
ConstantRange SCEVConstant::getValueRange() const {
return ConstantRange(V->getValue());
}
@@ -487,10 +491,6 @@
return SCEVUnknown::get(C);
}
-SCEVHandle SCEVUnknown::getIntegerSCEV(const APInt& Val) {
- return SCEVUnknown::get(ConstantInt::get(Val));
-}
-
/// getTruncateOrZeroExtend - Return a SCEV corresponding to a conversion of the
/// input value to the specified type. If the type must be extended, it is zero
/// extended.
@@ -531,7 +531,7 @@
APInt Result(Val.getBitWidth(), 1);
for (; NumSteps; --NumSteps)
Result *= Val-(NumSteps-1);
- return SCEVUnknown::get(ConstantInt::get(Result));
+ return SCEVConstant::get(Result);
}
const Type *Ty = V->getType();
@@ -1716,8 +1716,8 @@
}
static ConstantInt *
-EvaluateConstantChrecAtConstant(const SCEVAddRecExpr *AddRec, Constant *C) {
- SCEVHandle InVal = SCEVConstant::get(cast<ConstantInt>(C));
+EvaluateConstantChrecAtConstant(const SCEVAddRecExpr *AddRec, ConstantInt *C) {
+ SCEVHandle InVal = SCEVConstant::get(C);
SCEVHandle Val = AddRec->evaluateAtIteration(InVal);
assert(isa<SCEVConstant>(Val) &&
"Evaluation of SCEV at constant didn't fold correctly?");
@@ -2199,8 +2199,8 @@
ConstantInt *Solution1 = ConstantInt::get((NegB + SqrtVal).sdiv(TwoA));
ConstantInt *Solution2 = ConstantInt::get((NegB - SqrtVal).sdiv(TwoA));
- return std::make_pair(SCEVUnknown::get(Solution1),
- SCEVUnknown::get(Solution2));
+ return std::make_pair(SCEVConstant::get(Solution1),
+ SCEVConstant::get(Solution2));
} // end APIntOps namespace
}
@@ -2468,15 +2468,14 @@
EvaluateConstantChrecAtConstant(this,
ConstantInt::get(ExitVal - One))->getValue()) &&
"Linear scev computation is off in a bad way!");
- return SCEVConstant::get(cast<ConstantInt>(ExitValue));
+ return SCEVConstant::get(ExitValue);
} else if (isQuadratic()) {
// If this is a quadratic (3-term) AddRec {L,+,M,+,N}, find the roots of the
// quadratic equation to solve it. To do this, we must frame our problem in
// terms of figuring out when zero is crossed, instead of when
// Range.getUpper() is crossed.
std::vector<SCEVHandle> NewOps(op_begin(), op_end());
- NewOps[0] = SCEV::getNegativeSCEV(SCEVUnknown::get(
- ConstantInt::get(Range.getUpper())));
+ NewOps[0] = SCEV::getNegativeSCEV(SCEVConstant::get(Range.getUpper()));
SCEVHandle NewAddRec = SCEVAddRecExpr::get(NewOps, getLoop());
// Next, solve the constructed addrec
@@ -2499,17 +2498,17 @@
R1->getValue());
if (Range.contains(R1Val->getValue())) {
// The next iteration must be out of the range...
- Constant *NextVal = ConstantInt::get(R1->getValue()->getValue()+1);
+ ConstantInt *NextVal = ConstantInt::get(R1->getValue()->getValue()+1);
R1Val = EvaluateConstantChrecAtConstant(this, NextVal);
if (!Range.contains(R1Val->getValue()))
- return SCEVUnknown::get(NextVal);
+ return SCEVConstant::get(NextVal);
return new SCEVCouldNotCompute(); // Something strange happened
}
// If R1 was not in the range, then it is a good return value. Make
// sure that R1-1 WAS in the range though, just in case.
- Constant *NextVal = ConstantInt::get(R1->getValue()->getValue()-1);
+ ConstantInt *NextVal = ConstantInt::get(R1->getValue()->getValue()-1);
R1Val = EvaluateConstantChrecAtConstant(this, NextVal);
if (Range.contains(R1Val->getValue()))
return R1;
More information about the llvm-commits
mailing list