[llvm-commits] CVS: llvm/lib/Transforms/Scalar/CondPropagate.cpp CorrelatedExprs.cpp InstructionCombining.cpp LoopUnswitch.cpp PredicateSimplifier.cpp Reassociate.cpp SCCP.cpp

Zhou Sheng zhousheng00 at gmail.com
Thu Jan 11 04:25:06 PST 2007



Changes in directory llvm/lib/Transforms/Scalar:

CondPropagate.cpp updated: 1.11 -> 1.12
CorrelatedExprs.cpp updated: 1.44 -> 1.45
InstructionCombining.cpp updated: 1.588 -> 1.589
LoopUnswitch.cpp updated: 1.53 -> 1.54
PredicateSimplifier.cpp updated: 1.42 -> 1.43
Reassociate.cpp updated: 1.70 -> 1.71
SCCP.cpp updated: 1.147 -> 1.148
---
Log message:

For PR1043: http://llvm.org/PR1043 :
Merge ConstantIntegral and ConstantBool into ConstantInt.
Remove ConstantIntegral and ConstantBool from LLVM.


---
Diffs of the changes:  (+269 -257)

 CondPropagate.cpp        |    5 -
 CorrelatedExprs.cpp      |  156 +++++++++++++++++----------------
 InstructionCombining.cpp |  218 +++++++++++++++++++++++------------------------
 LoopUnswitch.cpp         |   64 +++++++------
 PredicateSimplifier.cpp  |   57 ++++++------
 Reassociate.cpp          |    4 
 SCCP.cpp                 |   22 ++--
 7 files changed, 269 insertions(+), 257 deletions(-)


Index: llvm/lib/Transforms/Scalar/CondPropagate.cpp
diff -u llvm/lib/Transforms/Scalar/CondPropagate.cpp:1.11 llvm/lib/Transforms/Scalar/CondPropagate.cpp:1.12
--- llvm/lib/Transforms/Scalar/CondPropagate.cpp:1.11	Tue Dec 19 15:40:18 2006
+++ llvm/lib/Transforms/Scalar/CondPropagate.cpp	Thu Jan 11 06:24:14 2007
@@ -133,12 +133,13 @@
   // constants.  Walk from the end to remove operands from the end when
   // possible, and to avoid invalidating "i".
   for (unsigned i = PN->getNumIncomingValues(); i != 0; --i)
-    if (ConstantBool *CB = dyn_cast<ConstantBool>(PN->getIncomingValue(i-1))) {
+    if (ConstantInt *CB = dyn_cast<ConstantInt>(PN->getIncomingValue(i-1))) {
+      if (CB->getType() != Type::BoolTy) continue;
       // If we have a constant, forward the edge from its current to its
       // ultimate destination.
       bool PHIGone = PN->getNumIncomingValues() == 2;
       RevectorBlockTo(PN->getIncomingBlock(i-1),
-                      BI->getSuccessor(CB->getValue() == 0));
+                      BI->getSuccessor(CB->getBoolValue() == 0));
       ++NumBrThread;
 
       // If there were two predecessors before this simplification, the PHI node


Index: llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp
diff -u llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp:1.44 llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp:1.45
--- llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp:1.44	Thu Jan 11 04:33:26 2007
+++ llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp	Thu Jan 11 06:24:14 2007
@@ -472,7 +472,7 @@
     } else if (CmpInst *CI = dyn_cast<CmpInst>(I)) {
       Relation::KnownResult Res = getCmpResult(CI, NewRI);
       if (Res == Relation::Unknown) return false;
-      PropagateEquality(CI, ConstantBool::get(Res), NewRI);
+      PropagateEquality(CI, ConstantInt::get(Res), NewRI);
     } else {
       assert(isa<BranchInst>(*I) && "Unexpected instruction type!");
     }
@@ -484,10 +484,11 @@
   if (PredicateVI.getReplacement() &&
       isa<Constant>(PredicateVI.getReplacement()) &&
       !isa<GlobalValue>(PredicateVI.getReplacement())) {
-    ConstantBool *CB = cast<ConstantBool>(PredicateVI.getReplacement());
+    ConstantInt *CB = cast<ConstantInt>(PredicateVI.getReplacement());
 
     // Forward to the successor that corresponds to the branch we will take.
-    ForwardSuccessorTo(TI, SuccNo, BI->getSuccessor(!CB->getValue()), NewRI);
+    ForwardSuccessorTo(TI, SuccNo, 
+                       BI->getSuccessor(!CB->getBoolValue()), NewRI);
     return true;
   }
 
@@ -782,12 +783,12 @@
 
   // Propagate information into the true block...
   //
