aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhou Sheng <zhousheng00@gmail.com>2007-01-11 12:24:14 +0000
committerZhou Sheng <zhousheng00@gmail.com>2007-01-11 12:24:14 +0000
commit6b6b6ef1677fa71b1072c2911b4c1f9524a558c9 (patch)
tree480ecf010ac5facd1bc29ab57441253691bb42d6
parent057809ac1c78c3456e8f1481330fa2bcd2b85029 (diff)
For PR1043:
Merge ConstantIntegral and ConstantBool into ConstantInt. Remove ConstantIntegral and ConstantBool from LLVM. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33073 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Constants.h189
-rw-r--r--include/llvm/Support/ConstantRange.h11
-rw-r--r--include/llvm/Support/PatternMatch.h4
-rw-r--r--include/llvm/Value.h1
-rw-r--r--lib/Analysis/BasicAliasAnalysis.cpp15
-rw-r--r--lib/Analysis/ConstantRange.cpp50
-rw-r--r--lib/Analysis/ScalarEvolution.cpp28
-rw-r--r--lib/Analysis/ScalarEvolutionExpander.cpp2
-rw-r--r--lib/AsmParser/ParserInternals.h4
-rw-r--r--lib/AsmParser/llvmAsmParser.cpp.cvs1920
-rw-r--r--lib/AsmParser/llvmAsmParser.h.cvs2
-rw-r--r--lib/AsmParser/llvmAsmParser.y10
-rw-r--r--lib/AsmParser/llvmAsmParser.y.cvs62
-rw-r--r--lib/Bytecode/Reader/Reader.cpp2
-rw-r--r--lib/Bytecode/Writer/Writer.cpp2
-rw-r--r--lib/CodeGen/AsmPrinter.cpp10
-rw-r--r--lib/CodeGen/MachineDebugInfo.cpp6
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp24
-rw-r--r--lib/ExecutionEngine/ExecutionEngine.cpp2
-rw-r--r--lib/ExecutionEngine/JIT/JIT.cpp2
-rw-r--r--lib/Support/ConstantRange.cpp50
-rw-r--r--lib/Target/CBackend/CBackend.cpp27
-rw-r--r--lib/Transforms/IPO/GlobalOpt.cpp21
-rw-r--r--lib/Transforms/Instrumentation/RSProfiling.cpp4
-rw-r--r--lib/Transforms/Scalar/CondPropagate.cpp5
-rw-r--r--lib/Transforms/Scalar/CorrelatedExprs.cpp156
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp218
-rw-r--r--lib/Transforms/Scalar/LoopUnswitch.cpp64
-rw-r--r--lib/Transforms/Scalar/PredicateSimplifier.cpp57
-rw-r--r--lib/Transforms/Scalar/Reassociate.cpp4
-rw-r--r--lib/Transforms/Scalar/SCCP.cpp22
-rw-r--r--lib/Transforms/Utils/CloneFunction.cpp13
-rw-r--r--lib/Transforms/Utils/CodeExtractor.cpp2
-rw-r--r--lib/Transforms/Utils/Local.cpp6
-rw-r--r--lib/Transforms/Utils/SimplifyCFG.cpp13
-rw-r--r--lib/Transforms/Utils/ValueMapper.cpp2
-rw-r--r--lib/VMCore/AsmWriter.cpp8
-rw-r--r--lib/VMCore/ConstantFold.cpp340
-rw-r--r--lib/VMCore/Constants.cpp43
-rw-r--r--lib/VMCore/Instructions.cpp10
-rw-r--r--tools/llvm-upgrade/UpgradeParser.cpp328
-rw-r--r--tools/llvm-upgrade/UpgradeParser.h2
-rw-r--r--tools/llvm2cpp/CppWriter.cpp13
43 files changed, 1930 insertions, 1824 deletions
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h
index e7552e33e0..de9730c096 100644
--- a/include/llvm/Constants.h
+++ b/include/llvm/Constants.h
@@ -36,18 +36,19 @@ template<class ConstantClass, class TypeClass>
struct ConvertConstantType;
//===----------------------------------------------------------------------===//
-/// This is the shared superclass of boolean and integer constants. This class
-/// just defines some common interfaces to be implemented by the subclasses.
-/// @brief An abstract class for integer constants.
-class ConstantIntegral : public Constant {
+/// This is the shared class of boolean and integrer constants. This class
+/// represents both boolean and integral constants.
+/// @brief Class for constant integers.
+class ConstantInt : public Constant {
protected:
uint64_t Val;
- ConstantIntegral(const Type *Ty, ValueTy VT, uint64_t V);
+protected:
+ ConstantInt(const ConstantInt &); // DO NOT IMPLEMENT
+ ConstantInt(const Type *Ty, uint64_t V);
+ ConstantInt(const Type *Ty, int64_t V);
+ ConstantInt(bool V);
+ friend struct ConstantCreator<ConstantInt, Type, uint64_t>;
public:
-
- /// ConstantIntegral::get - Return a bool or integer constant.
- static ConstantIntegral *get(const Type *Ty, int64_t V);
-
/// Return the constant as a 64-bit unsigned integer value after it
/// has been zero extended as appropriate for the type of this constant.
/// @brief Return the zero extended value.
@@ -62,106 +63,6 @@ public:
unsigned Size = getType()->getPrimitiveSizeInBits();
return (int64_t(Val) << (64-Size)) >> (64-Size);
}
-
- /// This function is implemented by subclasses and will return true iff this
- /// constant represents the the "null" value that would be returned by the
- /// getNullValue method.
- /// @returns true if the constant's value is 0.
- /// @brief Determine if the value is null.
- virtual bool isNullValue() const = 0;
-
- /// This function is implemented by sublcasses and will return true iff this
- /// constant represents the the largest value that may be represented by this
- /// constant's type.
- /// @returns true if the constant's value is maximal.
- /// @brief Determine if the value is maximal.
- virtual bool isMaxValue(bool isSigned) const = 0;
-
- /// This function is implemented by subclasses and will return true iff this
- /// constant represents the smallest value that may be represented by this
- /// constant's type.
- /// @returns true if the constant's value is minimal
- /// @brief Determine if the value is minimal.
- virtual bool isMinValue(bool isSigned) const = 0;
-
- /// This function is implemented by subclasses and will return true iff every
- /// bit in this constant is set to true.
- /// @returns true if all bits of the constant are ones.
- /// @brief Determine if the value is all ones.
- virtual bool isAllOnesValue() const = 0;
-
- /// @returns the value for an integer constant of the given type that has all
- /// its bits set to true.
- /// @brief Get the all ones value
- static ConstantIntegral *getAllOnesValue(const Type *Ty);
-
- /// Methods to support type inquiry through isa, cast, and dyn_cast:
- static inline bool classof(const ConstantIntegral *) { return true; }
- static bool classof(const Value *V) {
- return V->getValueType() == ConstantBoolVal ||
- V->getValueType() == ConstantIntVal;
- }
-};
-
-
-//===----------------------------------------------------------------------===//
-/// This concrete class represents constant values of type BoolTy. There are
-/// only two instances of this class constructed: the True and False static
-/// members. The constructor is hidden to ensure this invariant.
-/// @brief Constant Boolean class
-class ConstantBool : public ConstantIntegral {
- ConstantBool(bool V);
-public:
- /// getTrue/getFalse - Return the singleton true/false values.
- static ConstantBool *getTrue();
- static ConstantBool *getFalse();
-
- /// This method is provided mostly for compatibility with the other
- /// ConstantIntegral subclasses.
- /// @brief Static factory method for getting a ConstantBool instance.
- static ConstantBool *get(bool Value) { return Value ? getTrue() : getFalse();}
-
- /// This method is provided mostly for compatibility with the other
- /// ConstantIntegral subclasses.
- /// @brief Static factory method for getting a ConstantBool instance.
- static ConstantBool *get(const Type *Ty, bool Value) { return get(Value); }
-
- /// Returns the opposite value of this ConstantBool value.
- /// @brief Get inverse value.
- inline ConstantBool *inverted() const {
- return getValue() ? getFalse() : getTrue();
- }
-
- /// @returns the value of this ConstantBool
- /// @brief return the boolean value of this constant.
- inline bool getValue() const { return static_cast<bool>(getZExtValue()); }
-
- /// @see ConstantIntegral for details
- /// @brief Implement overrides
- virtual bool isNullValue() const { return getValue() == false; }
- virtual bool isMaxValue(bool isSigned) const { return getValue() == true; }
- virtual bool isMinValue(bool isSigned) const { return getValue() == false; }
- virtual bool isAllOnesValue() const { return getValue() == true; }
-
- /// @brief Methods to support type inquiry through isa, cast, and dyn_cast:
- static inline bool classof(const ConstantBool *) { return true; }
- static bool classof(const Value *V) {
- return V->getValueType() == ConstantBoolVal;
- }
-};
-
-
-//===----------------------------------------------------------------------===//
-/// This is concrete integer subclass of ConstantIntegral that represents
-/// both signed and unsigned integral constants, other than boolean.
-/// @brief Class for constant integers.
-class ConstantInt : public ConstantIntegral {
-protected:
- ConstantInt(const ConstantInt &); // DO NOT IMPLEMENT
- ConstantInt(const Type *Ty, uint64_t V);
- ConstantInt(const Type *Ty, int64_t V);
- friend struct ConstantCreator<ConstantInt, Type, uint64_t>;
-public:
/// A helper method that can be used to determine if the constant contained
/// within is equal to a constant. This only works for very small values,
/// because this is all that can be represented with all types.
@@ -172,13 +73,45 @@ public:
return Val == V;
}
+ /// getTrue/getFalse - Return the singleton true/false values.
+ static inline ConstantInt *getTrue() {
+ static ConstantInt *T = 0;
+ if (T) return T;
+ return T = new ConstantInt(true);
+ }
+ static inline ConstantInt *getFalse() {
+ static ConstantInt *F = 0;
+ if (F) return F;
+ return F = new ConstantInt(false);
+ }
+
+ /// @brief Static factory method for getting a ConstantInt instance which
+ /// stands for a bool value.
+ static ConstantInt *get(bool Value) { return Value ? getTrue() : getFalse();}
+
/// Return a ConstantInt with the specified value for the specified type. The
/// value V will be canonicalized to a uint64_t but accessing it with either
- /// getSExtValue() or getZExtValue() (ConstantIntegral) will yield the correct
+ /// getSExtValue() or getZExtValue() (ConstantInt) will yield the correct
/// sized/signed value for the type Ty.
/// @brief Get a ConstantInt for a specific value.
static ConstantInt *get(const Type *Ty, int64_t V);
+ /// Returns the opposite value of this ConstantInt value if it's a boolean
+ /// constant.
+ /// @brief Get inverse value.
+ inline ConstantInt *inverted() const {
+ static ConstantInt *CI = 0;
+ if (CI) return CI;
+ return CI = new ConstantInt(getType(), Val ^ (-1));
+ }
+
+ /// @returns the value of this ConstantInt only if it's a boolean type.
+ /// @brief return the boolean value of this constant.
+ inline bool getBoolValue() const {
+ assert(getType() == Type::BoolTy && "Should be a boolean constant!");
+ return static_cast<bool>(getZExtValue());
+ }
+
/// This static method returns true if the type Ty is big enough to
/// represent the value V. This can be used to avoid having the get method
/// assert when V is larger than Ty can represent. Note that there are two
@@ -191,21 +124,30 @@ public:
static bool isValueValidForType(const Type *Ty, uint64_t V);
static bool isValueValidForType(const Type *Ty, int64_t V);
+ /// This function will return true iff this constant represents the "null"
+ /// value that would be returned by the getNullValue method.
/// @returns true if this is the null integer value.
- /// @see ConstantIntegral for details
- /// @brief Implement override.
- virtual bool isNullValue() const { return Val == 0; }
+ /// @brief Determine if the value is null.
+ virtual bool isNullValue() const {
+ return Val == 0;
+ }
+ /// This function will return true iff every bit in this constant is set
+ /// to true.
/// @returns true iff this constant's bits are all set to true.
- /// @see ConstantIntegral
- /// @brief Override implementation
- virtual bool isAllOnesValue() const { return getSExtValue() == -1; }
+ /// @brief Determine if the value is all ones.
+ virtual bool isAllOnesValue() const {
+ if (getType() == Type::BoolTy) return getBoolValue() == true;
+ return getSExtValue() == -1;
+ }
+ /// This function will return true iff this constant represents the largest
+ /// value that may be represented by the constant's type.
/// @returns true iff this is the largest value that may be represented
/// by this type.
- /// @see ConstantIntegeral
- /// @brief Override implementation
+ /// @brief Determine if the value is maximal.
virtual bool isMaxValue(bool isSigned) const {
+ if (getType() == Type::BoolTy) return getBoolValue() == true;
if (isSigned) {
int64_t V = getSExtValue();
if (V < 0) return false; // Be careful about wrap-around on 'long's
@@ -215,11 +157,13 @@ public:
return isAllOnesValue();
}
+ /// This function will return true iff this constant represents the smallest
+ /// value that may be represented by this constant's type.
/// @returns true if this is the smallest value that may be represented by
/// this type.
- /// @see ConstantIntegral
- /// @brief Override implementation
+ /// @brief Determine if the value is minimal.
virtual bool isMinValue(bool isSigned) const {
+ if (getType() == Type::BoolTy) return getBoolValue() == false;
if (isSigned) {
int64_t V = getSExtValue();
if (V > 0) return false; // Be careful about wrap-around on 'long's
@@ -229,6 +173,11 @@ public:
return getZExtValue() == 0;
}
+ /// @returns the value for an integer constant of the given type that has all
+ /// its bits set to true.
+ /// @brief Get the all ones value
+ static ConstantInt *getAllOnesValue(const Type *Ty);
+
/// @brief Methods to support type inquiry through isa, cast, and dyn_cast.
static inline bool classof(const ConstantInt *) { return true; }
static bool classof(const Value *V) {
diff --git a/include/llvm/Support/ConstantRange.h b/include/llvm/Support/ConstantRange.h
index 806dc80522..f37c54c707 100644
--- a/include/llvm/Support/ConstantRange.h
+++ b/include/llvm/Support/ConstantRange.h
@@ -36,12 +36,11 @@
namespace llvm {
class Constant;
-class ConstantIntegral;
class ConstantInt;
class Type;
class ConstantRange {
- ConstantIntegral *Lower, *Upper;
+ ConstantInt *Lower, *Upper;
public:
/// Initialize a full (the default) or empty set for the specified type.
///
@@ -61,15 +60,15 @@ class ConstantRange {
/// predicate should be either an ICmpInst::Predicate or FCmpInst::Predicate
/// value.
/// @brief Get a range for a relation with a constant integral.
- ConstantRange(unsigned short predicate, ConstantIntegral *C);
+ ConstantRange(unsigned short predicate, ConstantInt *C);
/// getLower - Return the lower value for this range...
///
- ConstantIntegral *getLower() const { return Lower; }
+ ConstantInt *getLower() const { return Lower; }
/// getUpper - Return the upper value for this range...
///
- ConstantIntegral *getUpper() const { return Upper; }
+ ConstantInt *getUpper() const { return Upper; }
/// getType - Return the LLVM data type of this range.
///
@@ -98,7 +97,7 @@ class ConstantRange {
/// getSingleElement - If this set contains a single element, return it,
/// otherwise return null.
///
- ConstantIntegral *getSingleElement() const;
+ ConstantInt *getSingleElement() const;
/// isSingleElement - Return true if this set contains exactly one member.
///
diff --git a/include/llvm/Support/PatternMatch.h b/include/llvm/Support/PatternMatch.h
index 6db214292a..f0acbcbaa6 100644
--- a/include/llvm/Support/PatternMatch.h
+++ b/include/llvm/Support/PatternMatch.h
@@ -356,9 +356,9 @@ struct not_match {
}
private:
bool matchIfNot(Value *LHS, Value *RHS) {
- if (ConstantIntegral *CI = dyn_cast<ConstantIntegral>(RHS))
+ if (ConstantInt *CI = dyn_cast<ConstantInt>(RHS))
return CI->isAllOnesValue() && L.match(LHS);
- else if (ConstantIntegral *CI = dyn_cast<ConstantIntegral>(LHS))
+ else if (ConstantInt *CI = dyn_cast<ConstantInt>(LHS))
return CI->isAllOnesValue() && L.match(RHS);
return false;
}
diff --git a/include/llvm/Value.h b/include/llvm/Value.h
index 0c3ddf6705..e1d26bb42e 100644
--- a/include/llvm/Value.h
+++ b/include/llvm/Value.h
@@ -152,7 +152,6 @@ public:
UndefValueVal, // This is an instance of UndefValue
ConstantExprVal, // This is an instance of ConstantExpr
ConstantAggregateZeroVal, // This is an instance of ConstantAggregateNull
- ConstantBoolVal, // This is an instance of ConstantBool
ConstantIntVal, // This is an instance of ConstantInt
ConstantFPVal, // This is an instance of ConstantFP
ConstantArrayVal, // This is an instance of ConstantArray
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp
index caabc86f3f..179f069716 100644
--- a/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/lib/Analysis/BasicAliasAnalysis.cpp
@@ -434,7 +434,8 @@ BasicAliasAnalysis::alias(const Value *V1, unsigned V1Size,
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 @@ BasicAliasAnalysis::CheckGEPInstructions(
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 @@ BasicAliasAnalysis::CheckGEPInstructions(
// 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 @@ BasicAliasAnalysis::CheckGEPInstructions(
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 {
diff --git a/lib/Analysis/ConstantRange.cpp b/lib/Analysis/ConstantRange.cpp
index a8ffa5813e..1d49e22472 100644
--- a/lib/Analysis/ConstantRange.cpp
+++ b/lib/Analysis/ConstantRange.cpp
@@ -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 ConstantIntegral *getMaxValue(const Type *Ty, bool isSigned = false) {
}
// 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 @@ static ConstantIntegral *getMinValue(const Type *Ty, bool isSigned = false) {
}
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 @@ ConstantRange::ConstantRange(const Type *Ty, bool Full) {
/// 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 @@ ConstantRange::ConstantRange(Constant *L, Constant *U)
/// 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 @@ bool ConstantRange::isWrappedSet(bool isSigned) const {
/// 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 @@ ConstantRange ConstantRange::intersectWith(const ConstantRange &CR,
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 @@ ConstantRange ConstantRange::intersectWith(const ConstantRange &CR,
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);
}
}
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp
index 55036a45c5..9fcbf8c75e 100644
--- a/lib/Analysis/ScalarEvolution.cpp
+++ b/lib/Analysis/ScalarEvolution.cpp
@@ -1721,8 +1721,8 @@ ComputeLoadConstantCompareIterationCount(LoadInst *LI, Constant *RHS,
// 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 @@ ComputeIterationCountExhaustively(const Loop *L, Value *Cond, bool ExitWhen) {
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 @@ SCEVHandle ScalarEvolutionsImpl::HowFarToZero(SCEV *V, const Loop *L) {
<< " 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 @@ SCEVHandle ScalarEvolutionsImpl::HowFarToNonZero(SCEV *V, const Loop *L) {
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 @@ SCEVHandle SCEVAddRecExpr::getNumIterationsInRange(ConstantRange Range,
SCEVConstant *R2 = dyn_cast<SCEVConstant>(Roots.second);
if (R1) {
// Pick the smallest positive root value.
- if (ConstantBool *CB =
- dyn_cast<Cons