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

Reid Spencer reid at x10sys.com
Sat Dec 30 21:49:04 PST 2006



Changes in directory llvm/lib/Transforms/Scalar:

CorrelatedExprs.cpp updated: 1.42 -> 1.43
IndVarSimplify.cpp updated: 1.99 -> 1.100
InstructionCombining.cpp updated: 1.576 -> 1.577
LoopStrengthReduce.cpp updated: 1.102 -> 1.103
LowerGC.cpp updated: 1.16 -> 1.17
LowerPacked.cpp updated: 1.14 -> 1.15
ScalarReplAggregates.cpp updated: 1.61 -> 1.62
---
Log message:

For PR950: http://llvm.org/PR950 :
This patch replaces signed integer types with signless ones:
1. [US]Byte -> Int8
2. [U]Short -> Int16
3. [U]Int   -> Int32
4. [U]Long  -> Int64.
5. Removal of isSigned, isUnsigned, getSignedVersion, getUnsignedVersion
   and other methods related to signedness. In a few places this warranted
   identifying the signedness information from other sources.



---
Diffs of the changes:  (+158 -227)

 CorrelatedExprs.cpp      |    2 
 IndVarSimplify.cpp       |    5 
 InstructionCombining.cpp |  291 ++++++++++++++++++-----------------------------
 LoopStrengthReduce.cpp   |   12 -
 LowerGC.cpp              |   18 +-
 LowerPacked.cpp          |   14 +-
 ScalarReplAggregates.cpp |   43 +++---
 7 files changed, 158 insertions(+), 227 deletions(-)


Index: llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp
diff -u llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp:1.42 llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp:1.43
--- llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp:1.42	Sat Dec 23 00:05:41 2006
+++ llvm/lib/Transforms/Scalar/CorrelatedExprs.cpp	Sat Dec 30 23:48:39 2006
@@ -111,7 +111,7 @@
     Value *Replacement;
   public:
     ValueInfo(const Type *Ty)
-      : Bounds(Ty->isIntegral() ? Ty : Type::IntTy), Replacement(0) {}
+      : Bounds(Ty->isIntegral() ? Ty : Type::Int32Ty), Replacement(0) {}
 
     // getBounds() - Return the constant bounds of the value...
     const ConstantRange &getBounds() const { return Bounds; }


Index: llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
diff -u llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.99 llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.100
--- llvm/lib/Transforms/Scalar/IndVarSimplify.cpp:1.99	Sat Dec 23 00:05:41 2006
+++ llvm/lib/Transforms/Scalar/IndVarSimplify.cpp	Sat Dec 30 23:48:39 2006
@@ -173,7 +173,7 @@
               Constant *NCE = ConstantExpr::getGetElementPtr(CE->getOperand(0),
                                                              CEIdxs);
               GetElementPtrInst *NGEPI =
-                new GetElementPtrInst(NCE, Constant::getNullValue(Type::IntTy),
+                new GetElementPtrInst(NCE, Constant::getNullValue(Type::Int32Ty),
                                       NewAdd, GEPI->getName(), GEPI);
               GEPI->replaceAllUsesWith(NGEPI);
               GEPI->eraseFromParent();
@@ -499,7 +499,6 @@
 
   // Now that we know the largest of of the induction variables in this loop,
   // insert a canonical induction variable of the largest size.
-  LargestType = LargestType->getUnsignedVersion();
   Value *IndVar = Rewriter.getOrInsertCanonicalInductionVariable(L,LargestType);
   ++NumInserted;
   Changed = true;
@@ -525,7 +524,7 @@
         PHINode *PN = IndVars[i].first;
         InsertedSizes[PN->getType()->getPrimitiveSize()] = true;
         Instruction *New = CastInst::create(Instruction::Trunc, IndVar, 
-            PN->getType()->getUnsignedVersion(), "indvar", InsertPt);
+            PN->getType(), "indvar", InsertPt);
         Rewriter.addInsertedValue(New, SE->getSCEV(New));
       }
   }


Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.576 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.577
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.576	Sat Dec 23 18:40:59 2006
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp	Sat Dec 30 23:48:39 2006
@@ -340,10 +340,8 @@
 // though a va_arg area...
 static const Type *getPromotedType(const Type *Ty) {
   switch (Ty->getTypeID()) {
-  case Type::SByteTyID:
-  case Type::ShortTyID:  return Type::IntTy;
-  case Type::UByteTyID:
-  case Type::UShortTyID: return Type::UIntTy;
+  case Type::Int8TyID:
+  case Type::Int16TyID:  return Type::Int32Ty;
   case Type::FloatTyID:  return Type::DoubleTy;
   default:               return Ty;
   }
@@ -540,14 +538,9 @@
 /// GetConstantInType - Return a ConstantInt with the specified type and value.
 ///
 static ConstantIntegral *GetConstantInType(const Type *Ty, uint64_t Val) {
-  if (Ty->isUnsigned()) 
-    return ConstantInt::get(Ty, Val);
-  else if (Ty->getTypeID() == Type::BoolTyID)
+  if (Ty->getTypeID() == Type::BoolTyID)
     return ConstantBool::get(Val);
-  int64_t SVal = Val;
-  SVal <<= 64-Ty->getPrimitiveSizeInBits();
-  SVal >>= 64-Ty->getPrimitiveSizeInBits();
-  return ConstantInt::get(Ty, SVal);
+  return ConstantInt::get(Ty, Val);
 }
 
 
@@ -1575,7 +1568,7 @@
   bool shouldApply(Value *LHS) const { return LHS == RHS; }
   Instruction *apply(BinaryOperator &Add) const {
     return new ShiftInst(Instruction::Shl, Add.getOperand(0),
-                         ConstantInt::get(Type::UByteTy, 1));
+                         ConstantInt::get(Type::Int8Ty, 1));
   }
 };
 
@@ -1825,9 +1818,9 @@
       const Type *MiddleType = 0;
       switch (Size) {
       default: break;
-      case 32: MiddleType = Type::IntTy; break;
-      case 16: MiddleType = Type::ShortTy; break;
-      case 8:  MiddleType = Type::SByteTy; break;
+      case 32: MiddleType = Type::Int32Ty; break;
+      case 16: MiddleType = Type::Int16Ty; break;
+      case 8:  MiddleType = Type::Int8Ty; break;
       }
       if (MiddleType) {
         Instruction *NewTrunc = new TruncInst(XorLHS, MiddleType, "sext");
@@ -1935,7 +1928,7 @@
          TD->getIntPtrType()->getPrimitiveSize()) 
         && isa<PointerType>(CI->getOperand(0)->getType())) {
       Value *I2 = InsertCastBefore(Instruction::BitCast, CI->getOperand(0),
-                                   PointerType::get(Type::SByteTy), I);
+                                   PointerType::get(Type::Int8Ty), I);
       I2 = InsertNewInstBefore(new GetElementPtrInst(I2, Other, "ctg2"), I);
       return new PtrToIntInst(I2, CI->getType());
     }