-  PropagateEquality(BI->getCondition(), ConstantBool::getTrue(),
+  PropagateEquality(BI->getCondition(), ConstantInt::getTrue(),
                     getRegionInfo(BI->getSuccessor(0)));
 
   // Propagate information into the false block...
   //
-  PropagateEquality(BI->getCondition(), ConstantBool::getFalse(),
+  PropagateEquality(BI->getCondition(), ConstantInt::getFalse(),
                     getRegionInfo(BI->getSuccessor(1)));
 }
 
@@ -832,78 +833,79 @@
   // it's a constant, then see if the other one is one of a setcc instruction,
   // an AND, OR, or XOR instruction.
   //
-  if (ConstantBool *CB = dyn_cast<ConstantBool>(Op1)) {
-
-    if (Instruction *Inst = dyn_cast<Instruction>(Op0)) {
-      // If we know that this instruction is an AND instruction, and the result
-      // is true, this means that both operands to the OR are known to be true
-      // as well.
-      //
-      if (CB->getValue() && Inst->getOpcode() == Instruction::And) {
-        PropagateEquality(Inst->getOperand(0), CB, RI);
-        PropagateEquality(Inst->getOperand(1), CB, RI);
-      }
-
-      // If we know that this instruction is an OR instruction, and the result
-      // is false, this means that both operands to the OR are know to be false
-      // as well.
-      //
-      if (!CB->getValue() && Inst->getOpcode() == Instruction::Or) {
-        PropagateEquality(Inst->getOperand(0), CB, RI);
-        PropagateEquality(Inst->getOperand(1), CB, RI);
-      }
-
-      // If we know that this instruction is a NOT instruction, we know that the
-      // operand is known to be the inverse of whatever the current value is.
-      //
-      if (BinaryOperator *BOp = dyn_cast<BinaryOperator>(Inst))
-        if (BinaryOperator::isNot(BOp))
-          PropagateEquality(BinaryOperator::getNotArgument(BOp),
-                            ConstantBool::get(!CB->getValue()), RI);
+  if (Op1->getType() == Type::BoolTy)
+    if (ConstantInt *CB = dyn_cast<ConstantInt>(Op1)) {
+  
+      if (Instruction *Inst = dyn_cast<Instruction>(Op0)) {
+        // If we know that this instruction is an AND instruction, and the result
+        // is true, this means that both operands to the OR are known to be true
+        // as well.
+        //
+        if (CB->getBoolValue() && Inst->getOpcode() == Instruction::And) {
+          PropagateEquality(Inst->getOperand(0), CB, RI);
+          PropagateEquality(Inst->getOperand(1), CB, RI);
+        }
+  
+        // If we know that this instruction is an OR instruction, and the result
+        // is false, this means that both operands to the OR are know to be false
+        // as well.
+        //
+        if (!CB->getBoolValue() && Inst->getOpcode() == Instruction::Or) {
+          PropagateEquality(Inst->getOperand(0), CB, RI);
+          PropagateEquality(Inst->getOperand(1), CB, RI);
+        }
 
-      // If we know the value of a FCmp instruction, propagate the information
-      // about the relation into this region as well.
-      //
-      if (FCmpInst *FCI = dyn_cast<FCmpInst>(Inst)) {
-        if (CB->getValue()) {  // If we know the condition is true...
-          // Propagate info about the LHS to the RHS & RHS to LHS
-          PropagateRelation(FCI->getPredicate(), FCI->getOperand(0),
-                            FCI->getOperand(1), RI);
-          PropagateRelation(FCI->getSwappedPredicate(),
-                            FCI->getOperand(1), FCI->getOperand(0), RI);
-
-        } else {               // If we know the condition is false...
-          // We know the opposite of the condition is true...
-          FCmpInst::Predicate C = FCI->getInversePredicate();
-
-          PropagateRelation(C, FCI->getOperand(0), FCI->getOperand(1), RI);
-          PropagateRelation(FCmpInst::getSwappedPredicate(C),
-                            FCI->getOperand(1), FCI->getOperand(0), RI);
+        // If we know that this instruction is a NOT instruction, we know that the
+        // operand is known to be the inverse of whatever the current value is.
+        //
+        if (BinaryOperator *BOp = dyn_cast<BinaryOperator>(Inst))
+          if (BinaryOperator::isNot(BOp))
+            PropagateEquality(BinaryOperator::getNotArgument(BOp),
+                              ConstantInt::get(!CB->getBoolValue()), RI);
+
+        // If we know the value of a FCmp instruction, propagate the information
+        // about the relation into this region as well.
+        //
+        if (FCmpInst *FCI = dyn_cast<FCmpInst>(Inst)) {
+          if (CB->getBoolValue()) {  // If we know the condition is true...
+            // Propagate info about the LHS to the RHS & RHS to LHS
+            PropagateRelation(FCI->getPredicate(), FCI->getOperand(0),
+                              FCI->getOperand(1), RI);
+            PropagateRelation(FCI->getSwappedPredicate(),
+                              FCI->getOperand(1), FCI->getOperand(0), RI);
+
+          } else {               // If we know the condition is false...
+            // We know the opposite of the condition is true...
+            FCmpInst::Predicate C = FCI->getInversePredicate();
+
+            PropagateRelation(C, FCI->getOperand(0), FCI->getOperand(1), RI);
+            PropagateRelation(FCmpInst::getSwappedPredicate(C),
+                              FCI->getOperand(1), FCI->getOperand(0), RI);
+          }
         }
-      }
       
-      // If we know the value of a ICmp instruction, propagate the information
-      // about the relation into this region as well.
-      //
-      if (ICmpInst *ICI = dyn_cast<ICmpInst>(Inst)) {
-        if (CB->getValue()) { // If we know the condition is true...
-          // Propagate info about the LHS to the RHS & RHS to LHS
-          PropagateRelation(ICI->getPredicate(), ICI->getOperand(0),
-                            ICI->getOperand(1), RI);
-          PropagateRelation(ICI->getSwappedPredicate(), ICI->getOperand(1),
-                            ICI->getOperand(1), RI);
-
-        } else {               // If we know the condition is false ...
-          // We know the opposite of the condition is true...
-          ICmpInst::Predicate C = ICI->getInversePredicate();
-
-          PropagateRelation(C, ICI->getOperand(0), ICI->getOperand(1), RI);
-          PropagateRelation(ICmpInst::getSwappedPredicate(C),
-                            ICI->getOperand(1), ICI->getOperand(0), RI);
+        // If we know the value of a ICmp instruction, propagate the information
+        // about the relation into this region as well.
+        //
+        if (ICmpInst *ICI = dyn_cast<ICmpInst>(Inst)) {
+          if (CB->getBoolValue()) { // If we know the condition is true...
+            // Propagate info about the LHS to the RHS & RHS to LHS
+            PropagateRelation(ICI->getPredicate(), ICI->getOperand(0),
+                              ICI->getOperand(1), RI);
+            PropagateRelation(ICI->getSwappedPredicate(), ICI->getOperand(1),
+                              ICI->getOperand(1), RI);
+
+          } else {               // If we know the condition is false ...
+            // We know the opposite of the condition is true...
+            ICmpInst::Predicate C = ICI->getInversePredicate();
+
+            PropagateRelation(C, ICI->getOperand(0), ICI->getOperand(1), RI);
+            PropagateRelation(ICmpInst::getSwappedPredicate(C),
+                              ICI->getOperand(1), ICI->getOperand(0), RI);
+          }
         }
       }
     }
-  }
 
   // Propagate information about Op0 to Op1 & visa versa
   PropagateRelation(ICmpInst::ICMP_EQ, Op0, Op1, RI);
@@ -992,7 +994,7 @@
     // See if we can figure out a result for this instruction...
     Relation::KnownResult Result = getCmpResult(CI, RI);
     if (Result != Relation::Unknown) {
-      PropagateEquality(CI, ConstantBool::get(Result != 0), RI);
+      PropagateEquality(CI, ConstantInt::get(Result != 0), RI);
     }
   }
 }
@@ -1066,7 +1068,7 @@
         DEBUG(cerr << "Replacing icmp with " << Result
                    << " constant: " << *CI);
 
-        CI->replaceAllUsesWith(ConstantBool::get((bool)Result));
+        CI->replaceAllUsesWith(ConstantInt::get((bool)Result));
         // The instruction is now dead, remove it from the program.
         CI->getParent()->getInstList().erase(CI);
         ++NumCmpRemoved;
@@ -1120,7 +1122,7 @@
       if (Constant *Result = ConstantFoldInstruction(CI)) {
         // Wow, this is easy, directly eliminate the ICmpInst.
         DEBUG(cerr << "Replacing cmp with constant fold: " << *CI);
-        return cast<ConstantBool>(Result)->getValue()
+        return cast<ConstantInt>(Result)->getBoolValue()
           ? Relation::KnownTrue : Relation::KnownFalse;
       }
     } else {
@@ -1143,7 +1145,7 @@
     // Op1.  Check to see if we know anything about comparing value with a
     // constant, and if we can use this info to fold the icmp.
     //
-    if (ConstantIntegral *C = dyn_cast<ConstantIntegral>(Op1)) {
+    if (ConstantInt *C = dyn_cast<ConstantInt>(Op1)) {
       // Check to see if we already know the result of this comparison...
       ConstantRange R = ConstantRange(predicate, C);
       ConstantRange Int = R.intersectWith(Op0VI->getBounds(),
@@ -1189,7 +1191,7 @@
   // If this is a relationship with a constant, make sure that this relationship
   // does not contradict properties known about the bounds of the constant.
   //
-  if (ConstantIntegral *C = dyn_cast<ConstantIntegral>(Val))
+  if (ConstantInt *C = dyn_cast<ConstantInt>(Val))
     if (Op >= ICmpInst::FIRST_ICMP_PREDICATE && 
         Op <= ICmpInst::LAST_ICMP_PREDICATE)
       if (ConstantRange(Op, C).intersectWith(VI.getBounds(),
@@ -1247,7 +1249,7 @@
   // If this is a relationship with a constant, make sure that we update the
   // range that is possible for the value to have...
   //
-  if (ConstantIntegral *C = dyn_cast<ConstantIntegral>(Val))
+  if (ConstantInt *C = dyn_cast<ConstantInt>(Val))
     if (Op >= ICmpInst::FIRST_ICMP_PREDICATE && 
         Op <= ICmpInst::LAST_ICMP_PREDICATE)
       VI.getBounds() = ConstantRange(Op, C).intersectWith(VI.getBounds(),


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.588 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.589
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.588	Mon Jan  8 14:17:17 2007
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Thu Jan 11 06:24:14 2007
@@ -302,10 +302,10 @@
     Instruction *FoldPHIArgBinOpIntoPHI(PHINode &PN);
     
     
-    Instruction *OptAndOp(Instruction *Op, ConstantIntegral *OpRHS,
-                          ConstantIntegral *AndRHS, BinaryOperator &TheAnd);
+    Instruction *OptAndOp(Instruction *Op, ConstantInt *OpRHS,
+                          ConstantInt *AndRHS, BinaryOperator &TheAnd);
     
-    Value *FoldLogicalPlusAnd(Value *LHS, Value *RHS, ConstantIntegral *Mask,
+    Value *FoldLogicalPlusAnd(Value *LHS, Value *RHS, ConstantInt *Mask,
                               bool isSub, Instruction &I);
     Instruction *InsertRangeTest(Value *V, Constant *Lo, Constant *Hi,
                                  bool isSigned, bool Inside, Instruction &IB);
@@ -484,7 +484,7 @@
     return BinaryOperator::getNotArgument(V);
 
   // Constants can be considered to be not'ed values...
-  if (ConstantIntegral *C = dyn_cast<ConstantIntegral>(V))
+  if (ConstantInt *C = dyn_cast<ConstantInt>(V))
     return ConstantExpr::getNot(C);
   return 0;
 }
@@ -531,14 +531,6 @@
                                          ConstantInt::get(C->getType(), 1)));
 }
 
-/// GetConstantInType - Return a ConstantInt with the specified type and value.
-///
-static ConstantIntegral *GetConstantInType(const Type *Ty, uint64_t Val) {
-  if (Ty->getTypeID() == Type::BoolTyID)
-    return ConstantBool::get(Val);
-  return ConstantInt::get(Ty, Val);
-}
-
 
 /// ComputeMaskedBits - Determine which of the bits specified in Mask are
 /// known to be either zero or one and return them in the KnownZero/KnownOne
@@ -552,7 +544,7 @@
   // optimized based on the contradictory assumption that it is non-zero.
   // Because instcombine aggressively folds operations with undef args anyway,
   // this won't lose us code quality.
-  if (ConstantIntegral *CI = dyn_cast<ConstantIntegral>(V)) {
+  if (ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
     // We know all of the bits for a constant!
     KnownOne = CI->getZExtValue() & Mask;
     KnownZero = ~KnownOne & Mask;
@@ -763,7 +755,7 @@
 
   // This is producing any bits that are not needed, shrink the RHS.
   uint64_t Val = Demanded & OpC->getZExtValue();
-  I->setOperand(OpNo, GetConstantInType(OpC->getType(), Val));
+  I->setOperand(OpNo, ConstantInt::get(OpC->getType(), Val));
   return true;
 }
 
@@ -824,7 +816,7 @@
 bool InstCombiner::SimplifyDemandedBits(Value *V, uint64_t DemandedMask,
                                         uint64_t &KnownZero, uint64_t &KnownOne,
                                         unsigned Depth) {
-  if (ConstantIntegral *CI = dyn_cast<ConstantIntegral>(V)) {
+  if (ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
     // We know all of the bits for a constant!
     KnownOne = CI->getZExtValue() & DemandedMask;
     KnownZero = ~KnownOne & DemandedMask;
@@ -965,8 +957,8 @@
     //    e.g. (X | C1) ^ C2 --> (X | C1) & ~C2 iff (C1&C2) == C2
     if ((DemandedMask & (KnownZero|KnownOne)) == DemandedMask) { // all known
       if ((KnownOne & KnownOne2) == KnownOne) {
-        Constant *AndC = GetConstantInType(I->getType(), 
-                                           ~KnownOne & DemandedMask);
+        Constant *AndC = ConstantInt::get(I->getType(), 
+                                          ~KnownOne & DemandedMask);
         Instruction *And = 
           BinaryOperator::createAnd(I->getOperand(0), AndC, "tmp");
         InsertNewInstBefore(And, *I);
@@ -1250,7 +1242,7 @@
   // If the client is only demanding bits that we know, return the known
   // constant.
   if ((DemandedMask & (KnownZero|KnownOne)) == DemandedMask)
-    return UpdateValueUsesWith(I, GetConstantInType(I->getType(), KnownOne));
+    return UpdateValueUsesWith(I, ConstantInt::get(I->getType(), KnownOne));
   return false;
 }  
 
@@ -2280,7 +2272,7 @@
       if (ST->isNullValue()) {
         Instruction *CondI = dyn_cast<Instruction>(SI->getOperand(0));
         if (CondI && CondI->getParent() == I.getParent())
-          UpdateValueUsesWith(CondI, ConstantBool::getFalse());
+          UpdateValueUsesWith(CondI, ConstantInt::getFalse());
         else if (I.getParent() != SI->getParent() || SI->hasOneUse())
           I.setOperand(1, SI->getOperand(2));
         else
@@ -2293,7 +2285,7 @@
       if (ST->isNullValue()) {
         Instruction *CondI = dyn_cast<Instruction>(SI->getOperand(0));
         if (CondI && CondI->getParent() == I.getParent())
-          UpdateValueUsesWith(CondI, ConstantBool::getTrue());
+          UpdateValueUsesWith(CondI, ConstantInt::getTrue());
         else if (I.getParent() != SI->getParent() || SI->hasOneUse())
           I.setOperand(1, SI->getOperand(1));
         else
@@ -2513,7 +2505,7 @@
       if (ST->isNullValue()) {
         Instruction *CondI = dyn_cast<Instruction>(SI->getOperand(0));
         if (CondI && CondI->getParent() == I.getParent())
-          UpdateValueUsesWith(CondI, ConstantBool::getFalse());
+          UpdateValueUsesWith(CondI, ConstantInt::getFalse());
         else if (I.getParent() != SI->getParent() || SI->hasOneUse())
           I.setOperand(1, SI->getOperand(2));
         else
@@ -2525,7 +2517,7 @@
       if (ST->isNullValue()) {
         Instruction *CondI = dyn_cast<Instruction>(SI->getOperand(0));
         if (CondI && CondI->getParent() == I.getParent())
-          UpdateValueUsesWith(CondI, ConstantBool::getTrue());
+          UpdateValueUsesWith(CondI, ConstantInt::getTrue());
         else if (I.getParent() != SI->getParent() || SI->hasOneUse())
           I.setOperand(1, SI->getOperand(1));
         else
@@ -2758,7 +2750,7 @@
 static Value *getICmpValue(bool sign, unsigned code, Value *LHS, Value *RHS) {
   switch (code) {
   default: assert(0 && "Illegal ICmp code!");
-  case  0: return ConstantBool::getFalse();
+  case  0: return ConstantInt::getFalse();
   case  1: 
     if (sign)
       return new ICmpInst(ICmpInst::ICMP_SGT, LHS, RHS);
@@ -2781,7 +2773,7 @@
       return new ICmpInst(ICmpInst::ICMP_SLE, LHS, RHS);
     else
       return new ICmpInst(ICmpInst::ICMP_ULE, LHS, RHS);
-  case  7: return ConstantBool::getTrue();
+  case  7: return ConstantInt::getTrue();
   }
 }
 
@@ -2839,8 +2831,8 @@
 // the Op parameter is 'OP', OpRHS is 'C1', and AndRHS is 'C2'.  Op is
 // guaranteed to be either a shift instruction or a binary operator.
 Instruction *InstCombiner::OptAndOp(Instruction *Op,
-                                    ConstantIntegral *OpRHS,
-                                    ConstantIntegral *AndRHS,
+                                    ConstantInt *OpRHS,
+                                    ConstantInt *AndRHS,
                                     BinaryOperator &TheAnd) {
   Value *X = Op->getOperand(0);
   Constant *Together = 0;
@@ -2911,7 +2903,7 @@
     // We know that the AND will not produce any of the bits shifted in, so if
     // the anded constant includes them, clear them now!
     //
-    Constant *AllOne = ConstantIntegral::getAllOnesValue(AndRHS->getType());
+    Constant *AllOne = ConstantInt::getAllOnesValue(AndRHS->getType());
     Constant *ShlMask = ConstantExpr::getShl(AllOne, OpRHS);
     Constant *CI = ConstantExpr::getAnd(AndRHS, ShlMask);
 
@@ -2929,7 +2921,7 @@
     // the anded constant includes them, clear them now!  This only applies to
     // unsigned shifts, because a signed shr may bring in set bits!
     //
-    Constant *AllOne = ConstantIntegral::getAllOnesValue(AndRHS->getType());
+    Constant *AllOne = ConstantInt::getAllOnesValue(AndRHS->getType());
     Constant *ShrMask = ConstantExpr::getLShr(AllOne, OpRHS);
     Constant *CI = ConstantExpr::getAnd(AndRHS, ShrMask);
 
@@ -2946,7 +2938,7 @@
     // See if this is shifting in some sign extension, then masking it out
     // with an and.
     if (Op->hasOneUse()) {
-      Constant *AllOne = ConstantIntegral::getAllOnesValue(AndRHS->getType());
+      Constant *AllOne = ConstantInt::getAllOnesValue(AndRHS->getType());
       Constant *ShrMask = ConstantExpr::getLShr(AllOne, OpRHS);
       Constant *C = ConstantExpr::getAnd(AndRHS, ShrMask);
       if (C == AndRHS) {          // Masking out bits shifted in.
@@ -2972,8 +2964,8 @@
 Instruction *InstCombiner::InsertRangeTest(Value *V, Constant *Lo, Constant *Hi,
                                            bool isSigned, bool Inside, 
                                            Instruction &IB) {
-  assert(cast<ConstantBool>(ConstantExpr::getICmp((isSigned ? 
-            ICmpInst::ICMP_SLE:ICmpInst::ICMP_ULE), Lo, Hi))->getValue() &&
+  assert(cast<ConstantInt>(ConstantExpr::getICmp((isSigned ? 
+            ICmpInst::ICMP_SLE:ICmpInst::ICMP_ULE), Lo, Hi))->getBoolValue() &&
          "Lo is not <= Hi in range emission code!");
     
   if (Inside) {
@@ -2981,7 +2973,7 @@
       return new ICmpInst(ICmpInst::ICMP_NE, V, V);
 
     // V >= Min && V < Hi --> V < Hi
-    if (cast<ConstantIntegral>(Lo)->isMinValue(isSigned)) {
+    if (cast<ConstantInt>(Lo)->isMinValue(isSigned)) {
     ICmpInst::Predicate pred = (isSigned ? 
         ICmpInst::ICMP_SLT : ICmpInst::ICMP_ULT);
       return new ICmpInst(pred, V, Hi);
@@ -3000,7 +2992,7 @@
 
   // V < Min || V >= Hi ->'V > Hi-1'
   Hi = SubOne(cast<ConstantInt>(Hi));
-  if (cast<ConstantIntegral>(Lo)->isMinValue(isSigned)) {
+  if (cast<ConstantInt>(Lo)->isMinValue(isSigned)) {
     ICmpInst::Predicate pred = (isSigned ? 
         ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT);
     return new ICmpInst(pred, V, Hi);
@@ -3018,7 +3010,7 @@
 // any number of 0s on either side.  The 1s are allowed to wrap from LSB to
 // MSB, so 0x000FFF0, 0x0000FFFF, and 0xFF0000FF are all runs.  0x0F0F0000 is
 // not, since all 1s are not contiguous.
-static bool isRunOfOnes(ConstantIntegral *Val, unsigned &MB, unsigned &ME) {
+static bool isRunOfOnes(ConstantInt *Val, unsigned &MB, unsigned &ME) {
   uint64_t V = Val->getZExtValue();
   if (!isShiftedMask_64(V)) return false;
 
@@ -3042,7 +3034,7 @@
 /// return (A +/- B).
 ///
 Value *InstCombiner::FoldLogicalPlusAnd(Value *LHS, Value *RHS,
-                                        ConstantIntegral *Mask, bool isSub,
+                                        ConstantInt *Mask, bool isSub,
                                         Instruction &I) {
   Instruction *LHSI = dyn_cast<Instruction>(LHS);
   if (!LHSI || LHSI->getNumOperands() != 2 ||
@@ -3106,7 +3098,7 @@
                            KnownZero, KnownOne))
     return &I;
   
-  if (ConstantIntegral *AndRHS = dyn_cast<ConstantIntegral>(Op1)) {
+  if (ConstantInt *AndRHS = dyn_cast<ConstantInt>(Op1)) {
     uint64_t AndRHSMask = AndRHS->getZExtValue();
     uint64_t TypeMask = Op0->getType()->getIntegralTypeMask();
     uint64_t NotAndRHS = AndRHSMask^TypeMask;
@@ -3272,7 +3264,7 @@
             ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT;
           Constant *Cmp = ConstantExpr::getICmp(GT, LHSCst, RHSCst);
           ICmpInst *LHS = cast<ICmpInst>(Op0);
-          if (cast<ConstantBool>(Cmp)->getValue()) {
+          if (cast<ConstantInt>(Cmp)->getBoolValue()) {
             std::swap(LHS, RHS);
             std::swap(LHSCst, RHSCst);
             std::swap(LHSCC, RHSCC);
@@ -3294,7 +3286,7 @@
             case ICmpInst::ICMP_EQ:         // (X == 13 & X == 15) -> false
             case ICmpInst::ICMP_UGT:        // (X == 13 & X >  15) -> false
             case ICmpInst::ICMP_SGT:        // (X == 13 & X >  15) -> false
-              return ReplaceInstUsesWith(I, ConstantBool::getFalse());
+              return ReplaceInstUsesWith(I, ConstantInt::getFalse());
             case ICmpInst::ICMP_NE:         // (X == 13 & X != 15) -> X == 13
             case ICmpInst::ICMP_ULT:        // (X == 13 & X <  15) -> X == 13
             case ICmpInst::ICMP_SLT:        // (X == 13 & X <  15) -> X == 13
@@ -3331,7 +3323,7 @@
             default: assert(0 && "Unknown integer condition code!");
             case ICmpInst::ICMP_EQ:         // (X u< 13 & X == 15) -> false
             case ICmpInst::ICMP_UGT:        // (X u< 13 & X u> 15) -> false
-              return ReplaceInstUsesWith(I, ConstantBool::getFalse());
+              return ReplaceInstUsesWith(I, ConstantInt::getFalse());
             case ICmpInst::ICMP_SGT:        // (X u< 13 & X s> 15) -> no change
               break;
             case ICmpInst::ICMP_NE:         // (X u< 13 & X != 15) -> X u< 13
@@ -3346,7 +3338,7 @@
             default: assert(0 && "Unknown integer condition code!");
             case ICmpInst::ICMP_EQ:         // (X s< 13 & X == 15) -> false
             case ICmpInst::ICMP_SGT:        // (X s< 13 & X s> 15) -> false
-              return ReplaceInstUsesWith(I, ConstantBool::getFalse());
+              return ReplaceInstUsesWith(I, ConstantInt::getFalse());
             case ICmpInst::ICMP_UGT:        // (X s< 13 & X u> 15) -> no change
               break;
             case ICmpInst::ICMP_NE:         // (X s< 13 & X != 15) -> X < 13
@@ -3563,7 +3555,7 @@
 
   if (isa<UndefValue>(Op1))
     return ReplaceInstUsesWith(I,                         // X | undef -> -1
-                               ConstantIntegral::getAllOnesValue(I.getType()));
+                               ConstantInt::getAllOnesValue(I.getType()));
 
   // or X, X = X
   if (Op0 == Op1)
@@ -3578,7 +3570,7 @@
     return &I;
   
   // or X, -1 == -1
-  if (ConstantIntegral *RHS = dyn_cast<ConstantIntegral>(Op1)) {
+  if (ConstantInt *RHS = dyn_cast<ConstantInt>(Op1)) {
     ConstantInt *C1 = 0; Value *X = 0;
     // (X & C1) | C2 --> (X | C2) & (C1|C2)
     if (match(Op0, m_And(m_Value(X), m_ConstantInt(C1))) && isOnlyUse(Op0)) {
@@ -3692,7 +3684,7 @@
   if (match(Op0, m_Not(m_Value(A)))) {   // ~A | Op1
     if (A == Op1)   // ~A | A == -1
       return ReplaceInstUsesWith(I,
-                                ConstantIntegral::getAllOnesValue(I.getType()));
+                                ConstantInt::getAllOnesValue(I.getType()));
   } else {
     A = 0;
   }
@@ -3700,7 +3692,7 @@
   if (match(Op1, m_Not(m_Value(B)))) {   // Op0 | ~B
     if (Op0 == B)
       return ReplaceInstUsesWith(I,
-                                ConstantIntegral::getAllOnesValue(I.getType()));
+                                ConstantInt::getAllOnesValue(I.getType()));
 
     // (~A | ~B) == (~(A & B)) - De Morgan's Law
     if (A && isOnlyUse(Op0) && isOnlyUse(Op1)) {
@@ -3731,7 +3723,7 @@
             ICmpInst::ICMP_SGT : ICmpInst::ICMP_UGT;
           Constant *Cmp = ConstantExpr::getICmp(GT, LHSCst, RHSCst);
           ICmpInst *LHS = cast<ICmpInst>(Op0);
-          if (cast<ConstantBool>(Cmp)->getValue()) {
+          if (cast<ConstantInt>(Cmp)->getBoolValue()) {
             std::swap(LHS, RHS);
             std::swap(LHSCst, RHSCst);
             std::swap(LHSCC, RHSCC);
@@ -3779,7 +3771,7 @@
             case ICmpInst::ICMP_NE:          // (X != 13 | X != 15) -> true
             case ICmpInst::ICMP_ULT:         // (X != 13 | X u< 15) -> true
             case ICmpInst::ICMP_SLT:         // (X != 13 | X s< 15) -> true
-              return ReplaceInstUsesWith(I, ConstantBool::getTrue());
+              return ReplaceInstUsesWith(I, ConstantInt::getTrue());
             }
             break;
           case ICmpInst::ICMP_ULT:
@@ -3826,7 +3818,7 @@
               break;
             case ICmpInst::ICMP_NE:         // (X u> 13 | X != 15) -> true
             case ICmpInst::ICMP_ULT:        // (X u> 13 | X u< 15) -> true
-              return ReplaceInstUsesWith(I, ConstantBool::getTrue());
+              return ReplaceInstUsesWith(I, ConstantInt::getTrue());
             case ICmpInst::ICMP_SLT:        // (X u> 13 | X s< 15) -> no change
               break;
             }
@@ -3841,7 +3833,7 @@
               break;
             case ICmpInst::ICMP_NE:         // (X s> 13 | X != 15) -> true
             case ICmpInst::ICMP_SLT:        // (X s> 13 | X s< 15) -> true
-              return ReplaceInstUsesWith(I, ConstantBool::getTrue());
+              return ReplaceInstUsesWith(I, ConstantInt::getTrue());
             case ICmpInst::ICMP_ULT:        // (X s> 13 | X u< 15) -> no change
               break;
             }
@@ -3905,10 +3897,10 @@
                            KnownZero, KnownOne))
     return &I;
 
-  if (ConstantIntegral *RHS = dyn_cast<ConstantIntegral>(Op1)) {
+  if (ConstantInt *RHS = dyn_cast<ConstantInt>(Op1)) {
     // xor (icmp A, B), true = not (icmp A, B) = !icmp A, B
     if (ICmpInst *ICI = dyn_cast<ICmpInst>(Op0))
-      if (RHS == ConstantBool::getTrue() && ICI->hasOneUse())
+      if (RHS == ConstantInt::getTrue() && ICI->hasOneUse())
         return new ICmpInst(ICI->getInversePredicate(),
                             ICI->getOperand(0), ICI->getOperand(1));
 
@@ -3973,12 +3965,12 @@
   if (Value *X = dyn_castNotVal(Op0))   // ~A ^ A == -1
     if (X == Op1)
       return ReplaceInstUsesWith(I,
-                                ConstantIntegral::getAllOnesValue(I.getType()));
+                                ConstantInt::getAllOnesValue(I.getType()));
 
   if (Value *X = dyn_castNotVal(Op1))   // A ^ ~A == -1
     if (X == Op0)
       return ReplaceInstUsesWith(I,
-                                ConstantIntegral::getAllOnesValue(I.getType()));
+                                ConstantInt::getAllOnesValue(I.getType()));
 
   if (BinaryOperator *Op1I = dyn_cast<BinaryOperator>(Op1))
     if (Op1I->getOpcode() == Instruction::Or) {
@@ -4160,7 +4152,7 @@
             EmitIt = false;  // This is indexing into a zero sized array?
           } else if (isa<ConstantInt>(C))
             return ReplaceInstUsesWith(I, // No comparison is needed here.
-                                 ConstantBool::get(Cond == ICmpInst::ICMP_NE));
+                                 ConstantInt::get(Cond == ICmpInst::ICMP_NE));
         }
 
         if (EmitIt) {
@@ -4184,7 +4176,7 @@
         return InVal;
       else
         // No comparison is needed here, all indexes = 0
-        ReplaceInstUsesWith(I, ConstantBool::get(Cond == ICmpInst::ICMP_EQ));
+        ReplaceInstUsesWith(I, ConstantInt::get(Cond == ICmpInst::ICMP_EQ));
     }
 
     // Only lower this if the icmp is the only user of the GEP or if we expect
@@ -4261,7 +4253,7 @@
 
       if (NumDifferences == 0)   // SAME GEP?
         return ReplaceInstUsesWith(I, // No comparison is needed here.
-                                 ConstantBool::get(Cond == ICmpInst::ICMP_EQ));
+                                 ConstantInt::get(Cond == ICmpInst::ICMP_EQ));
       else if (NumDifferences == 1) {
         Value *LHSV = GEPLHS->getOperand(DiffOperand);
         Value *RHSV = GEPRHS->getOperand(DiffOperand);
@@ -4289,7 +4281,7 @@
 
   // fcmp pred X, X
   if (Op0 == Op1)
-    return ReplaceInstUsesWith(I, ConstantBool::get(isTrueWhenEqual(I)));
+    return ReplaceInstUsesWith(I, ConstantInt::get(isTrueWhenEqual(I)));
 
   if (isa<UndefValue>(Op1))                  // fcmp pred X, undef -> undef
     return ReplaceInstUsesWith(I, UndefValue::get(Type::BoolTy));
@@ -4341,7 +4333,7 @@
 
   // icmp X, X
   if (Op0 == Op1)
-    return ReplaceInstUsesWith(I, ConstantBool::get(isTrueWhenEqual(I)));
+    return ReplaceInstUsesWith(I, ConstantInt::get(isTrueWhenEqual(I)));
 
   if (isa<UndefValue>(Op1))                  // X icmp undef -> undef
     return ReplaceInstUsesWith(I, UndefValue::get(Type::BoolTy));
@@ -4351,7 +4343,7 @@
   if (GlobalValue *GV0 = dyn_cast<GlobalValue>(Op0))
     if (GlobalValue *GV1 = dyn_cast<GlobalValue>(Op1))
       if (!GV0->hasExternalWeakLinkage() || !GV1->hasExternalWeakLinkage())
-        return ReplaceInstUsesWith(I, ConstantBool::get(!isTrueWhenEqual(I)));
+        return ReplaceInstUsesWith(I, ConstantInt::get(!isTrueWhenEqual(I)));
 
   // icmp <global/alloca*/null>, <global/alloca*/null> - Global/Stack value
   // addresses never equal each other!  We already know that Op0 != Op1.
@@ -4359,7 +4351,7 @@
        isa<ConstantPointerNull>(Op0)) &&
       (isa<GlobalValue>(Op1) || isa<AllocaInst>(Op1) ||
        isa<ConstantPointerNull>(Op1)))
-    return ReplaceInstUsesWith(I, ConstantBool::get(!isTrueWhenEqual(I)));
+    return ReplaceInstUsesWith(I, ConstantInt::get(!isTrueWhenEqual(I)));
 
   // icmp's with boolean values can always be turned into bitwise operations
   if (Ty == Type::BoolTy) {
@@ -4403,7 +4395,7 @@
     default: break;
     case ICmpInst::ICMP_ULT:                        // A <u MIN -> FALSE
       if (CI->isMinValue(false))
-        return ReplaceInstUsesWith(I, ConstantBool::getFalse());
+        return ReplaceInstUsesWith(I, ConstantInt::getFalse());
       if (CI->isMaxValue(false))                    // A <u MAX -> A != MAX
         return new ICmpInst(ICmpInst::ICMP_NE, Op0,Op1);
       if (isMinValuePlusOne(CI,false))              // A <u MIN+1 -> A == MIN
@@ -4412,7 +4404,7 @@
 
     case ICmpInst::ICMP_SLT:
       if (CI->isMinValue(true))                    // A <s MIN -> FALSE
-        return ReplaceInstUsesWith(I, ConstantBool::getFalse());
+        return ReplaceInstUsesWith(I, ConstantInt::getFalse());
       if (CI->isMaxValue(true))                    // A <s MAX -> A != MAX
         return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1);
       if (isMinValuePlusOne(CI,true))              // A <s MIN+1 -> A == MIN
@@ -4421,7 +4413,7 @@
 
     case ICmpInst::ICMP_UGT:
       if (CI->isMaxValue(false))                  // A >u MAX -> FALSE
-        return ReplaceInstUsesWith(I, ConstantBool::getFalse());
+        return ReplaceInstUsesWith(I, ConstantInt::getFalse());
       if (CI->isMinValue(false))                  // A >u MIN -> A != MIN
         return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1);
       if (isMaxValueMinusOne(CI, false))          // A >u MAX-1 -> A == MAX
@@ -4430,7 +4422,7 @@
 
     case ICmpInst::ICMP_SGT:
       if (CI->isMaxValue(true))                   // A >s MAX -> FALSE
-        return ReplaceInstUsesWith(I, ConstantBool::getFalse());
+        return ReplaceInstUsesWith(I, ConstantInt::getFalse());
       if (CI->isMinValue(true))                   // A >s MIN -> A != MIN
         return new ICmpInst(ICmpInst::ICMP_NE, Op0, Op1);
       if (isMaxValueMinusOne(CI, true))           // A >s MAX-1 -> A == MAX
@@ -4439,7 +4431,7 @@
 
     case ICmpInst::ICMP_ULE:
       if (CI->isMaxValue(false))                 // A <=u MAX -> TRUE
-        return ReplaceInstUsesWith(I, ConstantBool::getTrue());
+        return ReplaceInstUsesWith(I, ConstantInt::getTrue());
       if (CI->isMinValue(false))                 // A <=u MIN -> A == MIN
         return new ICmpInst(ICmpInst::ICMP_EQ, Op0, Op1);
       if (isMaxValueMinusOne(CI,false))          // A <=u MAX-1 -> A != MAX
@@ -4448,7 +4440,7 @@
 
     case ICmpInst::ICMP_SLE:
       if (CI->isMaxValue(true))                  // A <=s MAX -> TRUE
-        return ReplaceInstUsesWith(I, ConstantBool::getTrue());
+        return ReplaceInstUsesWith(I, ConstantInt::getTrue());
       if (CI->isMinValue(true))                  // A <=s MIN -> A == MIN
         return new ICmpInst(ICmpInst::ICMP_EQ, Op0, Op1);
       if (isMaxValueMinusOne(CI,true))           // A <=s MAX-1 -> A != MAX
@@ -4457,7 +4449,7 @@
 
     case ICmpInst::ICMP_UGE:
       if (CI->isMinValue(false))                 // A >=u MIN -> TRUE
-        return ReplaceInstUsesWith(I, ConstantBool::getTrue());
+        return ReplaceInstUsesWith(I, ConstantInt::getTrue());
       if (CI->isMaxValue(false))                 // A >=u MAX -> A == MAX
         return new ICmpInst(ICmpInst::ICMP_EQ, Op0, Op1);
       if (isMinValuePlusOne(CI,false))           // A >=u MIN-1 -> A != MIN
@@ -4466,7 +4458,7 @@
 
     case ICmpInst::ICMP_SGE:
       if (CI->isMinValue(true))                  // A >=s MIN -> TRUE
-        return ReplaceInstUsesWith(I, ConstantBool::getTrue());
+        return ReplaceInstUsesWith(I, ConstantInt::getTrue());
       if (CI->isMaxValue(true))                  // A >=s MAX -> A == MAX
         return new ICmpInst(ICmpInst::ICMP_EQ, Op0, Op1);
       if (isMinValuePlusOne(CI,true))            // A >=s MIN-1 -> A != MIN
@@ -4514,35 +4506,35 @@
       default: assert(0 && "Unknown icmp opcode!");
       case ICmpInst::ICMP_EQ:
         if (UMax < URHSVal || UMin > URHSVal)
-          return ReplaceInstUsesWith(I, ConstantBool::getFalse());
+          return ReplaceInstUsesWith(I, ConstantInt::getFalse());
         break;
       case ICmpInst::ICMP_NE:
         if (UMax < URHSVal || UMin > URHSVal)
-          return ReplaceInstUsesWith(I, ConstantBool::getTrue());
+          return ReplaceInstUsesWith(I, ConstantInt::getTrue());
         break;
       case ICmpInst::ICMP_ULT:
         if (UMax < URHSVal)
-          return ReplaceInstUsesWith(I, ConstantBool::getTrue());
+          return ReplaceInstUsesWith(I, ConstantInt::getTrue());
         if (UMin > URHSVal)
-          return ReplaceInstUsesWith(I, ConstantBool::getFalse());
+          return ReplaceInstUsesWith(I, ConstantInt::getFalse());
         break;
       case ICmpInst::ICMP_UGT:
         if (UMin > URHSVal)
-          return ReplaceInstUsesWith(I, ConstantBool::getTrue());
+          return ReplaceInstUsesWith(I, ConstantInt::getTrue());
         if (UMax < URHSVal)
-          return ReplaceInstUsesWith(I, ConstantBool::getFalse());
+          return ReplaceInstUsesWith(I, ConstantInt::getFalse());
         break;
       case ICmpInst::ICMP_SLT:
         if (SMax < SRHSVal)
-          return ReplaceInstUsesWith(I, ConstantBool::getTrue());
+          return ReplaceInstUsesWith(I, ConstantInt::getTrue());
         if (SMin > SRHSVal)
-          return ReplaceInstUsesWith(I, ConstantBool::getFalse());
+          return ReplaceInstUsesWith(I, ConstantInt::getFalse());
         break;
       case ICmpInst::ICMP_SGT: 
         if (SMin > SRHSVal)
-          return ReplaceInstUsesWith(I, ConstantBool::getTrue());
+          return ReplaceInstUsesWith(I, ConstantInt::getTrue());
         if (SMax < SRHSVal)
-          return ReplaceInstUsesWith(I, ConstantBool::getFalse());
+          return ReplaceInstUsesWith(I, ConstantInt::getFalse());
         break;
       }
     }
@@ -4634,9 +4626,9 @@
                 // As a special case, check to see if this means that the
                 // result is always true or false now.
                 if (I.getPredicate() == ICmpInst::ICMP_EQ)
-                  return ReplaceInstUsesWith(I, ConstantBool::getFalse());
+                  return ReplaceInstUsesWith(I, ConstantInt::getFalse());
                 if (I.getPredicate() == ICmpInst::ICMP_NE)
-                  return ReplaceInstUsesWith(I, ConstantBool::getTrue());
+                  return ReplaceInstUsesWith(I, ConstantInt::getTrue());
               } else {
                 I.setOperand(1, NewCst);
                 Constant *NewAndCST;
@@ -4699,7 +4691,7 @@
               ConstantExpr::getShl(ConstantExpr::getLShr(CI, ShAmt), ShAmt);
             if (Comp != CI) {// Comparing against a bit that we know is zero.
               bool IsICMP_NE = I.getPredicate() == ICmpInst::ICMP_NE;
-              Constant *Cst = ConstantBool::get(IsICMP_NE);
+              Constant *Cst = ConstantInt::get(IsICMP_NE);
               return ReplaceInstUsesWith(I, Cst);
             }
 
@@ -4743,7 +4735,7 @@
 
             if (Comp != CI) {// Comparing against a bit that we know is zero.
               bool IsICMP_NE = I.getPredicate() == ICmpInst::ICMP_NE;
-              Constant *Cst = ConstantBool::get(IsICMP_NE);
+              Constant *Cst = ConstantInt::get(IsICMP_NE);
               return ReplaceInstUsesWith(I, Cst);
             }
 
@@ -4859,7 +4851,7 @@
             default: assert(0 && "Unhandled icmp opcode!");
             case ICmpInst::ICMP_EQ:
               if (LoOverflow && HiOverflow)
-                return ReplaceInstUsesWith(I, ConstantBool::getFalse());
+                return ReplaceInstUsesWith(I, ConstantInt::getFalse());
               else if (HiOverflow)
                 return new ICmpInst(DivIsSigned ?  ICmpInst::ICMP_SGE : 
                                     ICmpInst::ICMP_UGE, X, LoBound);
@@ -4871,7 +4863,7 @@
                                        true, I);
             case ICmpInst::ICMP_NE:
               if (LoOverflow && HiOverflow)
-                return ReplaceInstUsesWith(I, ConstantBool::getTrue());
+                return ReplaceInstUsesWith(I, ConstantInt::getTrue());
               else if (HiOverflow)
                 return new ICmpInst(DivIsSigned ?  ICmpInst::ICMP_SLT : 
                                     ICmpInst::ICMP_ULT, X, LoBound);
@@ -4884,12 +4876,12 @@
             case ICmpInst::ICMP_ULT:
             case ICmpInst::ICMP_SLT:
               if (LoOverflow)
-                return ReplaceInstUsesWith(I, ConstantBool::getFalse());
+                return ReplaceInstUsesWith(I, ConstantInt::getFalse());
               return new ICmpInst(predicate, X, LoBound);
             case ICmpInst::ICMP_UGT:
             case ICmpInst::ICMP_SGT:
               if (HiOverflow)
-                return ReplaceInstUsesWith(I, ConstantBool::getFalse());
+                return ReplaceInstUsesWith(I, ConstantInt::getFalse());
               if (predicate == ICmpInst::ICMP_UGT)
                 return new ICmpInst(ICmpInst::ICMP_UGE, X, HiBound);
               else
@@ -4965,7 +4957,7 @@
           if (Constant *BOC = dyn_cast<Constant>(BO->getOperand(1))) {
             Constant *NotCI = ConstantExpr::getNot(CI);
             if (!ConstantExpr::getAnd(BOC, NotCI)->isNullValue())
-              return ReplaceInstUsesWith(I, ConstantBool::get(isICMP_NE));
+              return ReplaceInstUsesWith(I, ConstantInt::get(isICMP_NE));
           }
           break;
 
@@ -4975,7 +4967,7 @@
             // comparison can never succeed!
             if (!ConstantExpr::getAnd(CI,
                                       ConstantExpr::getNot(BOC))->isNullValue())
-              return ReplaceInstUsesWith(I, ConstantBool::get(isICMP_NE));
+              return ReplaceInstUsesWith(I, ConstantInt::get(isICMP_NE));
 
             // If we have ((X & C) == C), turn it into ((X & C) != 0).
             if (CI == BOC && isOneBitSet(CI))
@@ -5302,9 +5294,9 @@
   // First, handle some easy cases. We know the result cannot be equal at this
   // point so handle the ICI.isEquality() cases
   if (ICI.getPredicate() == ICmpInst::ICMP_EQ)
-    return ReplaceInstUsesWith(ICI, ConstantBool::getFalse());
+    return ReplaceInstUsesWith(ICI, ConstantInt::getFalse());
   if (ICI.getPredicate() == ICmpInst::ICMP_NE)
-    return ReplaceInstUsesWith(ICI, ConstantBool::getTrue());
+    return ReplaceInstUsesWith(ICI, ConstantInt::getTrue());
 
   // Evaluate the comparison for LT (we invert for GT below). LE and GE cases
   // should have been folded away previously and not enter in here.
@@ -5312,20 +5304,20 @@
   if (isSignedCmp) {
     // We're performing a signed comparison.
     if (cast<ConstantInt>(CI)->getSExtValue() < 0)
-      Result = ConstantBool::getFalse();          // X < (small) --> false
+      Result = ConstantInt::getFalse();          // X < (small) --> false
     else
-      Result = ConstantBool::getTrue();           // X < (large) --> true
+      Result = ConstantInt::getTrue();           // X < (large) --> true
   } else {
     // We're performing an unsigned comparison.
     if (isSignedExt) {
       // We're performing an unsigned comp with a sign extended value.
       // This is true if the input is >= 0. [aka >s -1]
-      Constant *NegOne = ConstantIntegral::getAllOnesValue(SrcTy);
+      Constant *NegOne = ConstantInt::getAllOnesValue(SrcTy);
       Result = InsertNewInstBefore(new ICmpInst(ICmpInst::ICMP_SGT, LHSCIOp,
                                    NegOne, ICI.getName()), ICI);
     } else {
       // Unsigned extend & unsigned compare -> always true.
-      Result = ConstantBool::getTrue();
+      Result = ConstantInt::getTrue();
     }
   }
 
@@ -5620,7 +5612,7 @@
     // because it can not turn an arbitrary bit of A into a sign bit.
     if (isUnsignedShift || isLeftShift) {
       // Calculate bitmask for what gets shifted off the edge.
-      Constant *C = ConstantIntegral::getAllOnesValue(I.getType());
+      Constant *C = ConstantInt::getAllOnesValue(I.getType());
       if (isLeftShift)
         C = ConstantExpr::getShl(C, ShiftAmt1C);
       else
@@ -5653,7 +5645,7 @@
                         ConstantInt::get(Type::Int8Ty, ShiftAmt1-ShiftAmt2));
         InsertNewInstBefore(Shift, I);
         
-        C = ConstantIntegral::getAllOnesValue(Shift->getType());
+        C = ConstantInt::getAllOnesValue(Shift->getType());
         C = ConstantExpr::getShl(C, Op1);
         return BinaryOperator::createAnd(Shift, C, Op->getName()+".mask");
       }
@@ -6105,7 +6097,7 @@
     // cast (xor bool X, true) to int  --> xor (cast bool X to int), 1
     if (isa<ZExtInst>(CI) && SrcBitSize == 1 && 
         SrcI->getOpcode() == Instruction::Xor &&
-        Op1 == ConstantBool::getTrue() &&
+        Op1 == ConstantInt::getTrue() &&
         (!Op0->hasOneUse() || !isa<CmpInst>(Op0))) {
       Value *New = InsertOperandCastBefore(Instruction::ZExt, Op0, DestTy, &CI);
       return BinaryOperator::createXor(New, ConstantInt::get(CI.getType(), 1));
@@ -6190,7 +6182,7 @@
           if (Op1CV && (Op1CV != (KnownZero^TypeMask))) {
             // (X&4) == 2 --> false
             // (X&4) != 2 --> true
-            Constant *Res = ConstantBool::get(isNE);
+            Constant *Res = ConstantInt::get(isNE);
             Res = ConstantExpr::getZExt(Res, CI.getType());
             return ReplaceInstUsesWith(CI, Res);
           }
@@ -6560,8 +6552,9 @@
 
   // select true, X, Y  -> X
   // select false, X, Y -> Y
-  if (ConstantBool *C = dyn_cast<ConstantBool>(CondVal))
-    return ReplaceInstUsesWith(SI, C->getValue() ? TrueVal : FalseVal);
+  if (ConstantInt *C = dyn_cast<ConstantInt>(CondVal))
+    if (C->getType() == Type::BoolTy)
+      return ReplaceInstUsesWith(SI, C->getBoolValue() ? TrueVal : FalseVal);
 
   // select C, X, X -> X
   if (TrueVal == FalseVal)
@@ -6578,9 +6571,11 @@
       return ReplaceInstUsesWith(SI, FalseVal);
   }
 
-  if (SI.getType() == Type::BoolTy)
-    if (ConstantBool *C = dyn_cast<ConstantBool>(TrueVal)) {
-      if (C->getValue()) {
+  if (SI.getType() == Type::BoolTy) {
+    ConstantInt *C;
+    if ((C = dyn_cast<ConstantInt>(TrueVal)) && 
+        C->getType() == Type::BoolTy) {
+      if (C->getBoolValue()) {
         // Change: A = select B, true, C --> A = or B, C
         return BinaryOperator::createOr(CondVal, FalseVal);
       } else {
@@ -6590,8 +6585,9 @@
                                              "not."+CondVal->getName()), SI);
         return BinaryOperator::createAnd(NotCond, FalseVal);
       }
-    } else if (ConstantBool *C = dyn_cast<ConstantBool>(FalseVal)) {
-      if (C->getValue() == false) {
+    } else if ((C = dyn_cast<ConstantInt>(FalseVal)) &&
+               C->getType() == Type::BoolTy) {
+      if (C->getBoolValue() == false) {
         // Change: A = select B, C, false --> A = and B, C
         return BinaryOperator::createAnd(CondVal, TrueVal);
       } else {
@@ -6602,6 +6598,7 @@
         return BinaryOperator::createOr(NotCond, TrueVal);
       }
     }
+  }
 
   // Selecting between two integer constants?
   if (ConstantInt *TrueValC = dyn_cast<ConstantInt>(TrueVal))
@@ -7135,7 +7132,7 @@
       Instruction *OldCall = CS.getInstruction();
       // If the call and callee calling conventions don't match, this call must
       // be unreachable, as the call is undefined.
-      new StoreInst(ConstantBool::getTrue(),
+      new StoreInst(ConstantInt::getTrue(),
                     UndefValue::get(PointerType::get(Type::BoolTy)), OldCall);
       if (!OldCall->use_empty())
         OldCall->replaceAllUsesWith(UndefValue::get(OldCall->getType()));
@@ -7148,7 +7145,7 @@
     // This instruction is not reachable, just remove it.  We insert a store to
     // undef so that we know that this code is not reachable, despite the fact
     // that we can't modify the CFG here.
-    new StoreInst(ConstantBool::getTrue(),
+    new StoreInst(ConstantInt::getTrue(),
                   UndefValue::get(PointerType::get(Type::BoolTy)),
                   CS.getInstruction());
 
@@ -7159,7 +7156,7 @@
     if (InvokeInst *II = dyn_cast<InvokeInst>(CS.getInstruction())) {
       // Don't break the CFG, insert a dummy cond branch.
       new BranchInst(II->getNormalDest(), II->getUnwindDest(),
-                     ConstantBool::getTrue(), II);
+                     ConstantInt::getTrue(), II);
     }
     return EraseInstFromFunction(*CS.getInstruction());
   }
@@ -7940,7 +7937,7 @@
   // free undef -> unreachable.
   if (isa<UndefValue>(Op)) {
     // Insert a new store to null because we cannot modify the CFG here.
-    new StoreInst(ConstantBool::getTrue(),
+    new StoreInst(ConstantInt::getTrue(),
                   UndefValue::get(PointerType::get(Type::BoolTy)), &FI);
     return EraseInstFromFunction(FI);
   }
@@ -9051,8 +9048,9 @@
   // only visit the reachable successor.
   TerminatorInst *TI = BB->getTerminator();
   if (BranchInst *BI = dyn_cast<BranchInst>(TI)) {
-    if (BI->isConditional() && isa<ConstantBool>(BI->getCondition())) {
-      bool CondVal = cast<ConstantBool>(BI->getCondition())->getValue();
+    if (BI->isConditional() && isa<ConstantInt>(BI->getCondition()) &&
+        BI->getCondition()->getType() == Type::BoolTy) {
+      bool CondVal = cast<ConstantInt>(BI->getCondition())->getBoolValue();
       AddReachableCodeToWorklist(BI->getSuccessor(!CondVal), Visited, WorkList,
                                  TD);
       return;


Index: llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
diff -u llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.53 llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.54
--- llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.53	Sat Dec 23 00:05:41 2006
+++ llvm/lib/Transforms/Scalar/LoopUnswitch.cpp	Thu Jan 11 06:24:14 2007
@@ -171,7 +171,7 @@
         // See if this, or some part of it, is loop invariant.  If so, we can
         // unswitch on it if we desire.
         Value *LoopCond = FindLIVLoopCondition(BI->getCondition(), L, Changed);
-        if (LoopCond && UnswitchIfProfitable(LoopCond, ConstantBool::getTrue(),
+        if (LoopCond && UnswitchIfProfitable(LoopCond, ConstantInt::getTrue(),
                                              L)) {
           ++NumBranches;
           return true;
@@ -195,7 +195,7 @@
          BBI != E; ++BBI)
       if (SelectInst *SI = dyn_cast<SelectInst>(BBI)) {
         Value *LoopCond = FindLIVLoopCondition(SI->getCondition(), L, Changed);
-        if (LoopCond && UnswitchIfProfitable(LoopCond, ConstantBool::getTrue(),
+        if (LoopCond && UnswitchIfProfitable(LoopCond, ConstantInt::getTrue(),
                                              L)) {
           ++NumSelects;
           return true;
@@ -286,9 +286,9 @@
     // side-effects.  If so, determine the value of Cond that causes it to do
     // this.
     if ((LoopExitBB = isTrivialLoopExitBlock(L, BI->getSuccessor(0)))) {
-      if (Val) *Val = ConstantBool::getTrue();
+      if (Val) *Val = ConstantInt::getTrue();
     } else if ((LoopExitBB = isTrivialLoopExitBlock(L, BI->getSuccessor(1)))) {
-      if (Val) *Val = ConstantBool::getFalse();
+      if (Val) *Val = ConstantInt::getFalse();
     }
   } else if (SwitchInst *SI = dyn_cast<SwitchInst>(HeaderTerm)) {
     // If this isn't a switch on Cond, we can't handle it.
@@ -486,9 +486,9 @@
   // Insert a conditional branch on LIC to the two preheaders.  The original
   // code is the true version and the new code is the false version.
   Value *BranchVal = LIC;
-  if (!isa<ConstantBool>(Val))
+  if (Val->getType() != Type::BoolTy)
     BranchVal = new ICmpInst(ICmpInst::ICMP_EQ, LIC, Val, "tmp", InsertPt);
-  else if (Val != ConstantBool::getTrue())
+  else if (Val != ConstantInt::getTrue())
     // We want to enter the new loop when the condition is true.
     std::swap(TrueDest, FalseDest);
 
@@ -919,12 +919,12 @@
 
   // If we know that LIC == Val, or that LIC == NotVal, just replace uses of LIC
   // in the loop with the appropriate one directly.
-  if (IsEqual || isa<ConstantBool>(Val)) {
+  if (IsEqual || (isa<ConstantInt>(Val) && Val->getType() == Type::BoolTy)) {
     Value *Replacement;
     if (IsEqual)
       Replacement = Val;
     else
-      Replacement = ConstantBool::get(!cast<ConstantBool>(Val)->getValue());
+      Replacement = ConstantInt::get(!cast<ConstantInt>(Val)->getBoolValue());
     
     for (unsigned i = 0, e = Users.size(); i != e; ++i)
       if (Instruction *U = cast<Instruction>(Users[i])) {
@@ -962,7 +962,7 @@
               
               Instruction* OldTerm = Old->getTerminator();
               new BranchInst(Split, SI->getSuccessor(i),
-                             ConstantBool::getTrue(), OldTerm);
+                             ConstantInt::getTrue(), OldTerm);
               
               Old->getTerminator()->eraseFromParent();
               
@@ -1025,32 +1025,36 @@
     // Special case hacks that appear commonly in unswitched code.
     switch (I->getOpcode()) {
     case Instruction::Select:
-      if (ConstantBool *CB = dyn_cast<ConstantBool>(I->getOperand(0))) {
-        ReplaceUsesOfWith(I, I->getOperand(!CB->getValue()+1), Worklist);
+      if (ConstantInt *CB = dyn_cast<ConstantInt>(I->getOperand(0))) {
+        ReplaceUsesOfWith(I, I->getOperand(!CB->getBoolValue()+1), Worklist);
         continue;
       }
       break;
     case Instruction::And:
-      if (isa<ConstantBool>(I->getOperand(0)))   // constant -> RHS
+      if (isa<ConstantInt>(I->getOperand(0)) && 
+          I->getOperand(0)->getType() == Type::BoolTy)   // constant -> RHS
         cast<BinaryOperator>(I)->swapOperands();
-      if (ConstantBool *CB = dyn_cast<ConstantBool>(I->getOperand(1))) {
-        if (CB->getValue())   // X & 1 -> X
-          ReplaceUsesOfWith(I, I->getOperand(0), Worklist);
-        else                  // X & 0 -> 0
-          ReplaceUsesOfWith(I, I->getOperand(1), Worklist);
-        continue;
-      }
+      if (ConstantInt *CB = dyn_cast<ConstantInt>(I->getOperand(1))) 
+        if (CB->getType() == Type::BoolTy) {
+          if (CB->getBoolValue())   // X & 1 -> X
+            ReplaceUsesOfWith(I, I->getOperand(0), Worklist);
+          else                  // X & 0 -> 0
+            ReplaceUsesOfWith(I, I->getOperand(1), Worklist);
+          continue;
+        }
       break;
     case Instruction::Or:
-      if (isa<ConstantBool>(I->getOperand(0)))   // constant -> RHS
+      if (isa<ConstantInt>(I->getOperand(0)) &&
+          I->getOperand(0)->getType() == Type::BoolTy)   // constant -> RHS
         cast<BinaryOperator>(I)->swapOperands();
-      if (ConstantBool *CB = dyn_cast<ConstantBool>(I->getOperand(1))) {
-        if (CB->getValue())   // X | 1 -> 1
-          ReplaceUsesOfWith(I, I->getOperand(1), Worklist);
-        else                  // X | 0 -> X
-          ReplaceUsesOfWith(I, I->getOperand(0), Worklist);
-        continue;
-      }
+      if (ConstantInt *CB = dyn_cast<ConstantInt>(I->getOperand(1)))
+        if (CB->getType() == Type::BoolTy) {
+          if (CB->getBoolValue())   // X | 1 -> 1
+            ReplaceUsesOfWith(I, I->getOperand(1), Worklist);
+          else                  // X | 0 -> X
+            ReplaceUsesOfWith(I, I->getOperand(0), Worklist);
+          continue;
+        }
       break;
     case Instruction::Br: {
       BranchInst *BI = cast<BranchInst>(I);
@@ -1084,14 +1088,14 @@
         LI->removeBlock(Succ);
         Succ->eraseFromParent();
         ++NumSimplify;
-      } else if (ConstantBool *CB = dyn_cast<ConstantBool>(BI->getCondition())){
+      } else if (ConstantInt *CB = dyn_cast<ConstantInt>(BI->getCondition())){
         // Conditional branch.  Turn it into an unconditional branch, then
         // remove dead blocks.
         break;  // FIXME: Enable.
 
         DOUT << "Folded branch: " << *BI;
-        BasicBlock *DeadSucc = BI->getSuccessor(CB->getValue());
-        BasicBlock *LiveSucc = BI->getSuccessor(!CB->getValue());
+        BasicBlock *DeadSucc = BI->getSuccessor(CB->getBoolValue());
+        BasicBlock *LiveSucc = BI->getSuccessor(!CB->getBoolValue());
         DeadSucc->removePredecessor(BI->getParent(), true);
         Worklist.push_back(new BranchInst(LiveSucc, BI));
         BI->eraseFromParent();


Index: llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp
diff -u llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.42 llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.43
--- llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.42	Wed Jan 10 20:38:21 2007
+++ llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp	Thu Jan 11 06:24:14 2007
@@ -357,16 +357,16 @@
 
     std::vector<Node> Nodes;
 
-    std::vector<std::pair<ConstantIntegral *, unsigned> > Constants;
+    std::vector<std::pair<ConstantInt *, unsigned> > Constants;
     void initializeConstant(Constant *C, unsigned index) {
-      ConstantIntegral *CI = dyn_cast<ConstantIntegral>(C);
+      ConstantInt *CI = dyn_cast<ConstantInt>(C);
       if (!CI) return;
 
       // XXX: instead of O(n) calls to addInequality, just find the 2, 3 or 4
       // nodes that are nearest less than or greater than (signed or unsigned).
-      for (std::vector<std::pair<ConstantIntegral *, unsigned> >::iterator
+      for (std::vector<std::pair<ConstantInt *, unsigned> >::iterator
            I = Constants.begin(), E = Constants.end(); I != E; ++I) {
-        ConstantIntegral *Other = I->first;
+        ConstantInt *Other = I->first;
         if (CI->getType() == Other->getType()) {
           unsigned lv = 0;
 
@@ -1046,7 +1046,7 @@
       if (Constant *C1 = dyn_cast<Constant>(V1))
         if (Constant *C2 = dyn_cast<Constant>(V2))
           return ConstantExpr::getCompare(Pred, C1, C2) ==
-                 ConstantBool::getTrue();
+                 ConstantInt::getTrue();
 
       // XXX: this is lousy. If we're passed a Constant, then we might miss
       // some relationships if it isn't in the IG because the relationships
@@ -1100,7 +1100,7 @@
           case Instruction::And: {
             // "and int %a, %b"  EQ -1   then %a EQ -1   and %b EQ -1
             // "and bool %a, %b" EQ true then %a EQ true and %b EQ true
-            ConstantIntegral *CI = ConstantIntegral::getAllOnesValue(Ty);
+            ConstantInt *CI = ConstantInt::getAllOnesValue(Ty);
             if (Canonical == CI) {
               add(CI, Op0, ICmpInst::ICMP_EQ, NewContext);
               add(CI, Op1, ICmpInst::ICMP_EQ, NewContext);
@@ -1127,13 +1127,17 @@
             Value *RHS = Op1;
             if (!isa<Constant>(LHS)) std::swap(LHS, RHS);
 
-            if (ConstantBool *CB = dyn_cast<ConstantBool>(Canonical)) {
-              if (ConstantBool *A = dyn_cast<ConstantBool>(LHS))
-                add(RHS, ConstantBool::get(A->getValue() ^ CB->getValue()),
-                                           ICmpInst::ICMP_EQ, NewContext);
+            ConstantInt *CB, *A;
+            if ((CB = dyn_cast<ConstantInt>(Canonical)) && 
+                CB->getType() == Type::BoolTy) {
+              if ((A = dyn_cast<ConstantInt>(LHS)) &&
+                  A->getType() == Type::BoolTy)
+                add(RHS, ConstantInt::get(A->getBoolValue() ^ 
+                                          CB->getBoolValue()),
+                                          ICmpInst::ICMP_EQ, NewContext);
             }
             if (Canonical == LHS) {
-              if (isa<ConstantIntegral>(Canonical))
+              if (isa<ConstantInt>(Canonical))
                 add(RHS, Constant::getNullValue(Ty), ICmpInst::ICMP_EQ,
                     NewContext);
             } else if (isRelatedBy(LHS, Canonical, ICmpInst::ICMP_NE)) {
@@ -1148,10 +1152,10 @@
         // "icmp ult int %a, int %y" EQ true then %a u< y
         // etc.
 
-        if (Canonical == ConstantBool::getTrue()) {
+        if (Canonical == ConstantInt::getTrue()) {
           add(IC->getOperand(0), IC->getOperand(1), IC->getPredicate(),
               NewContext);
-        } else if (Canonical == ConstantBool::getFalse()) {
+        } else if (Canonical == ConstantInt::getFalse()) {
           add(IC->getOperand(0), IC->getOperand(1),
               ICmpInst::getInversePredicate(IC->getPredicate()), NewContext);
         }
@@ -1167,11 +1171,11 @@
         if (isRelatedBy(True, False, ICmpInst::ICMP_NE)) {
           if (Canonical == IG.canonicalize(True, Top) ||
               isRelatedBy(Canonical, False, ICmpInst::ICMP_NE))
-            add(SI->getCondition(), ConstantBool::getTrue(),
+            add(SI->getCondition(), ConstantInt::getTrue(),
                 ICmpInst::ICMP_EQ, NewContext);
           else if (Canonical == IG.canonicalize(False, Top) ||
                    isRelatedBy(I, True, ICmpInst::ICMP_NE))
-            add(SI->getCondition(), ConstantBool::getFalse(),
+            add(SI->getCondition(), ConstantInt::getFalse(),
                 ICmpInst::ICMP_EQ, NewContext);
         }
       }
@@ -1188,8 +1192,8 @@
         Value *Op0 = IG.canonicalize(BO->getOperand(0), Top);
         Value *Op1 = IG.canonicalize(BO->getOperand(1), Top);
 
-        if (ConstantIntegral *CI0 = dyn_cast<ConstantIntegral>(Op0))
-          if (ConstantIntegral *CI1 = dyn_cast<ConstantIntegral>(Op1)) {
+        if (ConstantInt *CI0 = dyn_cast<ConstantInt>(Op0))
+          if (ConstantInt *CI1 = dyn_cast<ConstantInt>(Op1)) {
             add(BO, ConstantExpr::get(BO->getOpcode(), CI0, CI1),
                 ICmpInst::ICMP_EQ, NewContext);
             return;
@@ -1207,7 +1211,7 @@
             return;
           }
         } else if (BO->getOpcode() == Instruction::And) {
-          Constant *AllOnes = ConstantIntegral::getAllOnesValue(BO->getType());
+          Constant *AllOnes = ConstantInt::getAllOnesValue(BO->getType());
           if (Op0 == AllOnes) {
             add(BO, Op1, ICmpInst::ICMP_EQ, NewContext);
             return;
@@ -1244,8 +1248,9 @@
               Constant *One = NULL;
               if (isa<ConstantInt>(Unknown))
                 One = ConstantInt::get(Ty, 1);
-              else if (isa<ConstantBool>(Unknown))
-                One = ConstantBool::getTrue();
+              else if (isa<ConstantInt>(Unknown) && 
+                       Unknown->getType() == Type::BoolTy)
+                One = ConstantInt::getTrue();
 
               if (One) add(Unknown, One, ICmpInst::ICMP_EQ, NewContext);
               break;
@@ -1264,9 +1269,9 @@
 
         ICmpInst::Predicate Pred = IC->getPredicate();
         if (isRelatedBy(Op0, Op1, Pred)) {
-          add(IC, ConstantBool::getTrue(), ICmpInst::ICMP_EQ, NewContext);
+          add(IC, ConstantInt::getTrue(), ICmpInst::ICMP_EQ, NewContext);
         } else if (isRelatedBy(Op0, Op1, ICmpInst::getInversePredicate(Pred))) {
-          add(IC, ConstantBool::getFalse(), ICmpInst::ICMP_EQ, NewContext);
+          add(IC, ConstantInt::getFalse(), ICmpInst::ICMP_EQ, NewContext);
         }
 
         // TODO: make the predicate more strict, if possible.
@@ -1278,9 +1283,9 @@
         // %b EQ %c then %a EQ %b
 
         Value *Canonical = IG.canonicalize(SI->getCondition(), Top);
-        if (Canonical == ConstantBool::getTrue()) {
+        if (Canonical == ConstantInt::getTrue()) {
           add(SI, SI->getTrueValue(), ICmpInst::ICMP_EQ, NewContext);
-        } else if (Canonical == ConstantBool::getFalse()) {
+        } else if (Canonical == ConstantInt::getFalse()) {
           add(SI, SI->getFalseValue(), ICmpInst::ICMP_EQ, NewContext);
         } else if (IG.canonicalize(SI->getTrueValue(), Top) ==
                    IG.canonicalize(SI->getFalseValue(), Top)) {
@@ -1565,13 +1570,13 @@
       if (Dest == TrueDest) {
         DOUT << "(" << DTNode->getBlock()->getName() << ") true set:\n";
         VRPSolver VRP(IG, UB, PS->Forest, PS->modified, Dest);
-        VRP.add(ConstantBool::getTrue(), Condition, ICmpInst::ICMP_EQ);
+        VRP.add(ConstantInt::getTrue(), Condition, ICmpInst::ICMP_EQ);
         VRP.solve();
         DEBUG(IG.dump());
       } else if (Dest == FalseDest) {
         DOUT << "(" << DTNode->getBlock()->getName() << ") false set:\n";
         VRPSolver VRP(IG, UB, PS->Forest, PS->modified, Dest);
-        VRP.add(ConstantBool::getFalse(), Condition, ICmpInst::ICMP_EQ);
+        VRP.add(ConstantInt::getFalse(), Condition, ICmpInst::ICMP_EQ);
         VRP.solve();
         DEBUG(IG.dump());
       }


Index: llvm/lib/Transforms/Scalar/Reassociate.cpp
diff -u llvm/lib/Transforms/Scalar/Reassociate.cpp:1.70 llvm/lib/Transforms/Scalar/Reassociate.cpp:1.71
--- llvm/lib/Transforms/Scalar/Reassociate.cpp:1.70	Sat Dec 23 00:05:41 2006
+++ llvm/lib/Transforms/Scalar/Reassociate.cpp	Thu Jan 11 06:24:14 2007
@@ -537,7 +537,7 @@
     }
 
   // Check for destructive annihilation due to a constant being used.
-  if (ConstantIntegral *CstVal = dyn_cast<ConstantIntegral>(Ops.back().Op))
+  if (ConstantInt *CstVal = dyn_cast<ConstantInt>(Ops.back().Op))
     switch (Opcode) {
     default: break;
     case Instruction::And:
@@ -591,7 +591,7 @@
             return Constant::getNullValue(X->getType());
           } else if (Opcode == Instruction::Or) {   // ...|X|~X = -1
             ++NumAnnihil;
-            return ConstantIntegral::getAllOnesValue(X->getType());
+            return ConstantInt::getAllOnesValue(X->getType());
           }
         }
       }


Index: llvm/lib/Transforms/Scalar/SCCP.cpp
diff -u llvm/lib/Transforms/Scalar/SCCP.cpp:1.147 llvm/lib/Transforms/Scalar/SCCP.cpp:1.148
--- llvm/lib/Transforms/Scalar/SCCP.cpp:1.147	Wed Jan  3 20:12:40 2007
+++ llvm/lib/Transforms/Scalar/SCCP.cpp	Thu Jan 11 06:24:14 2007
@@ -416,13 +416,14 @@
     } else {
       LatticeVal &BCValue = getValueState(BI->getCondition());
       if (BCValue.isOverdefined() ||
-          (BCValue.isConstant() && !isa<ConstantBool>(BCValue.getConstant()))) {
+          (BCValue.isConstant() && 
+          BCValue.getConstant()->getType() != Type::BoolTy)) {
         // Overdefined condition variables, and branches on unfoldable constant
         // conditions, mean the branch could go either way.
         Succs[0] = Succs[1] = true;
       } else if (BCValue.isConstant()) {
         // Constant condition variables mean the branch can only go a single way
-        Succs[BCValue.getConstant() == ConstantBool::getFalse()] = true;
+        Succs[BCValue.getConstant() == ConstantInt::getFalse()] = true;
       }
     }
   } else if (isa<InvokeInst>(&TI)) {
@@ -476,11 +477,11 @@
         return true;
       } else if (BCValue.isConstant()) {
         // Not branching on an evaluatable constant?
-        if (!isa<ConstantBool>(BCValue.getConstant())) return true;
+        if (BCValue.getConstant()->getType() != Type::BoolTy) return true;
 
         // Constant condition variables mean the branch can only go a single way
         return BI->getSuccessor(BCValue.getConstant() ==
-                                       ConstantBool::getFalse()) == To;
+                                       ConstantInt::getFalse()) == To;
       }
       return false;
     }
@@ -646,10 +647,11 @@
   LatticeVal &CondValue = getValueState(I.getCondition());
   if (CondValue.isUndefined())
     return;
-  if (CondValue.isConstant()) {
-    if (ConstantBool *CondCB = dyn_cast<ConstantBool>(CondValue.getConstant())){
-      mergeInValue(&I, getValueState(CondCB->getValue() ? I.getTrueValue()
-                                                        : I.getFalseValue()));
+  if (CondValue.isConstant() &&
+      CondValue.getConstant()->getType() == Type::BoolTy) {
+    if (ConstantInt *CondCB = dyn_cast<ConstantInt>(CondValue.getConstant())){
+      mergeInValue(&I, getValueState(CondCB->getBoolValue() ? I.getTrueValue()
+                                                          : I.getFalseValue()));
       return;
     }
   }
@@ -712,8 +714,8 @@
               return;      // X and 0 = 0
             }
           } else {
-            if (ConstantIntegral *CI =
-                     dyn_cast<ConstantIntegral>(NonOverdefVal->getConstant()))
+            if (ConstantInt *CI =
+                     dyn_cast<ConstantInt>(NonOverdefVal->getConstant()))
               if (CI->isAllOnesValue()) {
                 markConstant(IV, &I, NonOverdefVal->getConstant());
                 return;    // X or -1 = -1






More information about the llvm-commits mailing list