Changes in directory llvm/lib/Analysis:
BasicAliasAnalysis.cpp updated: 1.96 -> 1.97 ConstantRange.cpp updated: 1.25 -> 1.26 ScalarEvolution.cpp updated: 1.81 -> 1.82 ScalarEvolutionExpander.cpp updated: 1.10 -> 1.11 --- Log message: For PR1043: http://llvm.org/PR1043 : Merge ConstantIntegral and ConstantBool into ConstantInt. Remove ConstantIntegral and ConstantBool from LLVM. --- Diffs of the changes: (+50 -45) BasicAliasAnalysis.cpp | 15 +++++++------ ConstantRange.cpp | 50 ++++++++++++++++++++++---------------------- ScalarEvolution.cpp | 28 +++++++++++++----------- ScalarEvolutionExpander.cpp | 2 - 4 files changed, 50 insertions(+), 45 deletions(-) Index: llvm/lib/Analysis/BasicAliasAnalysis.cpp diff -u llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.96 llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.97 --- llvm/lib/Analysis/BasicAliasAnalysis.cpp:1.96 Sat Dec 30 23:48:39 2006 +++ llvm/lib/Analysis/BasicAliasAnalysis.cpp Thu Jan 11 06:24:13 2007 @@ -434,7 +434,8 @@ if (cast<PointerType>( BasePtr->getType())->getElementType()->isSized()) { for (unsigned i = 0; i != GEPOperands.size(); ++i) - if (!isa<ConstantInt>(GEPOperands[i])) + if (!isa<ConstantInt>(GEPOperands[i]) || + GEPOperands[i]->getType() == Type::BoolTy) GEPOperands[i] = Constant::getNullValue(GEPOperands[i]->getType()); int64_t Offset = @@ -584,8 +585,8 @@ if (G1OC) { Constant *Compare = ConstantExpr::getICmp(ICmpInst::ICMP_SGT, G1OC, G2OC); - if (ConstantBool *CV = dyn_cast<ConstantBool>(Compare)) { - if (CV->getValue()) // If they are comparable and G2 > G1 + if (ConstantInt *CV = dyn_cast<ConstantInt>(Compare)) { + if (CV->getBoolValue()) // If they are comparable and G2 > G1 std::swap(GEP1Ops, GEP2Ops); // Make GEP1 < GEP2 break; } @@ -608,13 +609,15 @@ // Is there anything to check? if (GEP1Ops.size() > MinOperands) { for (unsigned i = FirstConstantOper; i != MaxOperands; ++i) - if (isa<ConstantInt>(GEP1Ops[i]) && + if (isa<ConstantInt>(GEP1Ops[i]) && + GEP1Ops[i]->getType() != Type::BoolTy && !cast<Constant>(GEP1Ops[i])->isNullValue()) { // Yup, there's a constant in the tail. Set all variables to // constants in the GEP instruction to make it suiteable for // TargetData::getIndexedOffset. for (i = 0; i != MaxOperands; ++i) - if (!isa<ConstantInt>(GEP1Ops[i])) + if (!isa<ConstantInt>(GEP1Ops[i]) || + GEP1Ops[i]->getType() == Type::BoolTy) GEP1Ops[i] = Constant::getNullValue(GEP1Ops[i]->getType()); // Okay, now get the offset. This is the relative offset for the full // instruction. @@ -667,7 +670,7 @@ const Value *Op2 = i < GEP2Ops.size() ? GEP2Ops[i] : 0; // If they are equal, use a zero index... if (Op1 == Op2 && BasePtr1Ty == BasePtr2Ty) { - if (!isa<ConstantInt>(Op1)) + if (!isa<ConstantInt>(Op1) || Op1->getType() == Type::BoolTy) GEP1Ops[i] = GEP2Ops[i] = Constant::getNullValue(Op1->getType()); // Otherwise, just keep the constants we have. } else { Index: llvm/lib/Analysis/ConstantRange.cpp diff -u llvm/lib/Analysis/ConstantRange.cpp:1.25 llvm/lib/Analysis/ConstantRange.cpp:1.26 --- llvm/lib/Analysis/ConstantRange.cpp:1.25 Sun Jan 7 23:34:39 2007 +++ llvm/lib/Analysis/ConstantRange.cpp Thu Jan 11 06:24:13 2007 @@ -30,9 +30,9 @@ #include <ostream> using namespace llvm; -static ConstantIntegral *getMaxValue(const Type *Ty, bool isSigned = false) { +static ConstantInt *getMaxValue(const Type *Ty, bool isSigned = false) { if (Ty == Type::BoolTy) - return ConstantBool::getTrue(); + return ConstantInt::getTrue(); if (Ty->isInteger()) { if (isSigned) { // Calculate 011111111111111... @@ -47,9 +47,9 @@ } // Static constructor to create the minimum constant for an integral type... -static ConstantIntegral *getMinValue(const Type *Ty, bool isSigned = false) { +static ConstantInt *getMinValue(const Type *Ty, bool isSigned = false) { if (Ty == Type::BoolTy) - return ConstantBool::getFalse(); + return ConstantInt::getFalse(); if (Ty->isInteger()) { if (isSigned) { // Calculate 1111111111000000000000 @@ -62,37 +62,37 @@ } return 0; } -static ConstantIntegral *Next(ConstantIntegral *CI) { - if (ConstantBool *CB = dyn_cast<ConstantBool>(CI)) - return ConstantBool::get(!CB->getValue()); +static ConstantInt *Next(ConstantInt *CI) { + if (CI->getType() == Type::BoolTy) + return ConstantInt::get(!CI->getBoolValue()); Constant *Result = ConstantExpr::getAdd(CI, ConstantInt::get(CI->getType(), 1)); - return cast<ConstantIntegral>(Result); + return cast<ConstantInt>(Result); } -static bool LT(ConstantIntegral *A, ConstantIntegral *B, bool isSigned) { +static bool LT(ConstantInt *A, ConstantInt *B, bool isSigned) { Constant *C = ConstantExpr::getICmp( (isSigned ? ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT), A, B); - assert(isa<ConstantBool>(C) && "Constant folding of integrals not impl??"); - return cast<ConstantBool>(C)->getValue(); + assert(isa<ConstantInt>(C) && "Constant folding of integrals not impl??"); + return cast<ConstantInt>(C)->getBoolValue(); } -static bool LTE(ConstantIntegral *A, ConstantIntegral *B, bool isSigned) { +static bool LTE(ConstantInt *A, ConstantInt *B, bool isSigned) { Constant *C = ConstantExpr::getICmp( (isSigned ? ICmpInst::ICMP_SLE : ICmpInst::ICMP_ULE), A, B); - assert(isa<ConstantBool>(C) && "Constant folding of integrals not impl??"); - return cast<ConstantBool>(C)->getValue(); + assert(isa<ConstantInt>(C) && "Constant folding of integrals not impl??"); + return cast<ConstantInt>(C)->getBoolValue(); } -static bool GT(ConstantIntegral *A, ConstantIntegral *B, bool isSigned) { +static bool GT(ConstantInt *A, ConstantInt *B, bool isSigned) { return LT(B, A, isSigned); } -static ConstantIntegral *Min(ConstantIntegral *A, ConstantIntegral *B, +static ConstantInt *Min(ConstantInt *A, ConstantInt *B, bool isSigned) { return LT(A, B, isSigned) ? A : B; } -static ConstantIntegral *Max(ConstantIntegral *A, ConstantIntegral *B, +static ConstantInt *Max(ConstantInt *A, ConstantInt *B, bool isSigned) { return GT(A, B, isSigned) ? A : B; } @@ -111,14 +111,14 @@ /// Initialize a range to hold the single specified value. /// ConstantRange::ConstantRange(Constant *V) - : Lower(cast<ConstantIntegral>(V)), Upper(Next(cast<ConstantIntegral>(V))) { } + : Lower(cast<ConstantInt>(V)), Upper(Next(cast<ConstantInt>(V))) { } /// Initialize a range of values explicitly... this will assert out if /// Lower==Upper and Lower != Min or Max for its type (or if the two constants /// have different types) /// ConstantRange::ConstantRange(Constant *L, Constant *U) - : Lower(cast<ConstantIntegral>(L)), Upper(cast<ConstantIntegral>(U)) { + : Lower(cast<ConstantInt>(L)), Upper(cast<ConstantInt>(U)) { assert(Lower->getType() == Upper->getType() && "Incompatible types for ConstantRange!"); @@ -130,7 +130,7 @@ /// Initialize a set of values that all satisfy the condition with C. /// -ConstantRange::ConstantRange(unsigned short ICmpOpcode, ConstantIntegral *C) { +ConstantRange::ConstantRange(unsigned short ICmpOpcode, ConstantInt *C) { switch (ICmpOpcode) { default: assert(0 && "Invalid ICmp opcode to ConstantRange ctor!"); case ICmpInst::ICMP_EQ: Lower = C; Upper = Next(C); return; @@ -195,7 +195,7 @@ /// getSingleElement - If this set contains a single element, return it, /// otherwise return null. -ConstantIntegral *ConstantRange::getSingleElement() const { +ConstantInt *ConstantRange::getSingleElement() const { if (Upper == Next(Lower)) // Is it a single element range? return Lower; return 0; @@ -292,8 +292,8 @@ if (!isWrappedSet(isSigned)) { if (!CR.isWrappedSet(isSigned)) { - ConstantIntegral *L = Max(Lower, CR.Lower, isSigned); - ConstantIntegral *U = Min(Upper, CR.Upper, isSigned); + ConstantInt *L = Max(Lower, CR.Lower, isSigned); + ConstantInt *U = Min(Upper, CR.Upper, isSigned); if (LT(L, U, isSigned)) // If range isn't empty... return ConstantRange(L, U); @@ -306,8 +306,8 @@ return intersect1Wrapped(*this, CR, isSigned); else { // Both ranges are wrapped... - ConstantIntegral *L = Max(Lower, CR.Lower, isSigned); - ConstantIntegral *U = Min(Upper, CR.Upper, isSigned); + ConstantInt *L = Max(Lower, CR.Lower, isSigned); + ConstantInt *U = Min(Upper, CR.Upper, isSigned); return ConstantRange(L, U); } } Index: llvm/lib/Analysis/ScalarEvolution.cpp diff -u llvm/lib/Analysis/ScalarEvolution.cpp:1.81 llvm/lib/Analysis/ScalarEvolution.cpp:1.82 --- llvm/lib/Analysis/ScalarEvolution.cpp:1.81 Sun Jan 7 19:26:33 2007 +++ llvm/lib/Analysis/ScalarEvolution.cpp Thu Jan 11 06:24:13 2007 @@ -1721,8 +1721,8 @@ // Evaluate the condition for this iteration. Result = ConstantExpr::getICmp(predicate, Result, RHS); - if (!isa<ConstantBool>(Result)) break; // Couldn't decide for sure - if (cast<ConstantBool>(Result)->getValue() == false) { + if (!isa<ConstantInt>(Result)) break; // Couldn't decide for sure + if (cast<ConstantInt>(Result)->getBoolValue() == false) { #if 0 cerr << "\n***\n*** Computed loop count " << *ItCst << "\n*** From global " << *GV << "*** BB: " << *L->getHeader() @@ -1926,11 +1926,13 @@ unsigned MaxIterations = MaxBruteForceIterations; // Limit analysis. for (Constant *PHIVal = StartCST; IterationNum != MaxIterations; ++IterationNum) { - ConstantBool *CondVal = - dyn_cast_or_null<ConstantBool>(EvaluateExpression(Cond, PHIVal)); - if (!CondVal) return UnknownValue; // Couldn't symbolically evaluate. + ConstantInt *CondVal = + dyn_cast_or_null<ConstantInt>(EvaluateExpression(Cond, PHIVal)); - if (CondVal->getValue() == ExitWhen) { + // Couldn't symbolically evaluate. + if (!CondVal || CondVal->getType() != Type::BoolTy) return UnknownValue; + + if (CondVal->getBoolValue() == ExitWhen) { ConstantEvolutionLoopExitValue[PN] = PHIVal; ++NumBruteForceTripCountsComputed; return SCEVConstant::get(ConstantInt::get(Type::Int32Ty, IterationNum)); @@ -2199,10 +2201,10 @@ << " sol#2: " << *R2 << "\n"; #endif // Pick the smallest positive root value. - if (ConstantBool *CB = - dyn_cast<ConstantBool>(ConstantExpr::getICmp(ICmpInst::ICMP_ULT, + if (ConstantInt *CB = + dyn_cast<ConstantInt>(ConstantExpr::getICmp(ICmpInst::ICMP_ULT, R1->getValue(), R2->getValue()))) { - if (CB->getValue() == false) + if (CB->getBoolValue() == false) std::swap(R1, R2); // R1 is the minimum root now. // We can only use this value if the chrec ends up with an exact zero @@ -2233,7 +2235,7 @@ Constant *Zero = Constant::getNullValue(C->getValue()->getType()); Constant *NonZero = ConstantExpr::getICmp(ICmpInst::ICMP_NE, C->getValue(), Zero); - if (NonZero == ConstantBool::getTrue()) + if (NonZero == ConstantInt::getTrue()) return getSCEV(Zero); return UnknownValue; // Otherwise it will loop infinitely. } @@ -2424,10 +2426,10 @@ SCEVConstant *R2 = dyn_cast<SCEVConstant>(Roots.second); if (R1) { // Pick the smallest positive root value. - if (ConstantBool *CB = - dyn_cast<ConstantBool>(ConstantExpr::getICmp(ICmpInst::ICMP_ULT, + if (ConstantInt *CB = + dyn_cast<ConstantInt>(ConstantExpr::getICmp(ICmpInst::ICMP_ULT, R1->getValue(), R2->getValue()))) { - if (CB->getValue() == false) + if (CB->getBoolValue() == false) std::swap(R1, R2); // R1 is the minimum root now. // Make sure the root is not off by one. The returned iteration should Index: llvm/lib/Analysis/ScalarEvolutionExpander.cpp diff -u llvm/lib/Analysis/ScalarEvolutionExpander.cpp:1.10 llvm/lib/Analysis/ScalarEvolutionExpander.cpp:1.11 --- llvm/lib/Analysis/ScalarEvolutionExpander.cpp:1.10 Wed Dec 13 02:06:42 2006 +++ llvm/lib/Analysis/ScalarEvolutionExpander.cpp Thu Jan 11 06:24:13 2007 @@ -143,7 +143,7 @@ Value *F = expandInTy(S->getOperand(1), Ty); // IF the step is by one, just return the inserted IV. - if (ConstantIntegral *CI = dyn_cast<ConstantIntegral>(F)) + if (ConstantInt *CI = dyn_cast<ConstantInt>(F)) if (CI->getZExtValue() == 1) return I; _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits