[llvm-commits] [SignlessTypes] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp LoopStrengthReduce.cpp LowerGC.cpp LowerPacked.cpp ScalarReplAggregates.cpp

Reid Spencer reid at x10sys.com
Wed Oct 18 20:59:01 PDT 2006



Changes in directory llvm/lib/Transforms/Scalar:

InstructionCombining.cpp updated: 1.520 -> 1.520.2.1
LoopStrengthReduce.cpp updated: 1.89 -> 1.89.2.1
LowerGC.cpp updated: 1.13 -> 1.13.2.1
LowerPacked.cpp updated: 1.9 -> 1.9.2.1
ScalarReplAggregates.cpp updated: 1.44 -> 1.44.2.1
---
Log message:

For PR950: http://llvm.org/PR950 :
This commit (on SignlessTypes branch) provides the first Iteration for 
moving LLVM away from Signed types. This patch removes the ConstantSInt
and ConstantUInt classes from Type.h and makes all necessary changes in
LLVM to compensate.


---
Diffs of the changes:  (+301 -264)

 InstructionCombining.cpp |  517 +++++++++++++++++++++++++----------------------
 LoopStrengthReduce.cpp   |    4 
 LowerGC.cpp              |   12 -
 LowerPacked.cpp          |   22 +-
 ScalarReplAggregates.cpp |   10 
 5 files changed, 301 insertions(+), 264 deletions(-)


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.520 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.520.2.1
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.520	Mon Oct 16 18:08:08 2006
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Wed Oct 18 22:57:56 2006
@@ -142,7 +142,7 @@
     Instruction *FoldGEPSetCC(User *GEPLHS, Value *RHS,
                               Instruction::BinaryOps Cond, Instruction &I);
     Instruction *visitShiftInst(ShiftInst &I);