@@ -2018,9 +2011,10 @@
             // Check to see if we are shifting out everything but the sign bit.
             if (CU->getZExtValue() == 
                 SI->getType()->getPrimitiveSizeInBits()-1) {
-              // Ok, the transformation is safe.  Insert LShr.
-              return new ShiftInst(Instruction::LShr, SI->getOperand(0),
-                                    CU, SI->getName());
+              
+              // Ok, the transformation is safe.  Insert LShr. 
+              return new ShiftInst(Instruction::LShr, SI->getOperand(0), CU, 
+                                   SI->getName());
             }
           }
         } 
@@ -2173,7 +2167,7 @@
       if (isPowerOf2_64(Val)) {          // Replace X*(2^C) with X << C
         uint64_t C = Log2_64(Val);
         return new ShiftInst(Instruction::Shl, Op0,
-                             ConstantInt::get(Type::UByteTy, C));
+                             ConstantInt::get(Type::Int8Ty, C));
       }
     } else if (ConstantFP *Op1F = dyn_cast<ConstantFP>(Op1)) {
       if (Op1F->isNullValue())
@@ -2234,7 +2228,7 @@
       if (isa<ConstantInt>(SCIOp1) &&
           isSignBitCheck(SCI->getPredicate(), cast<ConstantInt>(SCIOp1))) {
         // Shift the X value right to turn it into "all signbits".
-        Constant *Amt = ConstantInt::get(Type::UByteTy,
+        Constant *Amt = ConstantInt::get(Type::Int8Ty,
                                           SCOpTy->getPrimitiveSizeInBits()-1);
         Value *V =
           InsertNewInstBefore(new ShiftInst(Instruction::AShr, SCIOp0, Amt,
@@ -2368,7 +2362,7 @@
       if (isPowerOf2_64(Val)) {
         uint64_t ShiftAmt = Log2_64(Val);
         return new ShiftInst(Instruction::LShr, Op0, 
-                              ConstantInt::get(Type::UByteTy, ShiftAmt));
+                              ConstantInt::get(Type::Int8Ty, ShiftAmt));
       }
   }
 
@@ -2400,13 +2394,13 @@
             // Compute the shift amounts
             unsigned TSA = Log2_64(TVA), FSA = Log2_64(FVA);
             // Construct the "on true" case of the select
-            Constant *TC = ConstantInt::get(Type::UByteTy, TSA);
+            Constant *TC = ConstantInt::get(Type::Int8Ty, TSA);
             Instruction *TSI = 
               new ShiftInst(Instruction::LShr, Op0, TC, SI->getName()+".t");
             TSI = InsertNewInstBefore(TSI, I);
     
             // Construct the "on false" case of the select
-            Constant *FC = ConstantInt::get(Type::UByteTy, FSA); 
+            Constant *FC = ConstantInt::get(Type::Int8Ty, FSA); 
             Instruction *FSI = 
               new ShiftInst(Instruction::LShr, Op0, FC, SI->getName()+".f");
             FSI = InsertNewInstBefore(FSI, I);
@@ -2480,7 +2474,7 @@
       unsigned Zeros = CountTrailingZeros_64(RHS->getZExtValue());
       if (Zeros != V->getType()->getPrimitiveSizeInBits())
         return ConstantExpr::getShl(Result, 
-                                    ConstantInt::get(Type::UByteTy, Zeros));
+                                    ConstantInt::get(Type::Int8Ty, Zeros));
     }
   } else if (CastInst *CI = dyn_cast<CastInst>(I)) {
     // Only handle int->int casts.
@@ -3328,12 +3322,7 @@
                 Instruction *Add = BinaryOperator::createAdd(LHSVal, AddCST,
                                                       LHSVal->getName()+".off");
                 InsertNewInstBefore(Add, I);
-                const Type *UnsType = Add->getType()->getUnsignedVersion();
-                Value *OffsetVal = InsertCastBefore(Instruction::BitCast, Add,
-                                                    UnsType, I);
-                AddCST = ConstantExpr::getSub(RHSCst, LHSCst);
-                AddCST = ConstantExpr::getBitCast(AddCST, UnsType);
-                return new ICmpInst(ICmpInst::ICMP_UGT, OffsetVal, AddCST);
+                return new ICmpInst(ICmpInst::ICMP_UGT, Add, AddCST);
               }
               break;                        // (X != 13 & X != 15) -> no change
             }
@@ -3530,7 +3519,7 @@
 /// If so, insert the new bswap intrinsic and return it.
 Instruction *InstCombiner::MatchBSwap(BinaryOperator &I) {
   // We can only handle bswap of unsigned integers, and cannot bswap one byte.
-  if (!I.getType()->isUnsigned() || I.getType() == Type::UByteTy)
+  if (I.getType() == Type::Int8Ty)
     return 0;
   
   /// ByteValues - For each byte of the result, we keep track of which value
@@ -3556,11 +3545,11 @@
   // bswap to make it into.
   Module *M = I.getParent()->getParent()->getParent();
   const char *FnName = 0;
-  if (I.getType() == Type::UShortTy)
+  if (I.getType() == Type::Int16Ty)
     FnName = "llvm.bswap.i16";
-  else if (I.getType() == Type::UIntTy)
+  else if (I.getType() == Type::Int32Ty)
     FnName = "llvm.bswap.i32";
-  else if (I.getType() == Type::ULongTy)
+  else if (I.getType() == Type::Int64Ty)
     FnName = "llvm.bswap.i64";
   else
     assert(0 && "Unknown integer type!");
@@ -4093,16 +4082,8 @@
                             ConstantInt *In2) {
   Result = cast<ConstantInt>(ConstantExpr::getAdd(In1, In2));
 
-  if (In1->getType()->isUnsigned())
-    return cast<ConstantInt>(Result)->getZExtValue() <
-           cast<ConstantInt>(In1)->getZExtValue();
-  if (isPositive(In1) != isPositive(In2))
-    return false;
-  if (isPositive(In1))
-    return cast<ConstantInt>(Result)->getSExtValue() <
-           cast<ConstantInt>(In1)->getSExtValue();
-  return cast<ConstantInt>(Result)->getSExtValue() >
-         cast<ConstantInt>(In1)->getSExtValue();
+  return cast<ConstantInt>(Result)->getZExtValue() <
+         cast<ConstantInt>(In1)->getZExtValue();
 }
 
 /// EmitGEPOffset - Given a getelementptr instruction/constantexpr, emit the
