For PR1205:

Adjust to changes in ConstantRange interface.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34762 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Spencer 2007-02-28 22:03:51 +00:00
parent bb626a6751
commit c6aedf70b3
2 changed files with 20 additions and 13 deletions

View File

@ -124,7 +124,7 @@ ConstantRange SCEV::getValueRange() const {
const Type *Ty = getType(); const Type *Ty = getType();
assert(Ty->isInteger() && "Can't get range for a non-integer SCEV!"); assert(Ty->isInteger() && "Can't get range for a non-integer SCEV!");
// Default to a full range if no better information is available. // Default to a full range if no better information is available.
return ConstantRange(getType()); return ConstantRange(getBitWidth());
} }
uint32_t SCEV::getBitWidth() const { uint32_t SCEV::getBitWidth() const {
@ -211,7 +211,7 @@ SCEVTruncateExpr::~SCEVTruncateExpr() {
} }
ConstantRange SCEVTruncateExpr::getValueRange() const { ConstantRange SCEVTruncateExpr::getValueRange() const {
return getOperand()->getValueRange().truncate(getType()); return getOperand()->getValueRange().truncate(getBitWidth());
} }
void SCEVTruncateExpr::print(std::ostream &OS) const { void SCEVTruncateExpr::print(std::ostream &OS) const {
@ -237,7 +237,7 @@ SCEVZeroExtendExpr::~SCEVZeroExtendExpr() {
} }
ConstantRange SCEVZeroExtendExpr::getValueRange() const { ConstantRange SCEVZeroExtendExpr::getValueRange() const {
return getOperand()->getValueRange().zeroExtend(getType()); return getOperand()->getValueRange().zeroExtend(getBitWidth());
} }
void SCEVZeroExtendExpr::print(std::ostream &OS) const { void SCEVZeroExtendExpr::print(std::ostream &OS) const {
@ -1572,7 +1572,8 @@ SCEVHandle ScalarEvolutionsImpl::ComputeIterationCount(const Loop *L) {
ConstantExpr::getBitCast(CompVal, RealTy)); ConstantExpr::getBitCast(CompVal, RealTy));
if (CompVal) { if (CompVal) {
// Form the constant range. // Form the constant range.
ConstantRange CompRange(Cond, CompVal->getValue()); ConstantRange CompRange(
ICmpInst::makeConstantRange(Cond, CompVal->getValue()));
SCEVHandle Ret = AddRec->getNumIterationsInRange(CompRange, SCEVHandle Ret = AddRec->getNumIterationsInRange(CompRange,
false /*Always treat as unsigned range*/); false /*Always treat as unsigned range*/);

View File

@ -113,7 +113,8 @@ namespace {
Value *Replacement; Value *Replacement;
public: public:
ValueInfo(const Type *Ty) ValueInfo(const Type *Ty)
: Bounds(Ty->isInteger() ? Ty : Type::Int32Ty), Replacement(0) {} : Bounds(Ty->isInteger() ? cast<IntegerType>(Ty)->getBitWidth() : 32),
Replacement(0) {}
// getBounds() - Return the constant bounds of the value... // getBounds() - Return the constant bounds of the value...
const ConstantRange &getBounds() const { return Bounds; } const ConstantRange &getBounds() const { return Bounds; }
@ -1153,9 +1154,10 @@ Relation::KnownResult CEE::getCmpResult(CmpInst *CI,
// //
if (ConstantInt *C = dyn_cast<ConstantInt>(Op1)) { if (ConstantInt *C = dyn_cast<ConstantInt>(Op1)) {
// Check to see if we already know the result of this comparison... // Check to see if we already know the result of this comparison...
ConstantRange R = ConstantRange(predicate, C->getValue()); ICmpInst::Predicate ipred = ICmpInst::Predicate(predicate);
ConstantRange R = ICmpInst::makeConstantRange(ipred, C->getValue());
ConstantRange Int = R.intersectWith(Op0VI->getBounds(), ConstantRange Int = R.intersectWith(Op0VI->getBounds(),
ICmpInst::isSignedPredicate(ICmpInst::Predicate(predicate))); ICmpInst::isSignedPredicate(ipred));
// If the intersection of the two ranges is empty, then the condition // If the intersection of the two ranges is empty, then the condition
// could never be true! // could never be true!
@ -1199,10 +1201,12 @@ bool Relation::contradicts(unsigned Op,
// //
if (ConstantInt *C = dyn_cast<ConstantInt>(Val)) if (ConstantInt *C = dyn_cast<ConstantInt>(Val))
if (Op >= ICmpInst::FIRST_ICMP_PREDICATE && if (Op >= ICmpInst::FIRST_ICMP_PREDICATE &&
Op <= ICmpInst::LAST_ICMP_PREDICATE) Op <= ICmpInst::LAST_ICMP_PREDICATE) {
if (ConstantRange(Op, C->getValue()).intersectWith(VI.getBounds(), ICmpInst::Predicate ipred = ICmpInst::Predicate(Op);
ICmpInst::isSignedPredicate(ICmpInst::Predicate(Op))).isEmptySet()) if (ICmpInst::makeConstantRange(ipred, C->getValue()).intersectWith(
VI.getBounds(), ICmpInst::isSignedPredicate(ipred)).isEmptySet())
return true; return true;
}
switch (Rel) { switch (Rel) {
default: assert(0 && "Unknown Relationship code!"); default: assert(0 && "Unknown Relationship code!");
@ -1257,10 +1261,12 @@ bool Relation::incorporate(unsigned Op, ValueInfo &VI) {
// //
if (ConstantInt *C = dyn_cast<ConstantInt>(Val)) if (ConstantInt *C = dyn_cast<ConstantInt>(Val))
if (Op >= ICmpInst::FIRST_ICMP_PREDICATE && if (Op >= ICmpInst::FIRST_ICMP_PREDICATE &&
Op <= ICmpInst::LAST_ICMP_PREDICATE) Op <= ICmpInst::LAST_ICMP_PREDICATE) {
ICmpInst::Predicate ipred = ICmpInst::Predicate(Op);
VI.getBounds() = VI.getBounds() =
ConstantRange(Op, C->getValue()).intersectWith(VI.getBounds(), ICmpInst::makeConstantRange(ipred, C->getValue()).intersectWith(
ICmpInst::isSignedPredicate(ICmpInst::Predicate(Op))); VI.getBounds(), ICmpInst::isSignedPredicate(ipred));
}
switch (Rel) { switch (Rel) {
default: assert(0 && "Unknown prior value!"); default: assert(0 && "Unknown prior value!");