For PR1205:
First round of ConstantRange changes. This makes all CR constructors use
only APInt and not use ConstantInt. Clients are adjusted accordingly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34756 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp
index a81f24f..0507b39 100644
--- a/lib/Analysis/ScalarEvolution.cpp
+++ b/lib/Analysis/ScalarEvolution.cpp
@@ -177,7 +177,7 @@
}
ConstantRange SCEVConstant::getValueRange() const {
- return ConstantRange(V);
+ return ConstantRange(V->getValue());
}
const Type *SCEVConstant::getType() const { return V->getType(); }
@@ -490,12 +490,11 @@
// Handle this case efficiently, it is common to have constant iteration
// counts while computing loop exit values.
if (SCEVConstant *SC = dyn_cast<SCEVConstant>(V)) {
- uint64_t Val = SC->getValue()->getZExtValue();
- uint64_t Result = 1;
+ APInt Val = SC->getValue()->getValue();
+ APInt Result(Val.getBitWidth(), 1);
for (; NumSteps; --NumSteps)
Result *= Val-(NumSteps-1);
- Constant *Res = ConstantInt::get(Type::Int64Ty, Result);
- return SCEVUnknown::get(ConstantExpr::getTruncOrBitCast(Res, V->getType()));
+ return SCEVUnknown::get(ConstantInt::get(V->getType(), Result));
}
const Type *Ty = V->getType();
@@ -1567,7 +1566,7 @@
ConstantExpr::getBitCast(CompVal, RealTy));
if (CompVal) {
// Form the constant range.
- ConstantRange CompRange(Cond, CompVal);
+ ConstantRange CompRange(Cond, CompVal->getValue());
SCEVHandle Ret = AddRec->getNumIterationsInRange(CompRange,
false /*Always treat as unsigned range*/);