@@ -4596,17 +4577,10 @@
                  (CI->getZExtValue() == (uint64_t)CI->getSExtValue()))) {
               ConstantInt *NewCST;
               ConstantInt *NewCI;
-              if (Cast->getOperand(0)->getType()->isSigned()) {
-                NewCST = ConstantInt::get(Cast->getOperand(0)->getType(),
-                                           AndCST->getZExtValue());
-                NewCI = ConstantInt::get(Cast->getOperand(0)->getType(),
-                                          CI->getZExtValue());
-              } else {
-                NewCST = ConstantInt::get(Cast->getOperand(0)->getType(),
-                                           AndCST->getZExtValue());
-                NewCI = ConstantInt::get(Cast->getOperand(0)->getType(),
-                                          CI->getZExtValue());
-              }
+              NewCST = ConstantInt::get(Cast->getOperand(0)->getType(),
+                                         AndCST->getZExtValue());
+              NewCI = ConstantInt::get(Cast->getOperand(0)->getType(),
+                                        CI->getZExtValue());
               Instruction *NewAnd = 
                 BinaryOperator::createAnd(Cast->getOperand(0), NewCST, 
                                           LHSI->getName());
@@ -4644,7 +4618,7 @@
               int ShAmtVal = Ty->getPrimitiveSizeInBits()-ShAmt->getZExtValue();
               if (ShAmtVal < 0) ShAmtVal = 0; // Out of range shift.
 
-              Constant *OShAmt = ConstantInt::get(Type::UByteTy, ShAmtVal);
+              Constant *OShAmt = ConstantInt::get(Type::Int8Ty, ShAmtVal);
               Constant *ShVal =
                 ConstantExpr::getShl(ConstantInt::getAllOnesValue(AndTy), 
                                      OShAmt);
@@ -4756,15 +4730,7 @@
               // Otherwise strength reduce the shift into an and.
               unsigned ShAmtVal = (unsigned)ShAmt->getZExtValue();
               uint64_t Val = (1ULL << (TypeBits-ShAmtVal))-1;
-
-              Constant *Mask;
-              if (CI->getType()->isUnsigned()) {
-                Mask = ConstantInt::get(CI->getType(), Val);
-              } else if (ShAmtVal != 0) {
-                Mask = ConstantInt::get(CI->getType(), Val);
-              } else {
-                Mask = ConstantInt::getAllOnesValue(CI->getType());
-              }
+              Constant *Mask = ConstantInt::get(CI->getType(), Val);
 
               Instruction *AndI =
                 BinaryOperator::createAnd(LHSI->getOperand(0),
@@ -4791,7 +4757,7 @@
             // If we are comparing against bits always shifted out, the
             // comparison cannot succeed.
             Constant *Comp;
-            if (CI->getType()->isUnsigned())
+            if (LHSI->getOpcode() == Instruction::LShr) 
               Comp = ConstantExpr::getLShr(ConstantExpr::getShl(CI, ShAmt), 
                                            ShAmt);
             else
@@ -4810,14 +4776,8 @@
               // Otherwise strength reduce the shift into an and.
               uint64_t Val = ~0ULL;          // All ones.
               Val <<= ShAmtVal;              // Shift over to the right spot.
-
-              Constant *Mask;
-              if (CI->getType()->isUnsigned()) {
-                Val &= ~0ULL >> (64-TypeBits);
-                Mask = ConstantInt::get(CI->getType(), Val);
-              } else {
-                Mask = ConstantInt::get(CI->getType(), Val);
-              }
+              Val &= ~0ULL >> (64-TypeBits);
+              Constant *Mask = ConstantInt::get(CI->getType(), Val);
 
               Instruction *AndI =
                 BinaryOperator::createAnd(LHSI->getOperand(0),
@@ -5049,11 +5009,6 @@
             // Replace (and X, (1 << size(X)-1) != 0) with x s< 0
             if (isSignBit(BOC)) {
               Value *X = BO->getOperand(0);
-              // If 'X' is not signed, insert a cast now...
-              if (!BOC->getType()->isSigned()) {
-                const Type *DestTy = BOC->getType()->getSignedVersion();
-                X = InsertCastBefore(Instruction::BitCast, X, DestTy, I);
-              }
               Constant *Zero = Constant::getNullValue(X->getType());
               ICmpInst::Predicate pred = isICMP_NE ? 
                 ICmpInst::ICMP_SLT : ICmpInst::ICMP_SGE;
@@ -5080,21 +5035,21 @@
           // icmp eq (bswap(x)), c -> icmp eq (x,bswap(c))
           WorkList.push_back(II);  // Dead?
           I.setOperand(0, II->getOperand(1));
-          I.setOperand(1, ConstantInt::get(Type::UShortTy,
+          I.setOperand(1, ConstantInt::get(Type::Int16Ty,
                                            ByteSwap_16(CI->getZExtValue())));
           return &I;
         case Intrinsic::bswap_i32:   
           // icmp eq (bswap(x)), c -> icmp eq (x,bswap(c))
           WorkList.push_back(II);  // Dead?
           I.setOperand(0, II->getOperand(1));
-          I.setOperand(1, ConstantInt::get(Type::UIntTy,
+          I.setOperand(1, ConstantInt::get(Type::Int32Ty,
                                            ByteSwap_32(CI->getZExtValue())));
           return &I;
         case Intrinsic::bswap_i64:   
           // icmp eq (bswap(x)), c -> icmp eq (x,bswap(c))
           WorkList.push_back(II);  // Dead?
           I.setOperand(0, II->getOperand(1));
-          I.setOperand(1, ConstantInt::get(Type::ULongTy,
+          I.setOperand(1, ConstantInt::get(Type::Int64Ty,
                                            ByteSwap_64(CI->getZExtValue())));
           return &I;
         }
@@ -5393,12 +5348,12 @@
 }
 
 Instruction *InstCombiner::visitShiftInst(ShiftInst &I) {
-  assert(I.getOperand(1)->getType() == Type::UByteTy);
+  assert(I.getOperand(1)->getType() == Type::Int8Ty);
   Value *Op0 = I.getOperand(0), *Op1 = I.getOperand(1);
 
   // shl X, 0 == X and shr X, 0 == X
   // shl 0, X == 0 and shr 0, X == 0
-  if (Op1 == Constant::getNullValue(Type::UByteTy) ||
+  if (Op1 == Constant::getNullValue(Type::Int8Ty) ||
       Op0 == Constant::getNullValue(Op0->getType()))
     return ReplaceInstUsesWith(I, Op0);
   
@@ -5436,9 +5391,8 @@
   }
 
   if (ConstantInt *CUI = dyn_cast<ConstantInt>(Op1))
-    if (CUI->getType()->isUnsigned())
-      if (Instruction *Res = FoldShiftByConstant(Op0, CUI, I))
-        return Res;
+    if (Instruction *Res = FoldShiftByConstant(Op0, CUI, I))
+      return Res;
   return 0;
 }
 
@@ -5463,7 +5417,7 @@
     if (isUnsignedShift || isLeftShift)
       return ReplaceInstUsesWith(I, Constant::getNullValue(Op0->getType()));
     else {
-      I.setOperand(1, ConstantInt::get(Type::UByteTy, TypeBits-1));
+      I.setOperand(1, ConstantInt::get(Type::Int8Ty, TypeBits-1));
       return &I;
     }
   }
@@ -5657,7 +5611,7 @@
       
       Value *Op = ShiftOp->getOperand(0);
       ShiftInst *ShiftResult = new ShiftInst(I.getOpcode(), Op,
-                                          ConstantInt::get(Type::UByteTy, Amt));
+                                          ConstantInt::get(Type::Int8Ty, Amt));
       if (I.getType() == ShiftResult->getType())
         return ShiftResult;
       InsertNewInstBefore(ShiftResult, I);
@@ -5688,20 +5642,20 @@
         return ReplaceInstUsesWith(I, Mask);  // (A << c) >> c  === A & c2
       } else if (ShiftAmt1 < ShiftAmt2) {
         return new ShiftInst(I.getOpcode(), Mask,
-                         ConstantInt::get(Type::UByteTy, ShiftAmt2-ShiftAmt1));
+                         ConstantInt::get(Type::Int8Ty, ShiftAmt2-ShiftAmt1));
       } else if (isShiftOfUnsignedShift || isShiftOfLeftShift) {
         if (isShiftOfUnsignedShift && !isShiftOfLeftShift && isSignedShift) {
           return new ShiftInst(Instruction::LShr, Mask, 
-            ConstantInt::get(Type::UByteTy, ShiftAmt1-ShiftAmt2));
+            ConstantInt::get(Type::Int8Ty, ShiftAmt1-ShiftAmt2));
         } else {
           return new ShiftInst(ShiftOp->getOpcode(), Mask,
-                    ConstantInt::get(Type::UByteTy, ShiftAmt1-ShiftAmt2));
+                    ConstantInt::get(Type::Int8Ty, ShiftAmt1-ShiftAmt2));
         }
       } else {
         // (X >>s C1) << C2  where C1 > C2  === (X >>s (C1-C2)) & mask
         Instruction *Shift =
           new ShiftInst(ShiftOp->getOpcode(), Mask,
-                        ConstantInt::get(Type::UByteTy, ShiftAmt1-ShiftAmt2));
+                        ConstantInt::get(Type::Int8Ty, ShiftAmt1-ShiftAmt2));
         InsertNewInstBefore(Shift, I);
         
         C = ConstantIntegral::getAllOnesValue(Shift->getType());
@@ -5714,9 +5668,9 @@
       if (ShiftAmt1 == ShiftAmt2) {
         const Type *SExtType = 0;
         switch (Op0->getType()->getPrimitiveSizeInBits() - ShiftAmt1) {
-        case 8 : SExtType = Type::SByteTy; break;
-        case 16: SExtType = Type::ShortTy; break;
-        case 32: SExtType = Type::IntTy; break;
+        case 8 : SExtType = Type::Int8Ty; break;
+        case 16: SExtType = Type::Int16Ty; break;
+        case 32: SExtType = Type::Int32Ty; break;
         }
         
         if (SExtType) {
@@ -5738,38 +5692,34 @@
 ///
 static Value *DecomposeSimpleLinearExpr(Value *Val, unsigned &Scale,
                                         unsigned &Offset) {
-  assert(Val->getType() == Type::UIntTy && "Unexpected allocation size type!");
+  assert(Val->getType() == Type::Int32Ty && "Unexpected allocation size type!");
   if (ConstantInt *CI = dyn_cast<ConstantInt>(Val)) {
-    if (CI->getType()->isUnsigned()) {
-      Offset = CI->getZExtValue();
-      Scale  = 1;
-      return ConstantInt::get(Type::UIntTy, 0);
-    }
+    Offset = CI->getZExtValue();
+    Scale  = 1;
+    return ConstantInt::get(Type::Int32Ty, 0);
   } else if (Instruction *I = dyn_cast<Instruction>(Val)) {
     if (I->getNumOperands() == 2) {
       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;
-            }
+        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;
           }
         }
       }
@@ -5844,8 +5794,8 @@
     Amt = NumElements;
   } else {
     // 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 = ConstantInt::get(Type::Int32Ty, Scale);
+    if (isa<ConstantInt>(NumElements))
       Amt = ConstantExpr::getMul(
               cast<ConstantInt>(NumElements), cast<ConstantInt>(Amt));
     // otherwise multiply the amount and the number of elements
@@ -5856,7 +5806,7 @@
   }
   
   if (unsigned Offset = (AllocElTySize*ArrayOffset)/CastElTySize) {
-    Value *Off = ConstantInt::get(Type::UIntTy, Offset);
+    Value *Off = ConstantInt::get(Type::Int32Ty, Offset);
     Instruction *Tmp = BinaryOperator::createAdd(Amt, Off, "tmp");
     Amt = InsertNewInstBefore(Tmp, AI);
   }
@@ -6117,7 +6067,7 @@
         // We need to emit an AND to clear the high bits.
         assert(SrcBitSize < DestBitSize && "Not a zext?");
         Constant *C = 
-          ConstantInt::get(Type::ULongTy, (1ULL << SrcBitSize)-1);
+          ConstantInt::get(Type::Int64Ty, (1ULL << SrcBitSize)-1);
         if (DestBitSize < 64)
           C = ConstantExpr::getTrunc(C, DestTy);
         else {
@@ -6261,7 +6211,7 @@
             // Insert the shift to put the result in the low bit.
             In = InsertNewInstBefore(
               new ShiftInst(Instruction::LShr, In,
-                            ConstantInt::get(Type::UByteTy, ShiftAmt),
+                            ConstantInt::get(Type::Int8Ty, ShiftAmt),
                             In->getName()+".lobit"), CI);
           }
           
@@ -6442,7 +6392,7 @@
       const Type *DstElTy = DstPTy->getElementType();
       const Type *SrcElTy = SrcPTy->getElementType();
       
-      Constant *ZeroUInt = Constant::getNullValue(Type::UIntTy);
+      Constant *ZeroUInt = Constant::getNullValue(Type::Int32Ty);
       unsigned NumZeros = 0;
       while (SrcElTy != DstElTy && 
              isa<CompositeType>(SrcElTy) && !isa<PointerType>(SrcElTy) &&
@@ -6530,7 +6480,7 @@
   case Instruction::Shl:
   case Instruction::LShr:
   case Instruction::AShr:
-    return Constant::getNullValue(Type::UByteTy);
+    return Constant::getNullValue(Type::Int8Ty);
   case Instruction::And:
     return ConstantInt::getAllOnesValue(I->getType());
   case Instruction::Mul:
@@ -6697,7 +6647,7 @@
               // same width. Make an all-ones value by inserting a AShr.
               Value *X = IC->getOperand(0);
               unsigned Bits = X->getType()->getPrimitiveSizeInBits();
-              Constant *ShAmt = ConstantInt::get(Type::UByteTy, Bits-1);
+              Constant *ShAmt = ConstantInt::get(Type::Int8Ty, Bits-1);
               Instruction *SRA = new ShiftInst(Instruction::AShr, X,
                                                ShAmt, "ones");
               InsertNewInstBefore(SRA, SI);
@@ -6927,7 +6877,7 @@
         // Malloc returns maximally aligned memory.
         Align = TD->getTypeAlignment(AI->getType()->getElementType());
         Align = std::max(Align, (unsigned)TD->getTypeAlignment(Type::DoubleTy));
-        Align = std::max(Align, (unsigned)TD->getTypeAlignment(Type::LongTy));
+        Align = std::max(Align, (unsigned)TD->getTypeAlignment(Type::Int64Ty));
       }
     }
     return Align;
@@ -7007,7 +6957,7 @@
           Module *M = CI.getParent()->getParent()->getParent();
           const char *Name;
           if (CI.getCalledFunction()->getFunctionType()->getParamType(2) == 
-              Type::UIntTy)
+              Type::Int32Ty)
             Name = "llvm.memcpy.i32";
           else
             Name = "llvm.memcpy.i64";