-    Instruction *FoldShiftByConstant(Value *Op0, ConstantUInt *Op1,
+    Instruction *FoldShiftByConstant(Value *Op0, ConstantInt *Op1,
                                      ShiftInst &I);
     Instruction *visitCastInst(CastInst &CI);
     Instruction *FoldSelectOpOp(SelectInst &SI, Instruction *TI,
@@ -576,14 +576,14 @@
 /// GetConstantInType - Return a ConstantInt with the specified type and value.
 ///
 static ConstantIntegral *GetConstantInType(const Type *Ty, uint64_t Val) {
-  if (Ty->isUnsigned())
-    return ConstantUInt::get(Ty, Val);
+  if (Ty->isUnsigned()) 
+    return ConstantInt::get(Ty, Val);
   else if (Ty->getTypeID() == Type::BoolTyID)
     return ConstantBool::get(Val);
   int64_t SVal = Val;
   SVal <<= 64-Ty->getPrimitiveSizeInBits();
   SVal >>= 64-Ty->getPrimitiveSizeInBits();
-  return ConstantSInt::get(Ty, SVal);
+  return ConstantInt::get(Ty, SVal);
 }
 
 
@@ -712,40 +712,42 @@
   }
   case Instruction::Shl:
     // (shl X, C1) & C2 == 0   iff   (X & C2 >>u C1) == 0
-    if (ConstantUInt *SA = dyn_cast<ConstantUInt>(I->getOperand(1))) {
-      Mask >>= SA->getValue();
+    if (ConstantInt *SA = dyn_cast<ConstantInt>(I->getOperand(1))) {
+      uint64_t ShiftAmt = SA->getZExtValue();
+      Mask >>= ShiftAmt;
       ComputeMaskedBits(I->getOperand(0), Mask, KnownZero, KnownOne, Depth+1);
       assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); 
-      KnownZero <<= SA->getValue();
-      KnownOne  <<= SA->getValue();
-      KnownZero |= (1ULL << SA->getValue())-1;  // low bits known zero.
+      KnownZero <<= ShiftAmt;
+      KnownOne  <<= ShiftAmt;
+      KnownZero |= (1ULL << ShiftAmt)-1;  // low bits known zero.
       return;
     }
     break;
   case Instruction::Shr:
     // (ushr X, C1) & C2 == 0   iff  (-1 >> C1) & C2 == 0
-    if (ConstantUInt *SA = dyn_cast<ConstantUInt>(I->getOperand(1))) {
+    if (ConstantInt *SA = dyn_cast<ConstantInt>(I->getOperand(1))) {
       // Compute the new bits that are at the top now.
-      uint64_t HighBits = (1ULL << SA->getValue())-1;
-      HighBits <<= I->getType()->getPrimitiveSizeInBits()-SA->getValue();
+      uint64_t ShiftAmt = SA->getZExtValue();
+      uint64_t HighBits = (1ULL << ShiftAmt)-1;
+      HighBits <<= I->getType()->getPrimitiveSizeInBits()-ShiftAmt;
       
       if (I->getType()->isUnsigned()) {   // Unsigned shift right.
-        Mask <<= SA->getValue();
+        Mask <<= ShiftAmt;
         ComputeMaskedBits(I->getOperand(0), Mask, KnownZero,KnownOne,Depth+1);
         assert((KnownZero & KnownOne) == 0&&"Bits known to be one AND zero?"); 
-        KnownZero >>= SA->getValue();
-        KnownOne  >>= SA->getValue();
+        KnownZero >>= ShiftAmt;
+        KnownOne  >>= ShiftAmt;
         KnownZero |= HighBits;  // high bits known zero.
       } else {
-        Mask <<= SA->getValue();
+        Mask <<= ShiftAmt;
         ComputeMaskedBits(I->getOperand(0), Mask, KnownZero,KnownOne,Depth+1);
         assert((KnownZero & KnownOne) == 0&&"Bits known to be one AND zero?"); 
-        KnownZero >>= SA->getValue();
-        KnownOne  >>= SA->getValue();
+        KnownZero >>= ShiftAmt;
+        KnownOne  >>= ShiftAmt;
         
         // Handle the sign bits.
         uint64_t SignBit = 1ULL << (I->getType()->getPrimitiveSizeInBits()-1);
-        SignBit >>= SA->getValue();  // Adjust to where it is now in the mask.
+        SignBit >>= ShiftAmt;  // Adjust to where it is now in the mask.
         
         if (KnownZero & SignBit) {       // New bits are known zero.
           KnownZero |= HighBits;
@@ -1100,14 +1102,15 @@
     break;
   }
   case Instruction::Shl:
-    if (ConstantUInt *SA = dyn_cast<ConstantUInt>(I->getOperand(1))) {
-      if (SimplifyDemandedBits(I->getOperand(0), DemandedMask >> SA->getValue(), 
+    if (ConstantInt *SA = dyn_cast<ConstantInt>(I->getOperand(1))) {
+      uint64_t ShiftAmt = SA->getZExtValue();
+      if (SimplifyDemandedBits(I->getOperand(0), DemandedMask >> ShiftAmt, 
                                KnownZero, KnownOne, Depth+1))
         return true;
       assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); 
-      KnownZero <<= SA->getValue();
-      KnownOne  <<= SA->getValue();
-      KnownZero |= (1ULL << SA->getValue())-1;  // low bits known zero.
+      KnownZero <<= ShiftAmt;
+      KnownOne  <<= ShiftAmt;
+      KnownZero |= (1ULL << ShiftAmt) - 1;  // low bits known zero.
     }
     break;
   case Instruction::Shr:
@@ -1131,38 +1134,38 @@
       return UpdateValueUsesWith(I, NewVal);
     }    
     
-    if (ConstantUInt *SA = dyn_cast<ConstantUInt>(I->getOperand(1))) {
-      unsigned ShAmt = SA->getValue();
+    if (ConstantInt *SA = dyn_cast<ConstantInt>(I->getOperand(1))) {
+      unsigned ShiftAmt = SA->getZExtValue();
       
       // Compute the new bits that are at the top now.
-      uint64_t HighBits = (1ULL << ShAmt)-1;
-      HighBits <<= I->getType()->getPrimitiveSizeInBits() - ShAmt;
+      uint64_t HighBits = (1ULL << ShiftAmt)-1;
+      HighBits <<= I->getType()->getPrimitiveSizeInBits() - ShiftAmt;
       uint64_t TypeMask = I->getType()->getIntegralTypeMask();
       if (I->getType()->isUnsigned()) {   // Unsigned shift right.
         if (SimplifyDemandedBits(I->getOperand(0),
-                                 (DemandedMask << ShAmt) & TypeMask,
+                                 (DemandedMask << ShiftAmt) & TypeMask,
                                  KnownZero, KnownOne, Depth+1))
           return true;
         assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); 
         KnownZero &= TypeMask;
         KnownOne  &= TypeMask;
-        KnownZero >>= ShAmt;
-        KnownOne  >>= ShAmt;
+        KnownZero >>= ShiftAmt;
+        KnownOne  >>= ShiftAmt;
         KnownZero |= HighBits;  // high bits known zero.
       } else {                            // Signed shift right.
         if (SimplifyDemandedBits(I->getOperand(0),
-                                 (DemandedMask << ShAmt) & TypeMask,
+                                 (DemandedMask << ShiftAmt) & TypeMask,
                                  KnownZero, KnownOne, Depth+1))
           return true;
         assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?"); 
         KnownZero &= TypeMask;
         KnownOne  &= TypeMask;
-        KnownZero >>= SA->getValue();
-        KnownOne  >>= SA->getValue();
+        KnownZero >>= ShiftAmt;
+        KnownOne  >>= ShiftAmt;
         
         // Handle the sign bits.
         uint64_t SignBit = 1ULL << (I->getType()->getPrimitiveSizeInBits()-1);
-        SignBit >>= SA->getValue();  // Adjust to where it is now in the mask.
+        SignBit >>= ShiftAmt;  // Adjust to where it is now in the mask.
         
         // If the input sign bit is known to be zero, or if none of the top bits
         // are demanded, turn this into an unsigned shift right.
@@ -1277,7 +1280,7 @@
   case Instruction::InsertElement: {
     // If this is a variable index, we don't know which element it overwrites.
     // demand exactly the same input as we produce.
-    ConstantUInt *Idx = dyn_cast<ConstantUInt>(I->getOperand(2));
+    ConstantInt *Idx = dyn_cast<ConstantInt>(I->getOperand(2));
     if (Idx == 0) {
       // Note that we can't propagate undef elt info, because we don't know
       // which elt is getting updated.
@@ -1289,7 +1292,7 @@
     
     // If this is inserting an element that isn't demanded, remove this
     // insertelement.
-    unsigned IdxNo = Idx->getValue();
+    unsigned IdxNo = Idx->getZExtValue();
     if (IdxNo >= VWidth || (DemandedElts & (1ULL << IdxNo)) == 0)
       return AddSoonDeadInstToWorklist(*I, 0);
     
@@ -1894,14 +1897,15 @@
       Value *NoopCastedRHS = RemoveNoopCast(Op1);
       if (ShiftInst *SI = dyn_cast<ShiftInst>(NoopCastedRHS))
         if (SI->getOpcode() == Instruction::Shr)
-          if (ConstantUInt *CU = dyn_cast<ConstantUInt>(SI->getOperand(1))) {
+          if (ConstantInt *CU = dyn_cast<ConstantInt>(SI->getOperand(1))) {
             const Type *NewTy;
             if (SI->getType()->isSigned())
               NewTy = SI->getType()->getUnsignedVersion();
             else
               NewTy = SI->getType()->getSignedVersion();
             // Check to see if we are shifting out everything but the sign bit.
-            if (CU->getValue() == SI->getType()->getPrimitiveSizeInBits()-1) {
+            if (CU->getZExtValue() == 
+                SI->getType()->getPrimitiveSizeInBits()-1) {
               // Ok, the transformation is safe.  Insert a cast of the incoming
               // value, then the new shift, then the new cast.
               Instruction *FirstCast = new CastInst(SI->getOperand(0), NewTy,
@@ -1972,8 +1976,8 @@
 
       // 0 - (X sdiv C)  -> (X sdiv -C)
       if (Op1I->getOpcode() == Instruction::Div)
-        if (ConstantSInt *CSI = dyn_cast<ConstantSInt>(Op0))
-          if (CSI->isNullValue())
+        if (ConstantInt *CSI = dyn_cast<ConstantInt>(Op0))
+          if (CSI->getType()->isSigned() && CSI->isNullValue())
             if (Constant *DivRHS = dyn_cast<Constant>(Op1I->getOperand(1)))
               return BinaryOperator::createDiv(Op1I->getOperand(0),
                                                ConstantExpr::getNeg(DivRHS));
@@ -2022,14 +2026,14 @@
     return Opcode == Instruction::SetLT && RHS->isNullValue() ||
            Opcode == Instruction::SetLE && RHS->isAllOnesValue();
   } else {
-    ConstantUInt *RHSC = cast<ConstantUInt>(RHS);
+    ConstantInt *RHSC = cast<ConstantInt>(RHS);
     // True if source is LHS > 127 or LHS >= 128, where the constants depend on
     // the size of the integer type.
     if (Opcode == Instruction::SetGE)
-      return RHSC->getValue() ==
+      return RHSC->getZExtValue() ==
         1ULL << (RHS->getType()->getPrimitiveSizeInBits()-1);
     if (Opcode == Instruction::SetGT)
-      return RHSC->getValue() ==
+      return RHSC->getZExtValue() ==
         (1ULL << (RHS->getType()->getPrimitiveSizeInBits()-1))-1;
   }
   return false;
@@ -2064,7 +2068,7 @@
       if (isPowerOf2_64(Val)) {          // Replace X*(2^C) with X << C
         uint64_t C = Log2_64(Val);
         return new ShiftInst(Instruction::Shl, Op0,
-                             ConstantUInt::get(Type::UByteTy, C));
+                             ConstantInt::get(Type::UByteTy, C));
       }
     } else if (ConstantFP *Op1F = dyn_cast<ConstantFP>(Op1)) {
       if (Op1F->isNullValue())
@@ -2125,7 +2129,7 @@
       if (isa<ConstantInt>(SCIOp1) &&
           isSignBitCheck(SCI->getOpcode(), SCIOp0, cast<ConstantInt>(SCIOp1))) {
         // Shift the X value right to turn it into "all signbits".
-        Constant *Amt = ConstantUInt::get(Type::UByteTy,
+        Constant *Amt = ConstantInt::get(Type::UByteTy,
                                           SCOpTy->getPrimitiveSizeInBits()-1);
         if (SCIOp0->getType()->isUnsigned()) {
           const Type *NewTy = SCIOp0->getType()->getSignedVersion();
@@ -2179,13 +2183,14 @@
 
     // Check to see if this is an unsigned division with an exact power of 2,
     // if so, convert to a right shift.
-    if (ConstantUInt *C = dyn_cast<ConstantUInt>(RHS))
-      if (uint64_t Val = C->getValue())    // Don't break X / 0
-        if (isPowerOf2_64(Val)) {
-          uint64_t C = Log2_64(Val);
-          return new ShiftInst(Instruction::Shr, Op0,
-                               ConstantUInt::get(Type::UByteTy, C));
-        }
+    if (ConstantInt *C = dyn_cast<ConstantInt>(RHS)) 
+      if (C->getType()->isUnsigned())
+        if (uint64_t Val = C->getZExtValue())    // Don't break X / 0
+          if (isPowerOf2_64(Val)) {
+            uint64_t C = Log2_64(Val);
+            return new ShiftInst(Instruction::Shr, Op0,
+                                 ConstantInt::get(Type::UByteTy, C));
+          }
 
     // -X/C -> X/-C
     if (RHS->getType()->isSigned())
@@ -2235,24 +2240,25 @@
 
     // If this is 'udiv X, (Cond ? C1, C2)' where C1&C2 are powers of two,
     // transform this into: '(Cond ? (udiv X, C1) : (udiv X, C2))'.
-    if (ConstantUInt *STO = dyn_cast<ConstantUInt>(SI->getOperand(1)))
-      if (ConstantUInt *SFO = dyn_cast<ConstantUInt>(SI->getOperand(2))) {
-        // STO == 0 and SFO == 0 handled above.
-        uint64_t TVA = STO->getValue(), FVA = SFO->getValue();
-        if (isPowerOf2_64(TVA) && isPowerOf2_64(FVA)) {
-          unsigned TSA = Log2_64(TVA), FSA = Log2_64(FVA);
-          Constant *TC = ConstantUInt::get(Type::UByteTy, TSA);
-          Instruction *TSI = new ShiftInst(Instruction::Shr, Op0,
-                                           TC, SI->getName()+".t");
-          TSI = InsertNewInstBefore(TSI, I);
-
-          Constant *FC = ConstantUInt::get(Type::UByteTy, FSA);
-          Instruction *FSI = new ShiftInst(Instruction::Shr, Op0,
-                                           FC, SI->getName()+".f");
-          FSI = InsertNewInstBefore(FSI, I);
-          return new SelectInst(SI->getOperand(0), TSI, FSI);
+    if (ConstantInt *STO = dyn_cast<ConstantInt>(SI->getOperand(1)))
+      if (ConstantInt *SFO = dyn_cast<ConstantInt>(SI->getOperand(2))) 
+        if (STO->getType()->isUnsigned() && SFO->getType()->isUnsigned()) {
+          // STO == 0 and SFO == 0 handled above.
+          uint64_t TVA = STO->getZExtValue(), FVA = SFO->getZExtValue();
+          if (isPowerOf2_64(TVA) && isPowerOf2_64(FVA)) {
+            unsigned TSA = Log2_64(TVA), FSA = Log2_64(FVA);
+            Constant *TC = ConstantInt::get(Type::UByteTy, TSA);
+            Instruction *TSI = new ShiftInst(Instruction::Shr, Op0,
+                                             TC, SI->getName()+".t");
+            TSI = InsertNewInstBefore(TSI, I);
+
+            Constant *FC = ConstantInt::get(Type::UByteTy, FSA);
+            Instruction *FSI = new ShiftInst(Instruction::Shr, Op0,
+                                             FC, SI->getName()+".f");
+            FSI = InsertNewInstBefore(FSI, I);
+            return new SelectInst(SI->getOperand(0), TSI, FSI);
+          }
         }
-      }
   }
 
   // 0 / X == 0, we don't need to preserve faults!
@@ -2282,13 +2288,14 @@
     if (Instruction *RHSI = dyn_cast<Instruction>(I.getOperand(1))) {
       // Turn A / (C1 << N), where C1 is "1<<C2" into A >> (N+C2) [udiv only].
       if (RHSI->getOpcode() == Instruction::Shl &&
-          isa<ConstantUInt>(RHSI->getOperand(0))) {
-        unsigned C1 = cast<ConstantUInt>(RHSI->getOperand(0))->getRawValue();
+          isa<ConstantInt>(RHSI->getOperand(0)) &&
+          RHSI->getOperand(0)->getType()->isUnsigned()) {
+        uint64_t C1 = cast<ConstantInt>(RHSI->getOperand(0))->getRawValue();
         if (isPowerOf2_64(C1)) {
-          unsigned C2 = Log2_64(C1);
+          uint64_t C2 = Log2_64(C1);
           Value *Add = RHSI->getOperand(1);
           if (C2) {
-            Constant *C2V = ConstantUInt::get(Add->getType(), C2);
+            Constant *C2V = ConstantInt::get(Add->getType(), C2);
             Add = InsertNewInstBefore(BinaryOperator::createAdd(Add, C2V,
                                                                 "tmp"), I);
           }
@@ -2330,7 +2337,7 @@
       unsigned Zeros = CountTrailingZeros_64(RHS->getZExtValue());
       if (Zeros != V->getType()->getPrimitiveSizeInBits())
         return ConstantExpr::getShl(Result, 
-                                    ConstantUInt::get(Type::UByteTy, Zeros));
+                                    ConstantInt::get(Type::UByteTy, Zeros));
     }
   } else if (I->getOpcode() == Instruction::Cast) {
     Value *Op = I->getOperand(0);
@@ -2356,8 +2363,8 @@
   
   if (I.getType()->isSigned()) {
     if (Value *RHSNeg = dyn_castNegVal(Op1))
-      if (!isa<ConstantSInt>(RHSNeg) ||
-          cast<ConstantSInt>(RHSNeg)->getValue() > 0) {
+      if (!isa<ConstantInt>(RHSNeg) || !RHSNeg->getType()->isSigned() ||
+          cast<ConstantInt>(RHSNeg)->getSExtValue() > 0) {
         // X % -Y -> X % Y
         AddUsesToWorkList(I);
         I.setOperand(1, RHSNeg);
@@ -2392,9 +2399,10 @@
 
     // Check to see if this is an unsigned remainder with an exact power of 2,
     // if so, convert to a bitwise and.
-    if (ConstantUInt *C = dyn_cast<ConstantUInt>(RHS))
-      if (isPowerOf2_64(C->getValue()))
-        return BinaryOperator::createAnd(Op0, SubOne(C));
+    if (ConstantInt *C = dyn_cast<ConstantInt>(RHS))
+      if (RHS->getType()->isUnsigned())
+        if (isPowerOf2_64(C->getZExtValue()))
+          return BinaryOperator::createAnd(Op0, SubOne(C));
 
     if (Instruction *Op0I = dyn_cast<Instruction>(Op0)) {
       if (SelectInst *SI = dyn_cast<SelectInst>(Op0I)) {
@@ -2415,8 +2423,9 @@
     // Turn A % (C << N), where C is 2^k, into A & ((C << N)-1) [urem only].
     if (I.getType()->isUnsigned() && 
         RHSI->getOpcode() == Instruction::Shl &&
-        isa<ConstantUInt>(RHSI->getOperand(0))) {
-      unsigned C1 = cast<ConstantUInt>(RHSI->getOperand(0))->getRawValue();
+        isa<ConstantInt>(RHSI->getOperand(0)) && 
+        RHSI->getOperand(0)->getType()->isUnsigned()) {
+      unsigned C1 = cast<ConstantInt>(RHSI->getOperand(0))->getZExtValue();
       if (isPowerOf2_64(C1)) {
         Constant *N1 = ConstantInt::getAllOnesValue(I.getType());
         Value *Add = InsertNewInstBefore(BinaryOperator::createAdd(RHSI, N1,
@@ -2458,18 +2467,21 @@
         }
 
       
-      if (ConstantUInt *STO = dyn_cast<ConstantUInt>(SI->getOperand(1)))
-        if (ConstantUInt *SFO = dyn_cast<ConstantUInt>(SI->getOperand(2))) {
-          // STO == 0 and SFO == 0 handled above.
-          
-          if (isPowerOf2_64(STO->getValue()) && isPowerOf2_64(SFO->getValue())){
-            Value *TrueAnd = InsertNewInstBefore(BinaryOperator::createAnd(Op0,
-                                          SubOne(STO), SI->getName()+".t"), I);
-            Value *FalseAnd = InsertNewInstBefore(BinaryOperator::createAnd(Op0,
-                                          SubOne(SFO), SI->getName()+".f"), I);
-            return new SelectInst(SI->getOperand(0), TrueAnd, FalseAnd);
+      if (ConstantInt *STO = dyn_cast<ConstantInt>(SI->getOperand(1)))
+        if (ConstantInt *SFO = dyn_cast<ConstantInt>(SI->getOperand(2))) 
+          if (STO->getType()->isUnsigned() && SFO->getType()->isUnsigned()) {
+            // STO == 0 and SFO == 0 handled above.
+            if (isPowerOf2_64(STO->getZExtValue()) && 
+                isPowerOf2_64(SFO->getZExtValue())) {
+              Value *TrueAnd = InsertNewInstBefore(
+                BinaryOperator::createAnd(Op0, SubOne(STO), SI->getName()+".t"),
+                  I);
+              Value *FalseAnd = InsertNewInstBefore(
+                BinaryOperator::createAnd(Op0, SubOne(SFO), SI->getName()+".f"),
+                  I);
+              return new SelectInst(SI->getOperand(0), TrueAnd, FalseAnd);
+            }
           }
-        }
     }
   }
   
@@ -2478,30 +2490,26 @@
 
 // isMaxValueMinusOne - return true if this is Max-1
 static bool isMaxValueMinusOne(const ConstantInt *C) {
-  if (const ConstantUInt *CU = dyn_cast<ConstantUInt>(C))
-    return CU->getValue() == C->getType()->getIntegralTypeMask()-1;
-
-  const ConstantSInt *CS = cast<ConstantSInt>(C);
+  if (C->getType()->isUnsigned()) 
+    return C->getZExtValue() == C->getType()->getIntegralTypeMask()-1;
 
   // Calculate 0111111111..11111
   unsigned TypeBits = C->getType()->getPrimitiveSizeInBits();
   int64_t Val = INT64_MAX;             // All ones
   Val >>= 64-TypeBits;                 // Shift out unwanted 1 bits...
-  return CS->getValue() == Val-1;
+  return C->getSExtValue() == Val-1;
 }
 
 // isMinValuePlusOne - return true if this is Min+1
 static bool isMinValuePlusOne(const ConstantInt *C) {
-  if (const ConstantUInt *CU = dyn_cast<ConstantUInt>(C))
-    return CU->getValue() == 1;
-
-  const ConstantSInt *CS = cast<ConstantSInt>(C);
+  if (C->getType()->isUnsigned())
+    return C->getZExtValue() == 1;
 
   // Calculate 1111111111000000000000
   unsigned TypeBits = C->getType()->getPrimitiveSizeInBits();
   int64_t Val = -1;                    // All ones
   Val <<= TypeBits-1;                  // Shift over to the right spot
-  return CS->getValue() == Val+1;
+  return C->getSExtValue() == Val+1;
 }
 
 // isOneBitSet - Return true if there is exactly one bit set in the specified
@@ -2780,7 +2788,9 @@
     return new SetCondInst(Instruction::SetEQ, V, V);
 
   Hi = SubOne(cast<ConstantInt>(Hi));
-  if (cast<ConstantIntegral>(Lo)->isMinValue()) // V < 0 || V >= Hi ->'V > Hi-1'
+
+  // V < 0 || V >= Hi ->'V > Hi-1'
+  if (cast<ConstantIntegral>(Lo)->isMinValue())
     return new SetCondInst(Instruction::SetGT, V, Hi);
 
   // Emit X-Lo > Hi-Lo-1
@@ -3716,7 +3726,7 @@
 }
 
 static bool isPositive(ConstantInt *C) {
-  return cast<ConstantSInt>(C)->getValue() >= 0;
+  return C->getSExtValue() >= 0;
 }
 
 /// AddWithOverflow - Compute Result = In1+In2, returning true if the result
@@ -3726,15 +3736,15 @@
   Result = cast<ConstantInt>(ConstantExpr::getAdd(In1, In2));
 
   if (In1->getType()->isUnsigned())
-    return cast<ConstantUInt>(Result)->getValue() <
-           cast<ConstantUInt>(In1)->getValue();
+    return cast<ConstantInt>(Result)->getZExtValue() <
+           cast<ConstantInt>(In1)->getZExtValue();
   if (isPositive(In1) != isPositive(In2))
     return false;
   if (isPositive(In1))
-    return cast<ConstantSInt>(Result)->getValue() <
-           cast<ConstantSInt>(In1)->getValue();
-  return cast<ConstantSInt>(Result)->getValue() >
-         cast<ConstantSInt>(In1)->getValue();
+    return cast<ConstantInt>(Result)->getSExtValue() <
+           cast<ConstantInt>(In1)->getSExtValue();
+  return cast<ConstantInt>(Result)->getSExtValue() >
+         cast<ConstantInt>(In1)->getSExtValue();
 }
 
 /// EmitGEPOffset - Given a getelementptr instruction/constantexpr, emit the
@@ -3753,7 +3763,7 @@
   for (unsigned i = 1, e = GEP->getNumOperands(); i != e; ++i, ++GTI) {
     Value *Op = GEP->getOperand(i);
     uint64_t Size = TD.getTypeSize(GTI.getIndexedType()) & PtrSizeMask;
-    Constant *Scale = ConstantExpr::getCast(ConstantUInt::get(UIntPtrTy, Size),
+    Constant *Scale = ConstantExpr::getCast(ConstantInt::get(UIntPtrTy, Size),
                                             SIntPtrTy);
     if (Constant *OpC = dyn_cast<Constant>(Op)) {
       if (!OpC->isNullValue()) {
@@ -4139,14 +4149,14 @@
               ConstantInt *NewCST;
               ConstantInt *NewCI;
               if (Cast->getOperand(0)->getType()->isSigned()) {
-                NewCST = ConstantSInt::get(Cast->getOperand(0)->getType(),
+                NewCST = ConstantInt::get(Cast->getOperand(0)->getType(),
                                            AndCST->getZExtValue());
-                NewCI = ConstantSInt::get(Cast->getOperand(0)->getType(),
+                NewCI = ConstantInt::get(Cast->getOperand(0)->getType(),
                                           CI->getZExtValue());
               } else {
-                NewCST = ConstantUInt::get(Cast->getOperand(0)->getType(),
+                NewCST = ConstantInt::get(Cast->getOperand(0)->getType(),
                                            AndCST->getZExtValue());
-                NewCI = ConstantUInt::get(Cast->getOperand(0)->getType(),
+                NewCI = ConstantInt::get(Cast->getOperand(0)->getType(),
                                           CI->getZExtValue());
               }
               Instruction *NewAnd = 
@@ -4172,8 +4182,8 @@
                 Shift = dyn_cast<ShiftInst>(CI->getOperand(0));
           }
 
-          ConstantUInt *ShAmt;
-          ShAmt = Shift ? dyn_cast<ConstantUInt>(Shift->getOperand(1)) : 0;
+          ConstantInt *ShAmt;
+          ShAmt = Shift ? dyn_cast<ConstantInt>(Shift->getOperand(1)) : 0;
           const Type *Ty = Shift ? Shift->getType() : 0;  // Type of the shift.
           const Type *AndTy = AndCST->getType();          // Type of the and.
 
@@ -4185,10 +4195,10 @@
             if (!CanFold) {
               // To test for the bad case of the signed shr, see if any
               // of the bits shifted in could be tested after the mask.
-              int ShAmtVal = Ty->getPrimitiveSizeInBits()-ShAmt->getValue();
+              int ShAmtVal = Ty->getPrimitiveSizeInBits()-ShAmt->getZExtValue();
               if (ShAmtVal < 0) ShAmtVal = 0; // Out of range shift.
 
-              Constant *OShAmt = ConstantUInt::get(Type::UByteTy, ShAmtVal);
+              Constant *OShAmt = ConstantInt::get(Type::UByteTy, ShAmtVal);
               Constant *ShVal =
                 ConstantExpr::getShl(ConstantInt::getAllOnesValue(AndTy), 
                                      OShAmt);
@@ -4277,14 +4287,14 @@
         break;
 
       case Instruction::Shl:         // (setcc (shl X, ShAmt), CI)
-        if (ConstantUInt *ShAmt = dyn_cast<ConstantUInt>(LHSI->getOperand(1))) {
+        if (ConstantInt *ShAmt = dyn_cast<ConstantInt>(LHSI->getOperand(1))) {
           if (I.isEquality()) {
             unsigned TypeBits = CI->getType()->getPrimitiveSizeInBits();
 
             // Check that the shift amount is in range.  If not, don't perform
             // undefined shifts.  When the shift is visited it will be
             // simplified.
-            if (ShAmt->getValue() >= TypeBits)
+            if (ShAmt->getZExtValue() >= TypeBits)
               break;
 
             // If we are comparing against bits always shifted out, the
@@ -4299,14 +4309,14 @@
 
             if (LHSI->hasOneUse()) {
               // Otherwise strength reduce the shift into an and.
-              unsigned ShAmtVal = (unsigned)ShAmt->getValue();
+              unsigned ShAmtVal = (unsigned)ShAmt->getZExtValue();
               uint64_t Val = (1ULL << (TypeBits-ShAmtVal))-1;
 
               Constant *Mask;
               if (CI->getType()->isUnsigned()) {
-                Mask = ConstantUInt::get(CI->getType(), Val);
+                Mask = ConstantInt::get(CI->getType(), Val);
               } else if (ShAmtVal != 0) {
-                Mask = ConstantSInt::get(CI->getType(), Val);
+                Mask = ConstantInt::get(CI->getType(), Val);
               } else {
                 Mask = ConstantInt::getAllOnesValue(CI->getType());
               }
@@ -4323,13 +4333,13 @@
         break;
 
       case Instruction::Shr:         // (setcc (shr X, ShAmt), CI)
-        if (ConstantUInt *ShAmt = dyn_cast<ConstantUInt>(LHSI->getOperand(1))) {
+        if (ConstantInt *ShAmt = dyn_cast<ConstantInt>(LHSI->getOperand(1))) {
           if (I.isEquality()) {
             // Check that the shift amount is in range.  If not, don't perform
             // undefined shifts.  When the shift is visited it will be
             // simplified.
             unsigned TypeBits = CI->getType()->getPrimitiveSizeInBits();
-            if (ShAmt->getValue() >= TypeBits)
+            if (ShAmt->getZExtValue() >= TypeBits)
               break;
 
             // If we are comparing against bits always shifted out, the
@@ -4344,7 +4354,7 @@
             }
 
             if (LHSI->hasOneUse() || CI->isNullValue()) {
-              unsigned ShAmtVal = (unsigned)ShAmt->getValue();
+              unsigned ShAmtVal = (unsigned)ShAmt->getZExtValue();
 
               // Otherwise strength reduce the shift into an and.
               uint64_t Val = ~0ULL;          // All ones.
@@ -4353,9 +4363,9 @@
               Constant *Mask;
               if (CI->getType()->isUnsigned()) {
                 Val &= ~0ULL >> (64-TypeBits);
-                Mask = ConstantUInt::get(CI->getType(), Val);
+                Mask = ConstantInt::get(CI->getType(), Val);
               } else {
-                Mask = ConstantSInt::get(CI->getType(), Val);
+                Mask = ConstantInt::get(CI->getType(), Val);
               }
 
               Instruction *AndI =
@@ -4466,22 +4476,40 @@
     if (I.isEquality()) {
       bool isSetNE = I.getOpcode() == Instruction::SetNE;
 
-      // If the first operand is (and|or|xor) with a constant, and the second
-      // operand is a constant, simplify a bit.
+      // If the first operand is (add|sub|and|or|xor|rem) with a constant, and 
+      // the second operand is a constant, simplify a bit.
       if (BinaryOperator *BO = dyn_cast<BinaryOperator>(Op0)) {
         switch (BO->getOpcode()) {
+#if 0
+        case Instruction::SRem:
+          // If we have a signed (X % (2^c)) == 0, turn it into an unsigned one.
+          if (CI->isNullValue() && isa<ConstantInt>(BO->getOperand(1)) &&
+              BO->hasOneUse()) {
+            int64_t V = cast<ConstantInt>(BO->getOperand(1))->getSExtValue();
+            if (V > 1 && isPowerOf2_64(V)) {
+              Value *NewRem = InsertNewInstBefore(
+                  BinaryOperator::createURem(BO->getOperand(0), 
+                                             BO->getOperand(1),
+                                             BO->getName()), I);
+              return BinaryOperator::create(
+                I.getOpcode(), NewRem, 
+                Constant::getNullValue(NewRem->getType()));
+            }
+          }
+          break;
+#endif
+
         case Instruction::Rem:
           // If we have a signed (X % (2^c)) == 0, turn it into an unsigned one.
-          if (CI->isNullValue() && isa<ConstantSInt>(BO->getOperand(1)) &&
-              BO->hasOneUse() &&
-              cast<ConstantSInt>(BO->getOperand(1))->getValue() > 1) {
-            int64_t V = cast<ConstantSInt>(BO->getOperand(1))->getValue();
-            if (isPowerOf2_64(V)) {
+          if (CI->isNullValue() && isa<ConstantInt>(BO->getOperand(1)) &&
+              BO->hasOneUse() && BO->getOperand(1)->getType()->isSigned()) {
+            int64_t V = cast<ConstantInt>(BO->getOperand(1))->getSExtValue();
+            if (V > 1 && isPowerOf2_64(V)) {
               unsigned L2 = Log2_64(V);
               const Type *UTy = BO->getType()->getUnsignedVersion();
               Value *NewX = InsertNewInstBefore(new CastInst(BO->getOperand(0),
                                                              UTy, "tmp"), I);
-              Constant *RHSCst = ConstantUInt::get(UTy, 1ULL << L2);
+              Constant *RHSCst = ConstantInt::get(UTy, 1ULL << L2);
               Value *NewRem =InsertNewInstBefore(BinaryOperator::createRem(NewX,
                                                     RHSCst, BO->getName()), I);
               return BinaryOperator::create(I.getOpcode(), NewRem,
@@ -4489,7 +4517,6 @@
             }
           }
           break;
-
         case Instruction::Add:
           // Replace ((add A, B) != C) with (A != C-B) if B & C are constants.
           if (ConstantInt *BOp1C = dyn_cast<ConstantInt>(BO->getOperand(1))) {
@@ -4602,21 +4629,21 @@
             if (I.getOpcode() == Instruction::SetLT && CI->isNullValue())
               // X < 0  => x > 127
               return BinaryOperator::createSetGT(CastOp,
-                         ConstantUInt::get(SrcTy, (1ULL << (SrcTySize-1))-1));
+                         ConstantInt::get(SrcTy, (1ULL << (SrcTySize-1))-1));
             else if (I.getOpcode() == Instruction::SetGT &&
-                     cast<ConstantSInt>(CI)->getValue() == -1)
+                     cast<ConstantInt>(CI)->getSExtValue() == -1)
               // X > -1  => x < 128
               return BinaryOperator::createSetLT(CastOp,
-                         ConstantUInt::get(SrcTy, 1ULL << (SrcTySize-1)));
+                         ConstantInt::get(SrcTy, 1ULL << (SrcTySize-1)));
           } else {
-            ConstantUInt *CUI = cast<ConstantUInt>(CI);
+            ConstantInt *CUI = cast<ConstantInt>(CI);
             if (I.getOpcode() == Instruction::SetLT &&
-                CUI->getValue() == 1ULL << (SrcTySize-1))
+                CUI->getZExtValue() == 1ULL << (SrcTySize-1))
               // X < 128 => X > -1
               return BinaryOperator::createSetGT(CastOp,
-                                                 ConstantSInt::get(SrcTy, -1));
+                                                 ConstantInt::get(SrcTy, -1));
             else if (I.getOpcode() == Instruction::SetGT &&
-                     CUI->getValue() == (1ULL << (SrcTySize-1))-1)
+                     CUI->getZExtValue() == (1ULL << (SrcTySize-1))-1)
               // X > 127 => X < 0
               return BinaryOperator::createSetLT(CastOp,
                                                  Constant::getNullValue(SrcTy));
@@ -4800,13 +4827,13 @@
         // We're performing a signed comparison.
         if (isSignSrc) {
           // Signed extend and signed comparison.
-          if (cast<ConstantSInt>(CI)->getValue() < 0) // X < (small) --> false
+          if (cast<ConstantInt>(CI)->getSExtValue() < 0)// X < (small) --> false
             Result = ConstantBool::getFalse();
           else
-            Result = ConstantBool::getTrue();         // X < (large) --> true
+            Result = ConstantBool::getTrue();           // X < (large) --> true
         } else {
           // Unsigned extend and signed comparison.
-          if (cast<ConstantSInt>(CI)->getValue() < 0)
+          if (cast<ConstantInt>(CI)->getSExtValue() < 0)
             Result = ConstantBool::getFalse();
           else
             Result = ConstantBool::getTrue();
@@ -4870,7 +4897,7 @@
 
   // shr int -1, X = -1   (for any arithmetic shift rights of ~0)
   if (!isLeftShift)
-    if (ConstantSInt *CSI = dyn_cast<ConstantSInt>(Op0))
+    if (ConstantInt *CSI = dyn_cast<ConstantInt>(Op0))
       if (CSI->isAllOnesValue())
         return ReplaceInstUsesWith(I, CSI);
 
@@ -4891,13 +4918,14 @@
     }
   }
 
-  if (ConstantUInt *CUI = dyn_cast<ConstantUInt>(Op1))
-    if (Instruction *Res = FoldShiftByConstant(Op0, CUI, I))
-      return Res;
+  if (ConstantInt *CUI = dyn_cast<ConstantInt>(Op1))
+    if (CUI->getType()->isUnsigned())
+      if (Instruction *Res = FoldShiftByConstant(Op0, CUI, I))
+        return Res;
   return 0;
 }
 
-Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantUInt *Op1,
+Instruction *InstCombiner::FoldShiftByConstant(Value *Op0, ConstantInt *Op1,
                                                ShiftInst &I) {
   bool isLeftShift = I.getOpcode() == Instruction::Shl;
   bool isSignedShift = Op0->getType()->isSigned();
@@ -4914,11 +4942,11 @@
   // of a signed value.
   //
   unsigned TypeBits = Op0->getType()->getPrimitiveSizeInBits();
-  if (Op1->getValue() >= TypeBits) {
+  if (Op1->getZExtValue() >= TypeBits) {
     if (isUnsignedShift || isLeftShift)
       return ReplaceInstUsesWith(I, Constant::getNullValue(Op0->getType()));
     else {
-      I.setOperand(1, ConstantUInt::get(Type::UByteTy, TypeBits-1));
+      I.setOperand(1, ConstantInt::get(Type::UByteTy, TypeBits-1));
       return &I;
     }
   }
@@ -5088,7 +5116,7 @@
     }
   }
   
-  if (ShiftOp && isa<ConstantUInt>(ShiftOp->getOperand(1))) {
+  if (ShiftOp && isa<ConstantInt>(ShiftOp->getOperand(1))) {
     // Find the operands and properties of the input shift.  Note that the
     // signedness of the input shift may differ from the current shift if there
     // is a noop cast between the two.
@@ -5096,10 +5124,10 @@
     bool isShiftOfSignedShift = ShiftOp->getType()->isSigned();
     bool isShiftOfUnsignedShift = !isShiftOfSignedShift;
     
-    ConstantUInt *ShiftAmt1C = cast<ConstantUInt>(ShiftOp->getOperand(1));
+    ConstantInt *ShiftAmt1C = cast<ConstantInt>(ShiftOp->getOperand(1));
 
-    unsigned ShiftAmt1 = (unsigned)ShiftAmt1C->getValue();
-    unsigned ShiftAmt2 = (unsigned)Op1->getValue();
+    unsigned ShiftAmt1 = (unsigned)ShiftAmt1C->getZExtValue();
+    unsigned ShiftAmt2 = (unsigned)Op1->getZExtValue();
     
     // Check for (A << c1) << c2   and   (A >> c1) >> c2.
     if (isLeftShift == isShiftOfLeftShift) {
@@ -5117,7 +5145,7 @@
       if (isShiftOfSignedShift != isSignedShift)
         Op = InsertNewInstBefore(new CastInst(Op, I.getType(), "tmp"), I);
       return new ShiftInst(I.getOpcode(), Op,
-                           ConstantUInt::get(Type::UByteTy, Amt));
+                           ConstantInt::get(Type::UByteTy, Amt));
     }
     
     // Check for (A << c1) >> c2 or (A >> c1) << c2.  If we are dealing with
@@ -5144,7 +5172,7 @@
         return ReplaceInstUsesWith(I, Mask);  // (A << c) >> c  === A & c2
       } else if (ShiftAmt1 < ShiftAmt2) {
         return new ShiftInst(I.getOpcode(), Mask,
-                         ConstantUInt::get(Type::UByteTy, ShiftAmt2-ShiftAmt1));
+                         ConstantInt::get(Type::UByteTy, ShiftAmt2-ShiftAmt1));
       } else if (isShiftOfUnsignedShift || isShiftOfLeftShift) {
         if (isShiftOfUnsignedShift && !isShiftOfLeftShift && isSignedShift) {
           // Make sure to emit an unsigned shift right, not a signed one.
@@ -5152,12 +5180,12 @@
                                         Mask->getType()->getUnsignedVersion(),
                                                   Op->getName()), I);
           Mask = new ShiftInst(Instruction::Shr, Mask,
-                         ConstantUInt::get(Type::UByteTy, ShiftAmt1-ShiftAmt2));
+                         ConstantInt::get(Type::UByteTy, ShiftAmt1-ShiftAmt2));
           InsertNewInstBefore(Mask, I);
           return new CastInst(Mask, I.getType());
         } else {
           return new ShiftInst(ShiftOp->getOpcode(), Mask,
-                    ConstantUInt::get(Type::UByteTy, ShiftAmt1-ShiftAmt2));
+                    ConstantInt::get(Type::UByteTy, ShiftAmt1-ShiftAmt2));
         }
       } else {
         // (X >>s C1) << C2  where C1 > C2  === (X >>s (C1-C2)) & mask
@@ -5166,7 +5194,7 @@
                                               Mask->getName()), I);
         Instruction *Shift =
           new ShiftInst(ShiftOp->getOpcode(), Op,
-                        ConstantUInt::get(Type::UByteTy, ShiftAmt1-ShiftAmt2));
+                        ConstantInt::get(Type::UByteTy, ShiftAmt1-ShiftAmt2));
         InsertNewInstBefore(Shift, I);
         
         C = ConstantIntegral::getAllOnesValue(Shift->getType());
@@ -5206,33 +5234,37 @@
 static Value *DecomposeSimpleLinearExpr(Value *Val, unsigned &Scale,
                                         unsigned &Offset) {
   assert(Val->getType() == Type::UIntTy && "Unexpected allocation size type!");
-  if (ConstantUInt *CI = dyn_cast<ConstantUInt>(Val)) {
-    Offset = CI->getValue();
-    Scale  = 1;
-    return ConstantUInt::get(Type::UIntTy, 0);
+  if (ConstantInt *CI = dyn_cast<ConstantInt>(Val)) {
+    if (CI->getType()->isUnsigned()) {
+      Offset = CI->getZExtValue();
+      Scale  = 1;
+      return ConstantInt::get(Type::UIntTy, 0);
+    }
   } else if (Instruction *I = dyn_cast<Instruction>(Val)) {
     if (I->getNumOperands() == 2) {
-      if (ConstantUInt *CUI = dyn_cast<ConstantUInt>(I->getOperand(1))) {
-        if (I->getOpcode() == Instruction::Shl) {
-          // This is a value scaled by '1 << the shift amt'.
-          Scale = 1U << CUI->getValue();
-          Offset = 0;
-          return I->getOperand(0);
-        } else if (I->getOpcode() == Instruction::Mul) {
-          // This value is scaled by 'CUI'.
-          Scale = CUI->getValue();
-          Offset = 0;
-          return I->getOperand(0);
-        } else if (I->getOpcode() == Instruction::Add) {
-          // We have X+C.  Check to see if we really have (X*C2)+C1, where C1 is
-          // divisible by C2.
-          unsigned SubScale;
-          Value *SubVal = DecomposeSimpleLinearExpr(I->getOperand(0), SubScale,
-                                                    Offset);
-          Offset += CUI->getValue();
-          if (SubScale > 1 && (Offset % SubScale == 0)) {
-            Scale = SubScale;
-            return SubVal;
+      if (ConstantInt *CUI = dyn_cast<ConstantInt>(I->getOperand(1))) {
+        if (CUI->getType()->isUnsigned()) {
+          if (I->getOpcode() == Instruction::Shl) {
+            // This is a value scaled by '1 << the shift amt'.
+            Scale = 1U << CUI->getZExtValue();
+            Offset = 0;
+            return I->getOperand(0);
+          } else if (I->getOpcode() == Instruction::Mul) {
+            // This value is scaled by 'CUI'.
+            Scale = CUI->getZExtValue();
+            Offset = 0;
+            return I->getOperand(0);
+          } else if (I->getOpcode() == Instruction::Add) {
+            // We have X+C.  Check to see if we really have (X*C2)+C1, 
+            // where C1 is divisible by C2.
+            unsigned SubScale;
+            Value *SubVal = 
+              DecomposeSimpleLinearExpr(I->getOperand(0), SubScale, Offset);
+            Offset += CUI->getZExtValue();
+            if (SubScale > 1 && (Offset % SubScale == 0)) {
+              Scale = SubScale;
+              return SubVal;
+            }
           }
         }
       }
@@ -5306,9 +5338,12 @@
   if (Scale == 1) {
     Amt = NumElements;
   } else {
-    Amt = ConstantUInt::get(Type::UIntTy, Scale);
-    if (ConstantUInt *CI = dyn_cast<ConstantUInt>(NumElements))
-      Amt = ConstantExpr::getMul(CI, cast<ConstantUInt>(Amt));
+    // If the allocation size is constant, form a constant mul expression
+    Amt = ConstantInt::get(Type::UIntTy, Scale);
+    if (isa<ConstantInt>(NumElements) && NumElements->getType()->isUnsigned())
+      Amt = ConstantExpr::getMul(
+              cast<ConstantInt>(NumElements), cast<ConstantInt>(Amt));
+    // otherwise multiply the amount and the number of elements
     else if (Scale != 1) {
       Instruction *Tmp = BinaryOperator::createMul(Amt, NumElements, "tmp");
       Amt = InsertNewInstBefore(Tmp, AI);
@@ -5316,7 +5351,7 @@
   }
   
   if (unsigned Offset = (AllocElTySize*ArrayOffset)/CastElTySize) {
-    Value *Off = ConstantUInt::get(Type::UIntTy, Offset);
+    Value *Off = ConstantInt::get(Type::UIntTy, Offset);
     Instruction *Tmp = BinaryOperator::createAdd(Amt, Off, "tmp");
     Amt = InsertNewInstBefore(Tmp, AI);
   }
@@ -5452,7 +5487,7 @@
       assert(CSrc->getType() != Type::ULongTy &&
              "Cannot have type bigger than ulong!");
       uint64_t AndValue = CSrc->getType()->getIntegralTypeMask();
-      Constant *AndOp = ConstantUInt::get(A->getType()->getUnsignedVersion(),
+      Constant *AndOp = ConstantInt::get(A->getType()->getUnsignedVersion(),
                                           AndValue);
       AndOp = ConstantExpr::getCast(AndOp, A->getType());
       Instruction *And = BinaryOperator::createAnd(CSrc->getOperand(0), AndOp);
@@ -5580,7 +5615,7 @@
             unsigned SrcBitSize = Src->getType()->getPrimitiveSizeInBits();
             unsigned DestBitSize = CI.getType()->getPrimitiveSizeInBits();
             assert(SrcBitSize < DestBitSize && "Not a zext?");
-            Constant *C = ConstantUInt::get(Type::ULongTy, (1 << SrcBitSize)-1);
+            Constant *C = ConstantInt::get(Type::ULongTy, (1 << SrcBitSize)-1);
             C = ConstantExpr::getCast(C, CI.getType());
             return BinaryOperator::createAnd(Res, C);
           }
@@ -5645,7 +5680,7 @@
         // simplifications.
         if (DestBitSize < SrcBitSize && Src->getType()->isSigned() &&
             isa<ConstantInt>(Op1)) {
-          unsigned ShiftAmt = cast<ConstantUInt>(Op1)->getValue();
+          unsigned ShiftAmt = cast<ConstantInt>(Op1)->getZExtValue();
           if (SrcBitSize > ShiftAmt && SrcBitSize-ShiftAmt >= DestBitSize) {
             // Convert to unsigned.
             Value *N1 = InsertOperandCastBefore(Op0,
@@ -5963,7 +5998,7 @@
               // Now that X is signed, we have to make the all ones value.  Do
               // this by inserting a new SRA.
               unsigned Bits = X->getType()->getPrimitiveSizeInBits();
-              Constant *ShAmt = ConstantUInt::get(Type::UByteTy, Bits-1);
+              Constant *ShAmt = ConstantInt::get(Type::UByteTy, Bits-1);
               Instruction *SRA = new ShiftInst(Instruction::Shr, X,
                                                ShAmt, "ones");
               InsertNewInstBefore(SRA, SI);
@@ -6264,13 +6299,13 @@
       unsigned Alignment2 = GetKnownAlignment(MI->getOperand(2), TD);
       unsigned Align = std::min(Alignment1, Alignment2);
       if (MI->getAlignment()->getRawValue() < Align) {
-        MI->setAlignment(ConstantUInt::get(Type::UIntTy, Align));
+        MI->setAlignment(ConstantInt::get(Type::UIntTy, Align));
         Changed = true;
       }
     } else if (isa<MemSetInst>(MI)) {
       unsigned Alignment = GetKnownAlignment(MI->getDest(), TD);
       if (MI->getAlignment()->getRawValue() < Alignment) {
-        MI->setAlignment(ConstantUInt::get(Type::UIntTy, Alignment));
+        MI->setAlignment(ConstantInt::get(Type::UIntTy, Alignment));
         Changed = true;
       }
     }
@@ -6527,14 +6562,14 @@
   for (unsigned i = 0, e = NumCommonArgs; i != e; ++i, ++AI) {
     const Type *ParamTy = FT->getParamType(i);
     const Type *ActTy = (*AI)->getType();
-    ConstantSInt* c = dyn_cast<ConstantSInt>(*AI);
+    ConstantInt* c = dyn_cast<ConstantInt>(*AI);
     //Either we can cast directly, or we can upconvert the argument
     bool isConvertible = ActTy->isLosslesslyConvertibleTo(ParamTy) ||
       (ParamTy->isIntegral() && ActTy->isIntegral() &&
        ParamTy->isSigned() == ActTy->isSigned() &&
        ParamTy->getPrimitiveSize() >= ActTy->getPrimitiveSize()) ||
       (c && ParamTy->getPrimitiveSize() >= ActTy->getPrimitiveSize() &&
-       c->getValue() > 0);
+       c->getSExtValue() > 0);
     if (Callee->isExternal() && !isConvertible) return false;
   }
 
@@ -6859,11 +6894,12 @@
 
       // If this is a constant idx, make sure to canonicalize it to be a signed
       // operand, otherwise CSE and other optimizations are pessimized.
-      if (ConstantUInt *CUI = dyn_cast<ConstantUInt>(Op)) {
-        GEP.setOperand(i, ConstantExpr::getCast(CUI,
-                                          CUI->getType()->getSignedVersion()));
-        MadeChange = true;
-      }
+      if (ConstantInt *CUI = dyn_cast<ConstantInt>(Op))
+        if (CUI->getType()->isUnsigned()) {
+          GEP.setOperand(i, 
+            ConstantExpr::getCast(CUI, CUI->getType()->getSignedVersion()));
+          MadeChange = true;
+        }
     }
   if (MadeChange) return &GEP;
 
@@ -7034,11 +7070,12 @@
         } else if (Instruction *Inst =dyn_cast<Instruction>(GEP.getOperand(1))){
           if (Inst->getOpcode() == Instruction::Shl &&
               isa<ConstantInt>(Inst->getOperand(1))) {
-            unsigned ShAmt =cast<ConstantUInt>(Inst->getOperand(1))->getValue();
+            unsigned ShAmt =
+              cast<ConstantInt>(Inst->getOperand(1))->getZExtValue();
             if (Inst->getType()->isSigned())
-              Scale = ConstantSInt::get(Inst->getType(), 1ULL << ShAmt);
+              Scale = ConstantInt::get(Inst->getType(), 1ULL << ShAmt);
             else
-              Scale = ConstantUInt::get(Inst->getType(), 1ULL << ShAmt);
+              Scale = ConstantInt::get(Inst->getType(), 1ULL << ShAmt);
             NewIdx = Inst->getOperand(0);
           } else if (Inst->getOpcode() == Instruction::Mul &&
                      isa<ConstantInt>(Inst->getOperand(1))) {
@@ -7050,12 +7087,8 @@
         // If the index will be to exactly the right offset with the scale taken
         // out, perform the transformation.
         if (Scale && Scale->getRawValue() % ArrayEltSize == 0) {
-          if (ConstantSInt *C = dyn_cast<ConstantSInt>(Scale))
-            Scale = ConstantSInt::get(C->getType(),
-                                      (int64_t)C->getRawValue() / 
-                                      (int64_t)ArrayEltSize);
-          else
-            Scale = ConstantUInt::get(Scale->getType(),
+          if (ConstantInt *C = dyn_cast<ConstantInt>(Scale))
+            Scale = ConstantInt::get(Scale->getType(),
                                       Scale->getRawValue() / ArrayEltSize);
           if (Scale->getRawValue() != 1) {
             Constant *C = ConstantExpr::getCast(Scale, NewIdx->getType());
@@ -7080,8 +7113,9 @@
 Instruction *InstCombiner::visitAllocationInst(AllocationInst &AI) {
   // Convert: malloc Ty, C - where C is a constant != 1 into: malloc [C x Ty], 1
   if (AI.isArrayAllocation())    // Check C != 1
-    if (const ConstantUInt *C = dyn_cast<ConstantUInt>(AI.getArraySize())) {
-      const Type *NewTy = ArrayType::get(AI.getAllocatedType(), C->getValue());
+    if (const ConstantInt *C = dyn_cast<ConstantInt>(AI.getArraySize())) {
+      const Type *NewTy = 
+        ArrayType::get(AI.getAllocatedType(), C->getZExtValue());
       AllocationInst *New = 0;
 
       // Create and insert the replacement instruction...
@@ -7673,7 +7707,7 @@
     if (isa<UndefValue>(CP->getOperand(i)))
       Result.push_back(NElts*2);  // undef -> 8
     else
-      Result.push_back(cast<ConstantUInt>(CP->getOperand(i))->getValue());
+      Result.push_back(cast<ConstantInt>(CP->getOperand(i))->getZExtValue());
   return Result;
 }
 
@@ -7695,12 +7729,14 @@
     return CP->getOperand(EltNo);
   else if (InsertElementInst *III = dyn_cast<InsertElementInst>(V)) {
     // If this is an insert to a variable element, we don't know what it is.
-    if (!isa<ConstantUInt>(III->getOperand(2))) return 0;
-    unsigned IIElt = cast<ConstantUInt>(III->getOperand(2))->getValue();
+    if (!isa<ConstantInt>(III->getOperand(2))) 
+      return 0;
+    unsigned IIElt = cast<ConstantInt>(III->getOperand(2))->getZExtValue();
     
     // If this is an insert to the element we are looking for, return the
     // inserted value.
-    if (EltNo == IIElt) return III->getOperand(1);
+    if (EltNo == IIElt) 
+      return III->getOperand(1);
     
     // Otherwise, the insertelement doesn't modify the value, recurse on its
     // vector input.
@@ -7744,21 +7780,22 @@
   
   // If extracting a specified index from the vector, see if we can recursively
   // find a previously computed scalar that was inserted into the vector.
-  if (ConstantUInt *IdxC = dyn_cast<ConstantUInt>(EI.getOperand(1))) {
+  if (ConstantInt *IdxC = dyn_cast<ConstantInt>(EI.getOperand(1))) {
     // This instruction only demands the single element from the input vector.
     // If the input vector has a single use, simplify it based on this use
     // property.
+    uint64_t IndexVal = IdxC->getZExtValue();
     if (EI.getOperand(0)->hasOneUse()) {
       uint64_t UndefElts;
       if (Value *V = SimplifyDemandedVectorElts(EI.getOperand(0),
-                                                1 << IdxC->getValue(),
+                                                1 << IndexVal,
                                                 UndefElts)) {
         EI.setOperand(0, V);
         return &EI;
       }
     }
     
-    if (Value *Elt = FindScalarElement(EI.getOperand(0), IdxC->getValue()))
+    if (Value *Elt = FindScalarElement(EI.getOperand(0), IndexVal))
       return ReplaceInstUsesWith(EI, Elt);
   }
   
@@ -7804,8 +7841,8 @@
     } else if (ShuffleVectorInst *SVI = dyn_cast<ShuffleVectorInst>(I)) {
       // If this is extracting an element from a shufflevector, figure out where
       // it came from and extract from the appropriate input element instead.
-      if (ConstantUInt *Elt = dyn_cast<ConstantUInt>(EI.getOperand(1))) {
-        unsigned SrcIdx = getShuffleMask(SVI)[Elt->getValue()];
+      if (ConstantInt *Elt = dyn_cast<ConstantInt>(EI.getOperand(1))) {
+        unsigned SrcIdx = getShuffleMask(SVI)[Elt->getZExtValue()];
         Value *Src;
         if (SrcIdx < SVI->getType()->getNumElements())
           Src = SVI->getOperand(0);
@@ -7836,11 +7873,11 @@
     return true;
   } else if (V == LHS) {
     for (unsigned i = 0; i != NumElts; ++i)
-      Mask.push_back(ConstantUInt::get(Type::UIntTy, i));
+      Mask.push_back(ConstantInt::get(Type::UIntTy, i));
     return true;
   } else if (V == RHS) {
     for (unsigned i = 0; i != NumElts; ++i)
-      Mask.push_back(ConstantUInt::get(Type::UIntTy, i+NumElts));
+      Mask.push_back(ConstantInt::get(Type::UIntTy, i+NumElts));
     return true;
   } else if (InsertElementInst *IEI = dyn_cast<InsertElementInst>(V)) {
     // If this is an insert of an extract from some other vector, include it.
@@ -7874,11 +7911,11 @@
             // If so, update the mask to reflect the inserted value.
             if (EI->getOperand(0) == LHS) {
               Mask[InsertedIdx & (NumElts-1)] = 
-                 ConstantUInt::get(Type::UIntTy, ExtractedIdx);
+                 ConstantInt::get(Type::UIntTy, ExtractedIdx);
             } else {
               assert(EI->getOperand(0) == RHS);
               Mask[InsertedIdx & (NumElts-1)] = 
-                ConstantUInt::get(Type::UIntTy, ExtractedIdx+NumElts);
+                ConstantInt::get(Type::UIntTy, ExtractedIdx+NumElts);
               
             }
             return true;
@@ -7906,7 +7943,7 @@
     Mask.assign(NumElts, UndefValue::get(Type::UIntTy));
     return V;
   } else if (isa<ConstantAggregateZero>(V)) {
-    Mask.assign(NumElts, ConstantUInt::get(Type::UIntTy, 0));
+    Mask.assign(NumElts, ConstantInt::get(Type::UIntTy, 0));
     return V;
   } else if (InsertElementInst *IEI = dyn_cast<InsertElementInst>(V)) {
     // If this is an insert of an extract from some other vector, include it.
@@ -7927,7 +7964,7 @@
           RHS = EI->getOperand(0);
           Value *V = CollectShuffleElements(VecOp, Mask, RHS);
           Mask[InsertedIdx & (NumElts-1)] = 
-            ConstantUInt::get(Type::UIntTy, NumElts+ExtractedIdx);
+            ConstantInt::get(Type::UIntTy, NumElts+ExtractedIdx);
           return V;
         }
         
@@ -7936,7 +7973,7 @@
           // Everything but the extracted element is replaced with the RHS.
           for (unsigned i = 0; i != NumElts; ++i) {
             if (i != InsertedIdx)
-              Mask[i] = ConstantUInt::get(Type::UIntTy, NumElts+i);
+              Mask[i] = ConstantInt::get(Type::UIntTy, NumElts+i);
           }
           return V;
         }
@@ -7953,7 +7990,7 @@
   
   // Otherwise, can't do anything fancy.  Return an identity vector.
   for (unsigned i = 0; i != NumElts; ++i)
-    Mask.push_back(ConstantUInt::get(Type::UIntTy, i));
+    Mask.push_back(ConstantInt::get(Type::UIntTy, i));
   return V;
 }
 
@@ -7995,10 +8032,10 @@
           Mask.assign(NumVectorElts, UndefValue::get(Type::UIntTy));
         else {
           assert(isa<ConstantAggregateZero>(VecOp) && "Unknown thing");
-          Mask.assign(NumVectorElts, ConstantUInt::get(Type::UIntTy,
+          Mask.assign(NumVectorElts, ConstantInt::get(Type::UIntTy,
                                                        NumVectorElts));
         } 
-        Mask[InsertedIdx] = ConstantUInt::get(Type::UIntTy, ExtractedIdx);
+        Mask[InsertedIdx] = ConstantInt::get(Type::UIntTy, ExtractedIdx);
         return new ShuffleVectorInst(EI->getOperand(0), VecOp,
                                      ConstantPacked::get(Mask));
       }
@@ -8053,7 +8090,7 @@
           Mask[i] = 2*e;     // Turn into undef.
         else
           Mask[i] &= (e-1);  // Force to LHS.
-        Elts.push_back(ConstantUInt::get(Type::UIntTy, Mask[i]));
+        Elts.push_back(ConstantInt::get(Type::UIntTy, Mask[i]));
       }
     }
     SVI.setOperand(0, SVI.getOperand(1));
@@ -8108,7 +8145,7 @@
           if (NewMask[i] >= e*2) {
             Elts.push_back(UndefValue::get(Type::UIntTy));
           } else {
-            Elts.push_back(ConstantUInt::get(Type::UIntTy, NewMask[i]));
+            Elts.push_back(ConstantInt::get(Type::UIntTy, NewMask[i]));
           }
         }
         return new ShuffleVectorInst(LHSSVI->getOperand(0),
@@ -8178,7 +8215,7 @@
     if (isFoldableGEP) {
       std::vector<Value*> Ops(CE->op_begin()+1, CE->op_end());
       uint64_t Offset = TD->getIndexedOffset(Ptr->getType(), Ops);
-      Constant *C = ConstantUInt::get(Type::ULongTy, Offset);
+      Constant *C = ConstantInt::get(Type::ULongTy, Offset);
       C = ConstantExpr::getCast(C, TD->getIntPtrType());
       return ConstantExpr::getCast(C, CE->getType());
     }


Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
diff -u llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.89 llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.89.2.1
--- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.89	Sun Aug 27 17:42:52 2006
+++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp	Wed Oct 18 22:57:56 2006
@@ -264,7 +264,7 @@
     // operand.
     if (const StructType *STy = dyn_cast<StructType>(*GTI)) {
       const StructLayout *SL = TD->getStructLayout(STy);
-      unsigned Idx = cast<ConstantUInt>(GEP->getOperand(i))->getValue();
+      unsigned Idx = cast<ConstantInt>(GEP->getOperand(i))->getZExtValue();
       uint64_t Offset = SL->MemberOffsets[Idx];
       GEPVal = SCEVAddExpr::get(GEPVal,
                                 SCEVUnknown::getIntegerSCEV(Offset, UIntPtrTy));
@@ -275,7 +275,7 @@
       uint64_t TypeSize = TD->getTypeSize(GTI.getIndexedType());
       if (TypeSize != 1)
         Idx = SCEVMulExpr::get(Idx,
-                               SCEVConstant::get(ConstantUInt::get(UIntPtrTy,
+                               SCEVConstant::get(ConstantInt::get(UIntPtrTy,
                                                                    TypeSize)));
       GEPVal = SCEVAddExpr::get(GEPVal, Idx);
     }


Index: llvm/lib/Transforms/Scalar/LowerGC.cpp
diff -u llvm/lib/Transforms/Scalar/LowerGC.cpp:1.13 llvm/lib/Transforms/Scalar/LowerGC.cpp:1.13.2.1
--- llvm/lib/Transforms/Scalar/LowerGC.cpp:1.13	Sun Aug 27 17:42:52 2006
+++ llvm/lib/Transforms/Scalar/LowerGC.cpp	Wed Oct 18 22:57:56 2006
@@ -222,8 +222,8 @@
   BasicBlock::iterator IP = AI;
   while (isa<AllocaInst>(IP)) ++IP;
 
-  Constant *Zero = ConstantUInt::get(Type::UIntTy, 0);
-  Constant *One  = ConstantUInt::get(Type::UIntTy, 1);
+  Constant *Zero = ConstantInt::get(Type::UIntTy, 0);
+  Constant *One  = ConstantInt::get(Type::UIntTy, 1);
 
   // Get a pointer to the prev pointer.
   std::vector<Value*> Par;
@@ -237,11 +237,11 @@
   new StoreInst(PrevPtr, PrevPtrPtr, IP);
 
   // Set the number of elements in this record.
-  Par[1] = ConstantUInt::get(Type::UIntTy, 1);
+  Par[1] = ConstantInt::get(Type::UIntTy, 1);
   Value *NumEltsPtr = new GetElementPtrInst(AI, Par, "numeltsptr", IP);
-  new StoreInst(ConstantUInt::get(Type::UIntTy, GCRoots.size()), NumEltsPtr,IP);
+  new StoreInst(ConstantInt::get(Type::UIntTy, GCRoots.size()), NumEltsPtr,IP);
 
-  Par[1] = ConstantUInt::get(Type::UIntTy, 2);
+  Par[1] = ConstantInt::get(Type::UIntTy, 2);
   Par.resize(4);
 
   const PointerType *PtrLocTy =
@@ -251,7 +251,7 @@
   // Initialize all of the gcroot records now, and eliminate them as we go.
   for (unsigned i = 0, e = GCRoots.size(); i != e; ++i) {
     // Initialize the meta-data pointer.
-    Par[2] = ConstantUInt::get(Type::UIntTy, i);
+    Par[2] = ConstantInt::get(Type::UIntTy, i);
     Par[3] = One;
     Value *MetaDataPtr = new GetElementPtrInst(AI, Par, "MetaDataPtr", IP);
     assert(isa<Constant>(GCRoots[i]->getOperand(2)) && "Must be a constant");


Index: llvm/lib/Transforms/Scalar/LowerPacked.cpp
diff -u llvm/lib/Transforms/Scalar/LowerPacked.cpp:1.9 llvm/lib/Transforms/Scalar/LowerPacked.cpp:1.9.2.1
--- llvm/lib/Transforms/Scalar/LowerPacked.cpp:1.9	Sun Aug 27 17:42:52 2006
+++ llvm/lib/Transforms/Scalar/LowerPacked.cpp	Wed Oct 18 22:57:56 2006
@@ -209,7 +209,7 @@
    if (const PackedType* PKT = dyn_cast<PackedType>(LI.getType())) {
        // Initialization, Idx is needed for getelementptr needed later
        std::vector<Value*> Idx(2);
-       Idx[0] = ConstantUInt::get(Type::UIntTy,0);
+       Idx[0] = ConstantInt::get(Type::UIntTy,0);
 
        ArrayType* AT = ArrayType::get(PKT->getContainedType(0),
                                       PKT->getNumElements());
@@ -227,7 +227,7 @@
 
        for (unsigned i = 0, e = PKT->getNumElements(); i != e; ++i) {
             // Calculate the second index we will need
-            Idx[1] = ConstantUInt::get(Type::UIntTy,i);
+            Idx[1] = ConstantInt::get(Type::UIntTy,i);
 
             // Get the pointer
             Value* val = new GetElementPtrInst(array,
@@ -283,7 +283,7 @@
        dyn_cast<PackedType>(SI.getOperand(0)->getType())) {
        // We will need this for getelementptr
        std::vector<Value*> Idx(2);
-       Idx[0] = ConstantUInt::get(Type::UIntTy,0);
+       Idx[0] = ConstantInt::get(Type::UIntTy,0);
 
        ArrayType* AT = ArrayType::get(PKT->getContainedType(0),
                                       PKT->getNumElements());
@@ -301,7 +301,7 @@
 
        for (unsigned i = 0, e = PKT->getNumElements(); i != e; ++i) {
             // Generate the indices for getelementptr
-            Idx[1] = ConstantUInt::get(Type::UIntTy,i);
+            Idx[1] = ConstantInt::get(Type::UIntTy,i);
             Value* val = new GetElementPtrInst(array,
                                                Idx,
                                                "store.ge." +
@@ -346,17 +346,17 @@
   const PackedType *PTy = cast<PackedType>(EI.getOperand(0)->getType());
   Value *op1 = EI.getOperand(1);
 
-  if (ConstantUInt *C = dyn_cast<ConstantUInt>(op1)) {
-    EI.replaceAllUsesWith(op0Vals[C->getValue()]);
+  if (ConstantInt *C = dyn_cast<ConstantInt>(op1)) {
+    EI.replaceAllUsesWith(op0Vals[C->getZExtValue()]);
   } else {
     AllocaInst *alloca = 
       new AllocaInst(PTy->getElementType(),
-                     ConstantUInt::get(Type::UIntTy, PTy->getNumElements()),
+                     ConstantInt::get(Type::UIntTy, PTy->getNumElements()),
                      EI.getName() + ".alloca", 
 		     EI.getParent()->getParent()->getEntryBlock().begin());
     for (unsigned i = 0; i < PTy->getNumElements(); ++i) {
       GetElementPtrInst *GEP = 
-        new GetElementPtrInst(alloca, ConstantUInt::get(Type::UIntTy, i),
+        new GetElementPtrInst(alloca, ConstantInt::get(Type::UIntTy, i),
                               "store.ge", &EI);
       new StoreInst(op0Vals[i], GEP, &EI);
     }
@@ -378,8 +378,8 @@
   std::vector<Value*> result;
   result.reserve(Vals.size());
 
-  if (ConstantUInt *C = dyn_cast<ConstantUInt>(Idx)) {
-    unsigned idxVal = C->getValue();
+  if (ConstantInt *C = dyn_cast<ConstantInt>(Idx)) {
+    unsigned idxVal = C->getZExtValue();
     for (unsigned i = 0; i != Vals.size(); ++i) {
       result.push_back(i == idxVal ? Elt : Vals[i]);
     }
@@ -387,7 +387,7 @@
     for (unsigned i = 0; i != Vals.size(); ++i) {
       SetCondInst *setcc =
         new SetCondInst(Instruction::SetEQ, Idx, 
-                        ConstantUInt::get(Type::UIntTy, i),
+                        ConstantInt::get(Type::UIntTy, i),
                         "setcc", &IE);
       SelectInst *select =
         new SelectInst(setcc, Elt, Vals[i], "select", &IE);


Index: llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp
diff -u llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.44 llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.44.2.1
--- llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.44	Sun Oct  8 18:53:04 2006
+++ llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp	Wed Oct 18 22:57:56 2006
@@ -608,13 +608,13 @@
         if (const PackedType *PTy = dyn_cast<PackedType>(NV->getType())) {
           // Must be an element access.
           unsigned Elt = Offset/(TD.getTypeSize(PTy->getElementType())*8);
-          NV = new ExtractElementInst(NV, ConstantUInt::get(Type::UIntTy, Elt),
+          NV = new ExtractElementInst(NV, ConstantInt::get(Type::UIntTy, Elt),
                                       "tmp", LI);
         } else {
           assert(NV->getType()->isInteger() && "Unknown promotion!");
           if (Offset && Offset < TD.getTypeSize(NV->getType())*8)
             NV = new ShiftInst(Instruction::Shr, NV,
-                               ConstantUInt::get(Type::UByteTy, Offset),
+                               ConstantInt::get(Type::UByteTy, Offset),
                                LI->getName(), LI);
           NV = new CastInst(NV, LI->getType(), LI->getName(), LI);
         }
@@ -635,7 +635,7 @@
           // Must be an element insertion.
           unsigned Elt = Offset/(TD.getTypeSize(PTy->getElementType())*8);
           SV = new InsertElementInst(Old, SV,
-                                     ConstantUInt::get(Type::UIntTy, Elt),
+                                     ConstantInt::get(Type::UIntTy, Elt),
                                      "tmp", SI);
         } else {
           // If SV is signed, convert it to unsigned, so that the next cast zero
@@ -646,7 +646,7 @@
           SV = new CastInst(SV, Old->getType(), SV->getName(), SI);
           if (Offset && Offset < TD.getTypeSize(SV->getType())*8)
             SV = new ShiftInst(Instruction::Shl, SV,
-                               ConstantUInt::get(Type::UByteTy, Offset),
+                               ConstantInt::get(Type::UByteTy, Offset),
                                SV->getName()+".adj", SI);
           // Mask out the bits we are about to insert from the old value.
           unsigned TotalBits = TD.getTypeSize(SV->getType())*8;
@@ -657,7 +657,7 @@
             if (TotalBits != 64)
               Mask = Mask & ((1ULL << TotalBits)-1);
             Old = BinaryOperator::createAnd(Old,
-                                        ConstantUInt::get(Old->getType(), Mask),
+                                        ConstantInt::get(Old->getType(), Mask),
                                             Old->getName()+".mask", SI);
             SV = BinaryOperator::createOr(Old, SV, SV->getName()+".ins", SI);
           }






More information about the llvm-commits mailing list