@@ -7025,13 +6975,13 @@
       unsigned Alignment2 = GetKnownAlignment(MI->getOperand(2), TD);
       unsigned Align = std::min(Alignment1, Alignment2);
       if (MI->getAlignment()->getZExtValue() < Align) {
-        MI->setAlignment(ConstantInt::get(Type::UIntTy, Align));
+        MI->setAlignment(ConstantInt::get(Type::Int32Ty, Align));
         Changed = true;
       }
     } else if (isa<MemSetInst>(MI)) {
       unsigned Alignment = GetKnownAlignment(MI->getDest(), TD);
       if (MI->getAlignment()->getZExtValue() < Alignment) {
-        MI->setAlignment(ConstantInt::get(Type::UIntTy, Alignment));
+        MI->setAlignment(ConstantInt::get(Type::Int32Ty, Alignment));
         Changed = true;
       }
     }
@@ -7298,7 +7248,6 @@
     //Either we can cast directly, or we can upconvert the argument
     bool isConvertible = ActTy->canLosslesslyBitCastTo(ParamTy) ||
       (ParamTy->isIntegral() && ActTy->isIntegral() &&
-       ParamTy->isSigned() == ActTy->isSigned() &&
        ParamTy->getPrimitiveSize() >= ActTy->getPrimitiveSize()) ||
       (c && ParamTy->getPrimitiveSize() >= ActTy->getPrimitiveSize() &&
        c->getSExtValue() > 0);
@@ -7321,7 +7270,7 @@
       Args.push_back(*AI);
     } else {
       Instruction::CastOps opcode = CastInst::getCastOpcode(*AI,
-          (*AI)->getType()->isSigned(), ParamTy, ParamTy->isSigned());
+          false, ParamTy, false);
       CastInst *NewCast = CastInst::create(opcode, *AI, ParamTy, "tmp");
       Args.push_back(InsertNewInstBefore(NewCast, *Caller));
     }
@@ -7343,8 +7292,8 @@
         const Type *PTy = getPromotedType((*AI)->getType());
         if (PTy != (*AI)->getType()) {
           // Must promote to pass through va_arg area!
-          Instruction::CastOps opcode = CastInst::getCastOpcode(
-              *AI, (*AI)->getType()->isSigned(), PTy, PTy->isSigned());
+          Instruction::CastOps opcode = CastInst::getCastOpcode(*AI, false, 
+                                                                PTy, false);
           Instruction *Cast = CastInst::create(opcode, *AI, PTy, "tmp");
           InsertNewInstBefore(Cast, *Caller);
           Args.push_back(Cast);
@@ -7374,8 +7323,8 @@
   if (Caller->getType() != NV->getType() && !Caller->use_empty()) {
     if (NV->getType() != Type::VoidTy) {
       const Type *CallerTy = Caller->getType();
-      Instruction::CastOps opcode = CastInst::getCastOpcode(
-          NC, NC->getType()->isSigned(), CallerTy, CallerTy->isSigned());
+      Instruction::CastOps opcode = CastInst::getCastOpcode(NC, false, 
+                                                            CallerTy, false);
       NV = NC = CastInst::create(opcode, NC, CallerTy, "tmp");
 
       // If this is an invoke instruction, we should insert it after the first
@@ -7728,14 +7677,6 @@
           GEP.setOperand(i, Op);
           MadeChange = true;
         }
-      // If this is a constant idx, make sure to canonicalize it to be a signed
-      // operand, otherwise CSE and other optimizations are pessimized.
-      if (ConstantInt *CUI = dyn_cast<ConstantInt>(Op))
-        if (CUI->getType()->isUnsigned()) {
-          GEP.setOperand(i, 
-            ConstantExpr::getBitCast(CUI, CUI->getType()->getSignedVersion()));
-          MadeChange = true;
-        }
     }
   if (MadeChange) return &GEP;
 
@@ -7878,7 +7819,7 @@
           TD->getTypeSize(cast<ArrayType>(SrcElTy)->getElementType()) ==
           TD->getTypeSize(ResElTy)) {
         Value *V = InsertNewInstBefore(
-               new GetElementPtrInst(X, Constant::getNullValue(Type::IntTy),
+               new GetElementPtrInst(X, Constant::getNullValue(Type::Int32Ty),
                                      GEP.getOperand(1), GEP.getName()), GEP);
         // V and GEP are both pointer types --> BitCast
         return new BitCastInst(V, GEP.getType());
@@ -7890,7 +7831,7 @@
       // getelementptr [100 x double]* %arr, int 0, int %tmp.2
       
       if (isa<ArrayType>(SrcElTy) &&
-          (ResElTy == Type::SByteTy || ResElTy == Type::UByteTy)) {
+          (ResElTy == Type::Int8Ty || ResElTy == Type::Int8Ty)) {
         uint64_t ArrayEltSize =
             TD->getTypeSize(cast<ArrayType>(SrcElTy)->getElementType());
         
@@ -7933,7 +7874,7 @@
 
           // Insert the new GEP instruction.
           Instruction *NewGEP =
-            new GetElementPtrInst(X, Constant::getNullValue(Type::IntTy),
+            new GetElementPtrInst(X, Constant::getNullValue(Type::Int32Ty),
                                   NewIdx, GEP.getName());
           NewGEP = InsertNewInstBefore(NewGEP, GEP);
           // The NewGEP must be pointer typed, so must the old one -> BitCast
@@ -7973,7 +7914,7 @@
       // Now that I is pointing to the first non-allocation-inst in the block,
       // insert our getelementptr instruction...
       //
-      Value *NullIdx = Constant::getNullValue(Type::IntTy);
+      Value *NullIdx = Constant::getNullValue(Type::Int32Ty);
       Value *V = new GetElementPtrInst(New, NullIdx, NullIdx,
                                        New->getName()+".sub", It);
 
@@ -8038,7 +7979,7 @@
       if (const ArrayType *ASrcTy = dyn_cast<ArrayType>(SrcPTy))
         if (Constant *CSrc = dyn_cast<Constant>(CastOp))
           if (ASrcTy->getNumElements() != 0) {
-            std::vector<Value*> Idxs(2, Constant::getNullValue(Type::IntTy));
+            std::vector<Value*> Idxs(2, Constant::getNullValue(Type::Int32Ty));
             CastOp = ConstantExpr::getGetElementPtr(CSrc, Idxs);
             SrcTy = cast<PointerType>(CastOp->getType());
             SrcPTy = SrcTy->getElementType();
@@ -8225,7 +8166,7 @@
       if (const ArrayType *ASrcTy = dyn_cast<ArrayType>(SrcPTy))
         if (Constant *CSrc = dyn_cast<Constant>(CastOp))
           if (ASrcTy->getNumElements() != 0) {
-            std::vector<Value*> Idxs(2, Constant::getNullValue(Type::IntTy));
+            std::vector<Value*> Idxs(2, Constant::getNullValue(Type::Int32Ty));
             CastOp = ConstantExpr::getGetElementPtr(CSrc, Idxs);
             SrcTy = cast<PointerType>(CastOp->getType());
             SrcPTy = SrcTy->getElementType();
@@ -8696,15 +8637,15 @@
   unsigned NumElts = cast<PackedType>(V->getType())->getNumElements();
 
   if (isa<UndefValue>(V)) {
-    Mask.assign(NumElts, UndefValue::get(Type::UIntTy));
+    Mask.assign(NumElts, UndefValue::get(Type::Int32Ty));
     return true;
   } else if (V == LHS) {
     for (unsigned i = 0; i != NumElts; ++i)
-      Mask.push_back(ConstantInt::get(Type::UIntTy, i));
+      Mask.push_back(ConstantInt::get(Type::Int32Ty, i));
     return true;
   } else if (V == RHS) {
     for (unsigned i = 0; i != NumElts; ++i)
-      Mask.push_back(ConstantInt::get(Type::UIntTy, i+NumElts));
+      Mask.push_back(ConstantInt::get(Type::Int32Ty, 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.
@@ -8721,7 +8662,7 @@
       // transitively ok.
       if (CollectSingleShuffleElements(VecOp, LHS, RHS, Mask)) {
         // If so, update the mask to reflect the inserted undef.
-        Mask[InsertedIdx] = UndefValue::get(Type::UIntTy);
+        Mask[InsertedIdx] = UndefValue::get(Type::Int32Ty);
         return true;
       }      
     } else if (ExtractElementInst *EI = dyn_cast<ExtractElementInst>(ScalarOp)){
@@ -8738,11 +8679,11 @@
             // If so, update the mask to reflect the inserted value.
             if (EI->getOperand(0) == LHS) {
               Mask[InsertedIdx & (NumElts-1)] = 
-                 ConstantInt::get(Type::UIntTy, ExtractedIdx);
+                 ConstantInt::get(Type::Int32Ty, ExtractedIdx);
             } else {
               assert(EI->getOperand(0) == RHS);
               Mask[InsertedIdx & (NumElts-1)] = 
-                ConstantInt::get(Type::UIntTy, ExtractedIdx+NumElts);
+                ConstantInt::get(Type::Int32Ty, ExtractedIdx+NumElts);
               
             }
             return true;
@@ -8767,10 +8708,10 @@
   unsigned NumElts = cast<PackedType>(V->getType())->getNumElements();
 
   if (isa<UndefValue>(V)) {
-    Mask.assign(NumElts, UndefValue::get(Type::UIntTy));
+    Mask.assign(NumElts, UndefValue::get(Type::Int32Ty));
     return V;
   } else if (isa<ConstantAggregateZero>(V)) {
-    Mask.assign(NumElts, ConstantInt::get(Type::UIntTy, 0));
+    Mask.assign(NumElts, ConstantInt::get(Type::Int32Ty, 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.
@@ -8791,7 +8732,7 @@
           RHS = EI->getOperand(0);
           Value *V = CollectShuffleElements(VecOp, Mask, RHS);
           Mask[InsertedIdx & (NumElts-1)] = 
-            ConstantInt::get(Type::UIntTy, NumElts+ExtractedIdx);
+            ConstantInt::get(Type::Int32Ty, NumElts+ExtractedIdx);
           return V;
         }
         
@@ -8800,7 +8741,7 @@
           // Everything but the extracted element is replaced with the RHS.
           for (unsigned i = 0; i != NumElts; ++i) {
             if (i != InsertedIdx)
-              Mask[i] = ConstantInt::get(Type::UIntTy, NumElts+i);
+              Mask[i] = ConstantInt::get(Type::Int32Ty, NumElts+i);
           }
           return V;
         }
@@ -8817,7 +8758,7 @@
   
   // Otherwise, can't do anything fancy.  Return an identity vector.
   for (unsigned i = 0; i != NumElts; ++i)
-    Mask.push_back(ConstantInt::get(Type::UIntTy, i));
+    Mask.push_back(ConstantInt::get(Type::Int32Ty, i));
   return V;
 }
 
@@ -8856,13 +8797,13 @@
         // Build a new shuffle mask.
         std::vector<Constant*> Mask;
         if (isa<UndefValue>(VecOp))
-          Mask.assign(NumVectorElts, UndefValue::get(Type::UIntTy));
+          Mask.assign(NumVectorElts, UndefValue::get(Type::Int32Ty));
         else {
           assert(isa<ConstantAggregateZero>(VecOp) && "Unknown thing");
-          Mask.assign(NumVectorElts, ConstantInt::get(Type::UIntTy,
+          Mask.assign(NumVectorElts, ConstantInt::get(Type::Int32Ty,
                                                        NumVectorElts));
         } 
-        Mask[InsertedIdx] = ConstantInt::get(Type::UIntTy, ExtractedIdx);
+        Mask[InsertedIdx] = ConstantInt::get(Type::Int32Ty, ExtractedIdx);
         return new ShuffleVectorInst(EI->getOperand(0), VecOp,
                                      ConstantPacked::get(Mask));
       }
@@ -8910,14 +8851,14 @@
     std::vector<Constant*> Elts;
     for (unsigned i = 0, e = Mask.size(); i != e; ++i) {
       if (Mask[i] >= 2*e)
-        Elts.push_back(UndefValue::get(Type::UIntTy));
+        Elts.push_back(UndefValue::get(Type::Int32Ty));
       else {
         if ((Mask[i] >= e && isa<UndefValue>(RHS)) ||
             (Mask[i] <  e && isa<UndefValue>(LHS)))
           Mask[i] = 2*e;     // Turn into undef.
         else
           Mask[i] &= (e-1);  // Force to LHS.
-        Elts.push_back(ConstantInt::get(Type::UIntTy, Mask[i]));
+        Elts.push_back(ConstantInt::get(Type::Int32Ty, Mask[i]));
       }
     }
     SVI.setOperand(0, SVI.getOperand(1));
@@ -8970,9 +8911,9 @@
         std::vector<Constant*> Elts;
         for (unsigned i = 0, e = NewMask.size(); i != e; ++i) {
           if (NewMask[i] >= e*2) {
-            Elts.push_back(UndefValue::get(Type::UIntTy));
+            Elts.push_back(UndefValue::get(Type::Int32Ty));
           } else {
-            Elts.push_back(ConstantInt::get(Type::UIntTy, NewMask[i]));
+            Elts.push_back(ConstantInt::get(Type::Int32Ty, NewMask[i]));
           }
         }
         return new ShuffleVectorInst(LHSSVI->getOperand(0),


Index: llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
diff -u llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.102 llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.103
--- llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:1.102	Sat Dec 23 00:05:41 2006
+++ llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp	Sat Dec 30 23:48:39 2006
@@ -86,8 +86,8 @@
     Value      *IncV;
 
     IVExpr()
-      : Stride(SCEVUnknown::getIntegerSCEV(0, Type::UIntTy)),
-        Base  (SCEVUnknown::getIntegerSCEV(0, Type::UIntTy)) {}
+      : Stride(SCEVUnknown::getIntegerSCEV(0, Type::Int32Ty)),
+        Base  (SCEVUnknown::getIntegerSCEV(0, Type::Int32Ty)) {}
     IVExpr(const SCEVHandle &stride, const SCEVHandle &base, PHINode *phi,
            Value *incv)
       : Stride(stride), Base(base), PHI(phi), IncV(incv) {}
@@ -334,12 +334,6 @@
          << "] Variable stride: " << *AddRec << "\n";
 
   Stride = AddRec->getOperand(1);
-  // Check that all constant strides are the unsigned type, we don't want to
-  // have two IV's one of signed stride 4 and one of unsigned stride 4 to not be
-  // merged.
-  assert((!isa<SCEVConstant>(Stride) || Stride->getType()->isUnsigned()) &&
-         "Constants should be canonicalized to unsigned!");
-
   return true;
 }
 
@@ -899,7 +893,7 @@
       if (unsigned(abs(SInt)) < Scale || (SInt % Scale) != 0)
         continue;
       std::map<SCEVHandle, IVsOfOneStride>::iterator SI =
-        IVsByStride.find(SCEVUnknown::getIntegerSCEV(SInt/Scale, Type::UIntTy));
+        IVsByStride.find(SCEVUnknown::getIntegerSCEV(SInt/Scale, Type::Int32Ty));
       if (SI == IVsByStride.end())
         continue;
       for (std::vector<IVExpr>::iterator II = SI->second.IVs.begin(),


Index: llvm/lib/Transforms/Scalar/LowerGC.cpp
diff -u llvm/lib/Transforms/Scalar/LowerGC.cpp:1.16 llvm/lib/Transforms/Scalar/LowerGC.cpp:1.17
--- llvm/lib/Transforms/Scalar/LowerGC.cpp:1.16	Tue Dec 12 18:50:17 2006
+++ llvm/lib/Transforms/Scalar/LowerGC.cpp	Sat Dec 30 23:48:39 2006
@@ -83,7 +83,7 @@
     MainRootRecordType ? (Type*)MainRootRecordType : (Type*)OpaqueType::get();
   ST.clear();
   ST.push_back(PointerType::get(RootListH));         // Prev pointer
-  ST.push_back(Type::UIntTy);                        // NumElements in array
+  ST.push_back(Type::Int32Ty);                       // NumElements in array
   ST.push_back(PairArrTy);                           // The pairs
   StructType *RootList = StructType::get(ST);
   if (MainRootRecordType)
@@ -103,7 +103,7 @@
   GCWriteInt = M.getNamedFunction("llvm.gcwrite");
   if (!GCRootInt && !GCReadInt && !GCWriteInt) return false;
 
-  PointerType *VoidPtr = PointerType::get(Type::SByteTy);
+  PointerType *VoidPtr = PointerType::get(Type::Int8Ty);
   PointerType *VoidPtrPtr = PointerType::get(VoidPtr);
 
   // If the program is using read/write barriers, find the implementations of
@@ -159,7 +159,7 @@
   // Quick exit for programs that are not using GC mechanisms.
   if (!GCRootInt && !GCReadInt && !GCWriteInt) return false;
 
-  PointerType *VoidPtr    = PointerType::get(Type::SByteTy);
+  PointerType *VoidPtr    = PointerType::get(Type::Int8Ty);
   PointerType *VoidPtrPtr = PointerType::get(VoidPtr);
 
   // If there are read/write barriers in the program, perform a quick pass over
@@ -225,8 +225,8 @@
   BasicBlock::iterator IP = AI;
   while (isa<AllocaInst>(IP)) ++IP;
 
-  Constant *Zero = ConstantInt::get(Type::UIntTy, 0);
-  Constant *One  = ConstantInt::get(Type::UIntTy, 1);
+  Constant *Zero = ConstantInt::get(Type::Int32Ty, 0);
+  Constant *One  = ConstantInt::get(Type::Int32Ty, 1);
 
   // Get a pointer to the prev pointer.
   std::vector<Value*> Par;
@@ -240,11 +240,11 @@
   new StoreInst(PrevPtr, PrevPtrPtr, IP);
 
   // Set the number of elements in this record.
-  Par[1] = ConstantInt::get(Type::UIntTy, 1);
+  Par[1] = ConstantInt::get(Type::Int32Ty, 1);
   Value *NumEltsPtr = new GetElementPtrInst(AI, Par, "numeltsptr", IP);
-  new StoreInst(ConstantInt::get(Type::UIntTy, GCRoots.size()), NumEltsPtr,IP);
+  new StoreInst(ConstantInt::get(Type::Int32Ty, GCRoots.size()), NumEltsPtr,IP);
 
-  Par[1] = ConstantInt::get(Type::UIntTy, 2);
+  Par[1] = ConstantInt::get(Type::Int32Ty, 2);
   Par.resize(4);
 
   const PointerType *PtrLocTy =
@@ -254,7 +254,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] = ConstantInt::get(Type::UIntTy, i);
+    Par[2] = ConstantInt::get(Type::Int32Ty, 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.14 llvm/lib/Transforms/Scalar/LowerPacked.cpp:1.15
--- llvm/lib/Transforms/Scalar/LowerPacked.cpp:1.14	Sat Dec 23 00:05:41 2006
+++ llvm/lib/Transforms/Scalar/LowerPacked.cpp	Sat Dec 30 23:48:39 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] = ConstantInt::get(Type::UIntTy,0);
+       Idx[0] = ConstantInt::get(Type::Int32Ty,0);
 
        ArrayType* AT = ArrayType::get(PKT->getContainedType(0),
                                       PKT->getNumElements());
@@ -225,7 +225,7 @@
 
        for (unsigned i = 0, e = PKT->getNumElements(); i != e; ++i) {
             // Calculate the second index we will need
-            Idx[1] = ConstantInt::get(Type::UIntTy,i);
+            Idx[1] = ConstantInt::get(Type::Int32Ty,i);
 
             // Get the pointer
             Value* val = new GetElementPtrInst(array,
@@ -308,7 +308,7 @@
        dyn_cast<PackedType>(SI.getOperand(0)->getType())) {
        // We will need this for getelementptr
        std::vector<Value*> Idx(2);
-       Idx[0] = ConstantInt::get(Type::UIntTy,0);
+       Idx[0] = ConstantInt::get(Type::Int32Ty,0);
 
        ArrayType* AT = ArrayType::get(PKT->getContainedType(0),
                                       PKT->getNumElements());
@@ -325,7 +325,7 @@
 
        for (unsigned i = 0, e = PKT->getNumElements(); i != e; ++i) {
             // Generate the indices for getelementptr
-            Idx[1] = ConstantInt::get(Type::UIntTy,i);
+            Idx[1] = ConstantInt::get(Type::Int32Ty,i);
             Value* val = new GetElementPtrInst(array,
                                                Idx,
                                                "store.ge." +
@@ -375,12 +375,12 @@
   } else {
     AllocaInst *alloca = 
       new AllocaInst(PTy->getElementType(),
-                     ConstantInt::get(Type::UIntTy, PTy->getNumElements()),
+                     ConstantInt::get(Type::Int32Ty, PTy->getNumElements()),
                      EI.getName() + ".alloca", 
 		     EI.getParent()->getParent()->getEntryBlock().begin());
     for (unsigned i = 0; i < PTy->getNumElements(); ++i) {
       GetElementPtrInst *GEP = 
-        new GetElementPtrInst(alloca, ConstantInt::get(Type::UIntTy, i),
+        new GetElementPtrInst(alloca, ConstantInt::get(Type::Int32Ty, i),
                               "store.ge", &EI);
       new StoreInst(op0Vals[i], GEP, &EI);
     }
@@ -411,7 +411,7 @@
     for (unsigned i = 0; i != Vals.size(); ++i) {
       ICmpInst *icmp =
         new ICmpInst(ICmpInst::ICMP_EQ, Idx, 
-                     ConstantInt::get(Type::UIntTy, i),
+                     ConstantInt::get(Type::Int32Ty, i),
                      "icmp", &IE);
       SelectInst *select =
         new SelectInst(icmp, Elt, Vals[i], "select", &IE);


Index: llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp
diff -u llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.61 llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.62
--- llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp:1.61	Sat Dec 23 00:05:41 2006
+++ llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp	Sat Dec 30 23:48:39 2006
@@ -226,7 +226,7 @@
         //
         std::string OldName = GEPI->getName();  // Steal the old name.
         std::vector<Value*> NewArgs;
-        NewArgs.push_back(Constant::getNullValue(Type::IntTy));
+        NewArgs.push_back(Constant::getNullValue(Type::Int32Ty));
         NewArgs.insert(NewArgs.end(), GEPI->op_begin()+3, GEPI->op_end());
         GEPI->setName("");
         RepValue = new GetElementPtrInst(AllocaToUse, NewArgs, OldName, GEPI);
@@ -389,7 +389,7 @@
 
       if (!isa<ConstantInt>(I.getOperand())) {
         if (NumElements == 1) {
-          GEPI->setOperand(2, Constant::getNullValue(Type::IntTy));
+          GEPI->setOperand(2, Constant::getNullValue(Type::Int32Ty));
         } else {
           assert(NumElements == 2 && "Unhandled case!");
           // All users of the GEP must be loads.  At each use of the GEP, insert
@@ -399,10 +399,10 @@
              "isone", GEPI);
           // Insert the new GEP instructions, which are properly indexed.
           std::vector<Value*> Indices(GEPI->op_begin()+1, GEPI->op_end());
-          Indices[1] = Constant::getNullValue(Type::IntTy);
+          Indices[1] = Constant::getNullValue(Type::Int32Ty);
           Value *ZeroIdx = new GetElementPtrInst(GEPI->getOperand(0), Indices,
                                                  GEPI->getName()+".0", GEPI);
-          Indices[1] = ConstantInt::get(Type::IntTy, 1);
+          Indices[1] = ConstantInt::get(Type::Int32Ty, 1);
           Value *OneIdx = new GetElementPtrInst(GEPI->getOperand(0), Indices,
                                                 GEPI->getName()+".1", GEPI);
           // Replace all loads of the variable index GEP with loads from both
@@ -468,8 +468,8 @@
     // Pointer/FP/Integer unions merge together as integers.
     switch (Accum->getTypeID()) {
     case Type::PointerTyID: Accum = TD.getIntPtrType(); break;
-    case Type::FloatTyID:   Accum = Type::UIntTy; break;
-    case Type::DoubleTyID:  Accum = Type::ULongTy; break;
+    case Type::FloatTyID:   Accum = Type::Int32Ty; break;
+    case Type::DoubleTyID:  Accum = Type::Int64Ty; break;
     default:
       assert(Accum->isIntegral() && "Unknown FP type!");
       break;
@@ -477,8 +477,8 @@
     
     switch (In->getTypeID()) {
     case Type::PointerTyID: In = TD.getIntPtrType(); break;
-    case Type::FloatTyID:   In = Type::UIntTy; break;
-    case Type::DoubleTyID:  In = Type::ULongTy; break;
+    case Type::FloatTyID:   In = Type::Int32Ty; break;
+    case Type::DoubleTyID:  In = Type::Int64Ty; break;
     default:
       assert(In->isIntegral() && "Unknown FP type!");
       break;
@@ -493,10 +493,10 @@
 /// null.
 const Type *getUIntAtLeastAsBitAs(unsigned NumBits) {
   if (NumBits > 64) return 0;
-  if (NumBits > 32) return Type::ULongTy;
-  if (NumBits > 16) return Type::UIntTy;
-  if (NumBits > 8) return Type::UShortTy;
-  return Type::UByteTy;    
+  if (NumBits > 32) return Type::Int64Ty;
+  if (NumBits > 16) return Type::Int32Ty;
+  if (NumBits > 8) return Type::Int16Ty;
+  return Type::Int8Ty;    
 }
 
 /// CanConvertToScalar - V is a pointer.  If we can convert the pointee to a
@@ -610,9 +610,6 @@
          "Not in the entry block!");
   EntryBlock->getInstList().remove(AI);  // Take the alloca out of the program.
   
-  if (ActualTy->isInteger())
-    ActualTy = ActualTy->getUnsignedVersion();
-  
   // Create and insert the alloca.
   AllocaInst *NewAI = new AllocaInst(ActualTy, 0, AI->getName(),
                                      EntryBlock->begin());
@@ -646,7 +643,7 @@
           } else {
             // Must be an element access.
             unsigned Elt = Offset/(TD.getTypeSize(PTy->getElementType())*8);
-            NV = new ExtractElementInst(NV, ConstantInt::get(Type::UIntTy, Elt),
+            NV = new ExtractElementInst(NV, ConstantInt::get(Type::Int32Ty, Elt),
                                         "tmp", LI);
           }
         } else if (isa<PointerType>(NV->getType())) {
@@ -658,7 +655,7 @@
           assert(NV->getType()->isInteger() && "Unknown promotion!");
           if (Offset && Offset < TD.getTypeSize(NV->getType())*8) {
             NV = new ShiftInst(Instruction::LShr, NV, 
-                               ConstantInt::get(Type::UByteTy, Offset), 
+                               ConstantInt::get(Type::Int8Ty, Offset), 
                                LI->getName(), LI);
           }
           
@@ -673,10 +670,10 @@
               switch (LI->getType()->getTypeID()) {
               default: assert(0 && "Unknown FP type!");
               case Type::FloatTyID:
-                NV = new TruncInst(NV, Type::UIntTy, LI->getName(), LI);
+                NV = new TruncInst(NV, Type::Int32Ty, LI->getName(), LI);
                 break;
               case Type::DoubleTyID:
-                NV = new TruncInst(NV, Type::ULongTy, LI->getName(), LI);
+                NV = new TruncInst(NV, Type::Int64Ty, LI->getName(), LI);
                 break;
               }
             }
@@ -710,7 +707,7 @@
             // Must be an element insertion.
             unsigned Elt = Offset/(TD.getTypeSize(PTy->getElementType())*8);
             SV = new InsertElementInst(Old, SV,
-                                       ConstantInt::get(Type::UIntTy, Elt),
+                                       ConstantInt::get(Type::Int32Ty, Elt),
                                        "tmp", SI);
           }
         } else {
@@ -722,10 +719,10 @@
             assert(!SV->getType()->isFloatingPoint() && "Unknown FP type!");
             break;
           case Type::FloatTyID:
-            SV = new BitCastInst(SV, Type::UIntTy, SV->getName(), SI);
+            SV = new BitCastInst(SV, Type::Int32Ty, SV->getName(), SI);
             break;
           case Type::DoubleTyID:
-            SV = new BitCastInst(SV, Type::ULongTy, SV->getName(), SI);
+            SV = new BitCastInst(SV, Type::Int64Ty, SV->getName(), SI);
             break;
           case Type::PointerTyID:
             if (isa<PointerType>(AllocaType))
@@ -743,7 +740,7 @@
                                                SV->getName(), SI);
           if (Offset && Offset < AllocaType->getPrimitiveSizeInBits())
             SV = new ShiftInst(Instruction::Shl, SV,
-                               ConstantInt::get(Type::UByteTy, Offset),
+                               ConstantInt::get(Type::Int8Ty, 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;






More information about the llvm-commits mailing list