For PR950:
This patch implements the first increment for the Signless Types feature.
All changes pertain to removing the ConstantSInt and ConstantUInt classes
in favor of just using ConstantInt.

llvm-svn: 31063
diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
index 5183d43..79f21b5 100644
--- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -307,8 +307,8 @@
       unsigned idx = 0;
       for (; idx < LHS.size() && idx < RHS.size(); ++idx) {
         if (LHS[idx] != RHS[idx]) {
-          return cast<ConstantInt>(LHS[idx])->getRawValue() <
-                 cast<ConstantInt>(RHS[idx])->getRawValue();
+          return cast<ConstantInt>(LHS[idx])->getZExtValue() <
+                 cast<ConstantInt>(RHS[idx])->getZExtValue();
         }
       }
 
@@ -518,7 +518,7 @@
           std::string NewName = I->getName();
           for (unsigned i = 0, e = Operands.size(); i != e; ++i)
             if (ConstantInt *CI = dyn_cast<ConstantInt>(Operands[i]))
-              NewName += "."+itostr((int64_t)CI->getRawValue());
+              NewName += "."+itostr((int64_t)CI->getZExtValue());
             else
               NewName += ".x";
           TheArg->setName(NewName+".val");
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index 5abd290..fc39fe8 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -270,7 +270,7 @@
 static Constant *getAggregateConstantElement(Constant *Agg, Constant *Idx) {
   ConstantInt *CI = dyn_cast<ConstantInt>(Idx);
   if (!CI) return 0;
-  unsigned IdxV = (unsigned)CI->getRawValue();
+  unsigned IdxV = CI->getZExtValue();
 
   if (ConstantStruct *CS = dyn_cast<ConstantStruct>(Agg)) {
     if (IdxV < CS->getNumOperands()) return CS->getOperand(IdxV);
@@ -384,7 +384,7 @@
     NewGlobals.reserve(STy->getNumElements());
     for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
       Constant *In = getAggregateConstantElement(Init,
-                                            ConstantUInt::get(Type::UIntTy, i));
+                                            ConstantInt::get(Type::UIntTy, i));
       assert(In && "Couldn't get element of initializer?");
       GlobalVariable *NGV = new GlobalVariable(STy->getElementType(i), false,
                                                GlobalVariable::InternalLinkage,
@@ -406,7 +406,7 @@
     NewGlobals.reserve(NumElements);
     for (unsigned i = 0, e = NumElements; i != e; ++i) {
       Constant *In = getAggregateConstantElement(Init,
-                                            ConstantUInt::get(Type::UIntTy, i));
+                                            ConstantInt::get(Type::UIntTy, i));
       assert(In && "Couldn't get element of initializer?");
 
       GlobalVariable *NGV = new GlobalVariable(STy->getElementType(), false,
@@ -435,8 +435,7 @@
     // Ignore the 1th operand, which has to be zero or else the program is quite
     // broken (undefined).  Get the 2nd operand, which is the structure or array
     // index.
-    unsigned Val =
-       (unsigned)cast<ConstantInt>(GEP->getOperand(2))->getRawValue();
+    unsigned Val = cast<ConstantInt>(GEP->getOperand(2))->getZExtValue();
     if (Val >= NewGlobals.size()) Val = 0; // Out of bound array access.
 
     Value *NewPtr = NewGlobals[Val];
@@ -673,11 +672,11 @@
   DEBUG(std::cerr << "PROMOTING MALLOC GLOBAL: " << *GV << "  MALLOC = " <<*MI);
   ConstantInt *NElements = cast<ConstantInt>(MI->getArraySize());
 
-  if (NElements->getRawValue() != 1) {
+  if (NElements->getZExtValue() != 1) {
     // If we have an array allocation, transform it to a single element
     // allocation to make the code below simpler.
     Type *NewTy = ArrayType::get(MI->getAllocatedType(),
-                                 (unsigned)NElements->getRawValue());
+                                 NElements->getZExtValue());
     MallocInst *NewMI =
       new MallocInst(NewTy, Constant::getNullValue(Type::UIntTy),
                      MI->getAlignment(), MI->getName(), MI);
@@ -886,11 +885,12 @@
     
     // Otherwise, this should be: 'getelementptr Ptr, Idx, uint FieldNo ...'
     GetElementPtrInst *GEPI = cast<GetElementPtrInst>(User);
-    assert(GEPI->getNumOperands() >= 3 && isa<ConstantUInt>(GEPI->getOperand(2))
+    assert(GEPI->getNumOperands() >= 3 && isa<ConstantInt>(GEPI->getOperand(2))
+           && GEPI->getOperand(2)->getType()->isUnsigned()
            && "Unexpected GEPI!");
     
     // Load the pointer for this field.
-    unsigned FieldNo = cast<ConstantUInt>(GEPI->getOperand(2))->getValue();
+    unsigned FieldNo = cast<ConstantInt>(GEPI->getOperand(2))->getZExtValue();
     if (InsertedLoadsForPtr.size() <= FieldNo)
       InsertedLoadsForPtr.resize(FieldNo+1);
     if (InsertedLoadsForPtr[FieldNo] == 0)
@@ -1088,7 +1088,7 @@
         // Restrict this transformation to only working on small allocations
         // (2048 bytes currently), as we don't want to introduce a 16M global or
         // something.
-        if (NElements->getRawValue()*
+        if (NElements->getZExtValue()*
                      TD.getTypeSize(MI->getAllocatedType()) < 2048) {
           GVI = OptimizeGlobalAddressOfMalloc(GV, MI);
           return true;
@@ -1431,7 +1431,7 @@
           
           // Init priority must be standard.
           ConstantInt *CI = dyn_cast<ConstantInt>(CS->getOperand(0));
-          if (!CI || CI->getRawValue() != 65535)
+          if (!CI || CI->getZExtValue() != 65535)
             return 0;
         } else {
           return 0;
@@ -1461,7 +1461,7 @@
                                           const std::vector<Function*> &Ctors) {
   // If we made a change, reassemble the initializer list.
   std::vector<Constant*> CSVals;
-  CSVals.push_back(ConstantSInt::get(Type::IntTy, 65535));
+  CSVals.push_back(ConstantInt::get(Type::IntTy, 65535));
   CSVals.push_back(0);
   
   // Create the new init list.
@@ -1474,7 +1474,7 @@
                                           std::vector<const Type*>(), false);
       const PointerType *PFTy = PointerType::get(FTy);
       CSVals[1] = Constant::getNullValue(PFTy);
-      CSVals[0] = ConstantSInt::get(Type::IntTy, 2147483647);
+      CSVals[0] = ConstantInt::get(Type::IntTy, 2147483647);
     }
     CAList.push_back(ConstantStruct::get(CSVals));
   }
@@ -1575,10 +1575,9 @@
     }
     
     // Replace the element that we are supposed to.
-    ConstantUInt *CU = cast<ConstantUInt>(Addr->getOperand(OpNo));
-    assert(CU->getValue() < STy->getNumElements() &&
-           "Struct index out of range!");
-    unsigned Idx = (unsigned)CU->getValue();
+    ConstantInt *CU = cast<ConstantInt>(Addr->getOperand(OpNo));
+    unsigned Idx = CU->getZExtValue();
+    assert(Idx < STy->getNumElements() && "Struct index out of range!");
     Elts[Idx] = EvaluateStoreInto(Elts[Idx], Val, Addr, OpNo+1);
     
     // Return the modified struct.
@@ -1603,9 +1602,9 @@
              " ConstantFoldLoadThroughGEPConstantExpr");
     }
     
-    assert((uint64_t)CI->getRawValue() < ATy->getNumElements());
-    Elts[(uint64_t)CI->getRawValue()] =
-      EvaluateStoreInto(Elts[(uint64_t)CI->getRawValue()], Val, Addr, OpNo+1);
+    assert(CI->getZExtValue() < ATy->getNumElements());
+    Elts[CI->getZExtValue()] =
+      EvaluateStoreInto(Elts[CI->getZExtValue()], Val, Addr, OpNo+1);
     return ConstantArray::get(ATy, Elts);
   }    
 }
diff --git a/llvm/lib/Transforms/IPO/LowerSetJmp.cpp b/llvm/lib/Transforms/IPO/LowerSetJmp.cpp
index 8018553..cd46718 100644
--- a/llvm/lib/Transforms/IPO/LowerSetJmp.cpp
+++ b/llvm/lib/Transforms/IPO/LowerSetJmp.cpp
@@ -378,7 +378,7 @@
   CastInst* BufPtr = new CastInst(Inst->getOperand(1), SBPTy, "SBJmpBuf", Inst);
   new CallInst(AddSJToMap,
                make_vector<Value*>(GetSetJmpMap(Func), BufPtr,
-                                   ConstantUInt::get(Type::UIntTy,
+                                   ConstantInt::get(Type::UIntTy,
                                                      SetJmpIDMap[Func]++), 0),
                "", Inst);
 
@@ -429,7 +429,7 @@
 
   // Add the case for this setjmp's number...
   SwitchValuePair SVP = GetSJSwitch(Func, GetRethrowBB(Func));
-  SVP.first->addCase(ConstantUInt::get(Type::UIntTy, SetJmpIDMap[Func] - 1),
+  SVP.first->addCase(ConstantInt::get(Type::UIntTy, SetJmpIDMap[Func] - 1),
                      SetJmpContBlock);
 
   // Value coming from the handling of the exception.
diff --git a/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp b/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
index 9f9c527..23f3352ce 100644
--- a/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
@@ -517,8 +517,8 @@
     std::vector<Value*> vals;
     vals.push_back(gep); // destination
     vals.push_back(ci->getOperand(2)); // source
-    vals.push_back(ConstantUInt::get(SLC.getIntPtrType(),len)); // length
-    vals.push_back(ConstantUInt::get(Type::UIntTy,1)); // alignment
+    vals.push_back(ConstantInt::get(SLC.getIntPtrType(),len)); // length
+    vals.push_back(ConstantInt::get(Type::UIntTy,1)); // alignment
     new CallInst(SLC.get_memcpy(), vals, "", ci);
 
     // Finally, substitute the first operand of the strcat call for the
@@ -556,38 +556,38 @@
     // Check that the first argument to strchr is a constant array of sbyte.
     // If it is, get the length and data, otherwise return false.
     uint64_t len = 0;
-    ConstantArray* CA;
+    ConstantArray* CA = 0;
     if (!getConstantStringLength(ci->getOperand(1),len,&CA))
       return false;
 
-    // Check that the second argument to strchr is a constant int, return false
-    // if it isn't
-    ConstantSInt* CSI = dyn_cast<ConstantSInt>(ci->getOperand(2));
-    if (!CSI) {
-      // Just lower this to memchr since we know the length of the string as
-      // it is constant.
+    // Check that the second argument to strchr is a constant int. If it isn't
+    // a constant signed integer, we can try an alternate optimization
+    ConstantInt* CSI = dyn_cast<ConstantInt>(ci->getOperand(2));
+    if (!CSI || CSI->getType()->isUnsigned() ) {
+      // The second operand is not constant, or not signed. Just lower this to 
+      // memchr since we know the length of the string since it is constant.
       Function* f = SLC.get_memchr();
       std::vector<Value*> args;
       args.push_back(ci->getOperand(1));
       args.push_back(ci->getOperand(2));
-      args.push_back(ConstantUInt::get(SLC.getIntPtrType(),len));
+      args.push_back(ConstantInt::get(SLC.getIntPtrType(),len));
       ci->replaceAllUsesWith( new CallInst(f,args,ci->getName(),ci));
       ci->eraseFromParent();
       return true;
     }
 
     // Get the character we're looking for
-    int64_t chr = CSI->getValue();
+    int64_t chr = CSI->getSExtValue();
 
     // Compute the offset
     uint64_t offset = 0;
     bool char_found = false;
     for (uint64_t i = 0; i < len; ++i) {
-      if (ConstantSInt* CI = dyn_cast<ConstantSInt>(CA->getOperand(i))) {
+      if (ConstantInt* CI = dyn_cast<ConstantInt>(CA->getOperand(i))) {
         // Check for the null terminator
         if (CI->isNullValue())
           break; // we found end of string
-        else if (CI->getValue() == chr) {
+        else if (CI->getSExtValue() == chr) {
           char_found = true;
           offset = i;
           break;
@@ -599,7 +599,7 @@
     //    (if c is a constant integer and s is a constant string)
     if (char_found) {
       std::vector<Value*> indices;
-      indices.push_back(ConstantUInt::get(Type::ULongTy,offset));
+      indices.push_back(ConstantInt::get(Type::ULongTy,offset));
       GetElementPtrInst* GEP = new GetElementPtrInst(ci->getOperand(1),indices,
           ci->getOperand(1)->getName()+".strchr",ci);
       ci->replaceAllUsesWith(GEP);
@@ -679,7 +679,7 @@
       std::string str1 = A1->getAsString();
       std::string str2 = A2->getAsString();
       int result = strcmp(str1.c_str(), str2.c_str());
-      ci->replaceAllUsesWith(ConstantSInt::get(Type::IntTy,result));
+      ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,result));
       ci->eraseFromParent();
       return true;
     }
@@ -723,7 +723,7 @@
     bool len_arg_is_const = false;
     if (ConstantInt* len_CI = dyn_cast<ConstantInt>(ci->getOperand(3))) {
       len_arg_is_const = true;
-      len_arg = len_CI->getRawValue();
+      len_arg = len_CI->getZExtValue();
       if (len_arg == 0) {
         // strncmp(x,y,0)   -> 0
         ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,0));
@@ -769,7 +769,7 @@
       std::string str1 = A1->getAsString();
       std::string str2 = A2->getAsString();
       int result = strncmp(str1.c_str(), str2.c_str(), len_arg);
-      ci->replaceAllUsesWith(ConstantSInt::get(Type::IntTy,result));
+      ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,result));
       ci->eraseFromParent();
       return true;
     }
@@ -843,8 +843,8 @@
     std::vector<Value*> vals;
     vals.push_back(dest); // destination
     vals.push_back(src); // source
-    vals.push_back(ConstantUInt::get(SLC.getIntPtrType(),len)); // length
-    vals.push_back(ConstantUInt::get(Type::UIntTy,1)); // alignment
+    vals.push_back(ConstantInt::get(SLC.getIntPtrType(),len)); // length
+    vals.push_back(ConstantInt::get(Type::UIntTy,1)); // alignment
     new CallInst(SLC.get_memcpy(), vals, "", ci);
 
     // Finally, substitute the first operand of the strcat call for the
@@ -891,7 +891,7 @@
         if (ConstantInt* CI = dyn_cast<ConstantInt>(bop->getOperand(1)))
         {
           // Get the value the strlen result is compared to
-          uint64_t val = CI->getRawValue();
+          uint64_t val = CI->getZExtValue();
 
           // If its compared against length 0 with == or !=
           if (val == 0 &&
@@ -902,7 +902,7 @@
             // strlen(x) == 0 -> *x == 0
             LoadInst* load = new LoadInst(str,str->getName()+".first",ci);
             BinaryOperator* rbop = BinaryOperator::create(bop->getOpcode(),
-              load, ConstantSInt::get(Type::SByteTy,0),
+              load, ConstantInt::get(Type::SByteTy,0),
               bop->getName()+".strlen", ci);
             bop->replaceAllUsesWith(rbop);
             bop->eraseFromParent();
@@ -919,9 +919,9 @@
     // strlen("xyz") -> 3 (for example)
     const Type *Ty = SLC.getTargetData()->getIntPtrType();
     if (Ty->isSigned())
-      ci->replaceAllUsesWith(ConstantSInt::get(Ty, len));
+      ci->replaceAllUsesWith(ConstantInt::get(Ty, len));
     else
-      ci->replaceAllUsesWith(ConstantUInt::get(Ty, len));
+      ci->replaceAllUsesWith(ConstantInt::get(Ty, len));
      
     ci->eraseFromParent();
     return true;
@@ -985,7 +985,7 @@
     // Make sure we have a constant length.
     ConstantInt *LenC = dyn_cast<ConstantInt>(CI->getOperand(3));
     if (!LenC) return false;
-    uint64_t Len = LenC->getRawValue();
+    uint64_t Len = LenC->getZExtValue();
       
     // If the length is zero, this returns 0.
     switch (Len) {
@@ -1075,8 +1075,8 @@
       return false;
 
     // If the length is larger than the alignment, we can't optimize
-    uint64_t len = LEN->getRawValue();
-    uint64_t alignment = ALIGN->getRawValue();
+    uint64_t len = LEN->getZExtValue();
+    uint64_t alignment = ALIGN->getZExtValue();
     if (alignment == 0)
       alignment = 1; // Alignment 0 is identity for alignment 1
     if (len > alignment)
@@ -1154,8 +1154,8 @@
       return false;
 
     // Extract the length and alignment
-    uint64_t len = LEN->getRawValue();
-    uint64_t alignment = ALIGN->getRawValue();
+    uint64_t len = LEN->getZExtValue();
+    uint64_t alignment = ALIGN->getZExtValue();
 
     // Alignment 0 is identity for alignment 1
     if (alignment == 0)
@@ -1174,7 +1174,7 @@
 
     // Make sure we have a constant ubyte to work with so we can extract
     // the value to be filled.
-    ConstantUInt* FILL = dyn_cast<ConstantUInt>(ci->getOperand(2));
+    ConstantInt* FILL = dyn_cast<ConstantInt>(ci->getOperand(2));
     if (!FILL)
       return false;
     if (FILL->getType() != Type::UByteTy)
@@ -1183,7 +1183,7 @@
     // memset(s,c,n) -> store s, c (for n=1,2,4,8)
 
     // Extract the fill character
-    uint64_t fill_char = FILL->getValue();
+    uint64_t fill_char = FILL->getZExtValue();
     uint64_t fill_value = fill_char;
 
     // Get the type we will cast to, based on size of memory area to fill, and
@@ -1215,7 +1215,7 @@
     // Cast dest to the right sized primitive and then load/store
     CastInst* DestCast =
       new CastInst(dest,PointerType::get(castType),dest->getName()+".cast",ci);
-    new StoreInst(ConstantUInt::get(castType,fill_value),DestCast, ci);
+    new StoreInst(ConstantInt::get(castType,fill_value),DestCast, ci);
     ci->eraseFromParent();
     return true;
   }
@@ -1325,16 +1325,16 @@
 
     // The first character has to be a %
     if (ConstantInt* CI = dyn_cast<ConstantInt>(CA->getOperand(0)))
-      if (CI->getRawValue() != '%')
+      if (CI->getZExtValue() != '%')
         return false;
 
     // Get the second character and switch on its value
     ConstantInt* CI = dyn_cast<ConstantInt>(CA->getOperand(1));
-    switch (CI->getRawValue()) {
+    switch (CI->getZExtValue()) {
       case 's':
       {
         if (len != 3 ||
-            dyn_cast<ConstantInt>(CA->getOperand(2))->getRawValue() != '\n')
+            dyn_cast<ConstantInt>(CA->getOperand(2))->getZExtValue() != '\n')
           return false;
 
         // printf("%s\n",str) -> puts(str)
@@ -1344,7 +1344,7 @@
         std::vector<Value*> args;
         args.push_back(CastToCStr(ci->getOperand(2), *ci));
         new CallInst(puts_func,args,ci->getName(),ci);
-        ci->replaceAllUsesWith(ConstantSInt::get(Type::IntTy,len));
+        ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,len));
         break;
       }
       case 'c':
@@ -1359,7 +1359,7 @@
         CastInst* cast = new CastInst(ci->getOperand(2), Type::IntTy,
                                       CI->getName()+".int", ci);
         new CallInst(putchar_func, cast, "", ci);
-        ci->replaceAllUsesWith(ConstantSInt::get(Type::IntTy, 1));
+        ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy, 1));
         break;
       }
       default:
@@ -1409,7 +1409,7 @@
       for (unsigned i = 0; i < len; ++i) {
         if (ConstantInt* CI = dyn_cast<ConstantInt>(CA->getOperand(i))) {
           // Check for the null terminator
-          if (CI->getRawValue() == '%')
+          if (CI->getZExtValue() == '%')
             return false; // we found end of string
         } else {
           return false;
@@ -1430,11 +1430,11 @@
 
       std::vector<Value*> args;
       args.push_back(ci->getOperand(2));
-      args.push_back(ConstantUInt::get(SLC.getIntPtrType(),len));
-      args.push_back(ConstantUInt::get(SLC.getIntPtrType(),1));
+      args.push_back(ConstantInt::get(SLC.getIntPtrType(),len));
+      args.push_back(ConstantInt::get(SLC.getIntPtrType(),1));
       args.push_back(ci->getOperand(1));
       new CallInst(fwrite_func,args,ci->getName(),ci);
-      ci->replaceAllUsesWith(ConstantSInt::get(Type::IntTy,len));
+      ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,len));
       ci->eraseFromParent();
       return true;
     }
@@ -1446,12 +1446,12 @@
 
     // The first character has to be a %
     if (ConstantInt* CI = dyn_cast<ConstantInt>(CA->getOperand(0)))
-      if (CI->getRawValue() != '%')
+      if (CI->getZExtValue() != '%')
         return false;
 
     // Get the second character and switch on its value
     ConstantInt* CI = dyn_cast<ConstantInt>(CA->getOperand(1));
-    switch (CI->getRawValue()) {
+    switch (CI->getZExtValue()) {
       case 's':
       {
         uint64_t len = 0;
@@ -1464,11 +1464,11 @@
             return false;
           std::vector<Value*> args;
           args.push_back(CastToCStr(ci->getOperand(3), *ci));
-          args.push_back(ConstantUInt::get(SLC.getIntPtrType(),len));
-          args.push_back(ConstantUInt::get(SLC.getIntPtrType(),1));
+          args.push_back(ConstantInt::get(SLC.getIntPtrType(),len));
+          args.push_back(ConstantInt::get(SLC.getIntPtrType(),1));
           args.push_back(ci->getOperand(1));
           new CallInst(fwrite_func,args,ci->getName(),ci);
-          ci->replaceAllUsesWith(ConstantSInt::get(Type::IntTy,len));
+          ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,len));
         } else {
           // fprintf(file,"%s",str) -> fputs(str,file)
           const Type* FILEptr_type = ci->getOperand(1)->getType();
@@ -1479,7 +1479,7 @@
           args.push_back(CastToCStr(ci->getOperand(3), *ci));
           args.push_back(ci->getOperand(1));
           new CallInst(fputs_func,args,ci->getName(),ci);
-          ci->replaceAllUsesWith(ConstantSInt::get(Type::IntTy,len));
+          ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,len));
         }
         break;
       }
@@ -1493,7 +1493,7 @@
         CastInst* cast = new CastInst(ci->getOperand(3), Type::IntTy,
                                       CI->getName()+".int", ci);
         new CallInst(fputc_func,cast,ci->getOperand(1),"",ci);
-        ci->replaceAllUsesWith(ConstantSInt::get(Type::IntTy,1));
+        ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,1));
         break;
       }
       default:
@@ -1537,7 +1537,7 @@
       if (len == 0) {
         // If the length is 0, we just need to store a null byte
         new StoreInst(ConstantInt::get(Type::SByteTy,0),ci->getOperand(1),ci);
-        ci->replaceAllUsesWith(ConstantSInt::get(Type::IntTy,0));
+        ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,0));
         ci->eraseFromParent();
         return true;
       }
@@ -1546,7 +1546,7 @@
       for (unsigned i = 0; i < len; ++i) {
         if (ConstantInt* CI = dyn_cast<ConstantInt>(CA->getOperand(i))) {
           // Check for the null terminator
-          if (CI->getRawValue() == '%')
+          if (CI->getZExtValue() == '%')
             return false; // we found a %, can't optimize
         } else {
           return false; // initializer is not constant int, can't optimize
@@ -1563,10 +1563,10 @@
       std::vector<Value*> args;
       args.push_back(ci->getOperand(1));
       args.push_back(ci->getOperand(2));
-      args.push_back(ConstantUInt::get(SLC.getIntPtrType(),len));
-      args.push_back(ConstantUInt::get(Type::UIntTy,1));
+      args.push_back(ConstantInt::get(SLC.getIntPtrType(),len));
+      args.push_back(ConstantInt::get(Type::UIntTy,1));
       new CallInst(memcpy_func,args,"",ci);
-      ci->replaceAllUsesWith(ConstantSInt::get(Type::IntTy,len));
+      ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,len));
       ci->eraseFromParent();
       return true;
     }
@@ -1578,12 +1578,12 @@
 
     // The first character has to be a %
     if (ConstantInt* CI = dyn_cast<ConstantInt>(CA->getOperand(0)))
-      if (CI->getRawValue() != '%')
+      if (CI->getZExtValue() != '%')
         return false;
 
     // Get the second character and switch on its value
     ConstantInt* CI = dyn_cast<ConstantInt>(CA->getOperand(1));
-    switch (CI->getRawValue()) {
+    switch (CI->getZExtValue()) {
     case 's': {
       // sprintf(dest,"%s",str) -> llvm.memcpy(dest, str, strlen(str)+1, 1)
       Function* strlen_func = SLC.get_strlen();
@@ -1602,7 +1602,7 @@
       args.push_back(CastToCStr(ci->getOperand(1), *ci));
       args.push_back(CastToCStr(ci->getOperand(3), *ci));
       args.push_back(Len1);
-      args.push_back(ConstantUInt::get(Type::UIntTy,1));
+      args.push_back(ConstantInt::get(Type::UIntTy,1));
       new CallInst(memcpy_func, args, "", ci);
       
       // The strlen result is the unincremented number of bytes in the string.
@@ -1619,10 +1619,10 @@
       CastInst* cast = new CastInst(ci->getOperand(3),Type::SByteTy,"char",ci);
       new StoreInst(cast, ci->getOperand(1), ci);
       GetElementPtrInst* gep = new GetElementPtrInst(ci->getOperand(1),
-        ConstantUInt::get(Type::UIntTy,1),ci->getOperand(1)->getName()+".end",
+        ConstantInt::get(Type::UIntTy,1),ci->getOperand(1)->getName()+".end",
         ci);
       new StoreInst(ConstantInt::get(Type::SByteTy,0),gep,ci);
-      ci->replaceAllUsesWith(ConstantSInt::get(Type::IntTy,1));
+      ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,1));
       ci->eraseFromParent();
       return true;
     }
@@ -1686,8 +1686,8 @@
           return false;
         std::vector<Value*> parms;
         parms.push_back(ci->getOperand(1));
-        parms.push_back(ConstantUInt::get(SLC.getIntPtrType(),len));
-        parms.push_back(ConstantUInt::get(SLC.getIntPtrType(),1));
+        parms.push_back(ConstantInt::get(SLC.getIntPtrType(),len));
+        parms.push_back(ConstantInt::get(SLC.getIntPtrType(),1));
         parms.push_back(ci->getOperand(2));
         new CallInst(fwrite_func,parms,"",ci);
         break;
@@ -1716,11 +1716,11 @@
   virtual bool OptimizeCall(CallInst *ci, SimplifyLibCalls &SLC) {
     if (ConstantInt* CI = dyn_cast<ConstantInt>(ci->getOperand(1))) {
       // isdigit(c)   -> 0 or 1, if 'c' is constant
-      uint64_t val = CI->getRawValue();
+      uint64_t val = CI->getZExtValue();
       if (val >= '0' && val <='9')
-        ci->replaceAllUsesWith(ConstantSInt::get(Type::IntTy,1));
+        ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,1));
       else
-        ci->replaceAllUsesWith(ConstantSInt::get(Type::IntTy,0));
+        ci->replaceAllUsesWith(ConstantInt::get(Type::IntTy,0));
       ci->eraseFromParent();
       return true;
     }
@@ -1730,10 +1730,10 @@
       new CastInst(ci->getOperand(1),Type::UIntTy,
         ci->getOperand(1)->getName()+".uint",ci);
     BinaryOperator* sub_inst = BinaryOperator::createSub(cast,
-        ConstantUInt::get(Type::UIntTy,0x30),
+        ConstantInt::get(Type::UIntTy,0x30),
         ci->getOperand(1)->getName()+".sub",ci);
     SetCondInst* setcond_inst = new SetCondInst(Instruction::SetLE,sub_inst,
-        ConstantUInt::get(Type::UIntTy,9),
+        ConstantInt::get(Type::UIntTy,9),
         ci->getOperand(1)->getName()+".cmp",ci);
     CastInst* c2 =
       new CastInst(setcond_inst,Type::IntTy,
@@ -1760,7 +1760,7 @@
     Value *V = CI->getOperand(1);
     if (V->getType()->isSigned())
       V = new CastInst(V, V->getType()->getUnsignedVersion(), V->getName(), CI);
-    Value *Cmp = BinaryOperator::createSetLT(V, ConstantUInt::get(V->getType(),
+    Value *Cmp = BinaryOperator::createSetLT(V, ConstantInt::get(V->getType(),
                                                                   128),
                                              V->getName()+".isascii", CI);
     if (Cmp->getType() != CI->getType())
@@ -1828,7 +1828,7 @@
       // ffs(cnst)  -> bit#
       // ffsl(cnst) -> bit#
       // ffsll(cnst) -> bit#
-      uint64_t val = CI->getRawValue();
+      uint64_t val = CI->getZExtValue();
       int result = 0;
       if (val) {
         ++result;
@@ -1837,7 +1837,7 @@
           val >>= 1;
         }
       }
-      TheCall->replaceAllUsesWith(ConstantSInt::get(Type::IntTy, result));
+      TheCall->replaceAllUsesWith(ConstantInt::get(Type::IntTy, result));
       TheCall->eraseFromParent();
       return true;
     }
@@ -1861,7 +1861,7 @@
     Value *V = new CastInst(TheCall->getOperand(1), ArgType, "tmp", TheCall);
     Value *V2 = new CallInst(F, V, "tmp", TheCall);
     V2 = new CastInst(V2, Type::IntTy, "tmp", TheCall);
-    V2 = BinaryOperator::createAdd(V2, ConstantSInt::get(Type::IntTy, 1),
+    V2 = BinaryOperator::createAdd(V2, ConstantInt::get(Type::IntTy, 1),
                                    "tmp", TheCall);
     Value *Cond = 
       BinaryOperator::createSetEQ(V, Constant::getNullValue(V->getType()),
@@ -2048,7 +2048,7 @@
   // value. We'll need this later for indexing the ConstantArray.
   uint64_t start_idx = 0;
   if (ConstantInt* CI = dyn_cast<ConstantInt>(GEP->getOperand(2)))
-    start_idx = CI->getRawValue();
+    start_idx = CI->getZExtValue();
   else
     return false;
 
diff --git a/llvm/lib/Transforms/Instrumentation/EmitFunctions.cpp b/llvm/lib/Transforms/Instrumentation/EmitFunctions.cpp
index 05c3419..b452325 100644
--- a/llvm/lib/Transforms/Instrumentation/EmitFunctions.cpp
+++ b/llvm/lib/Transforms/Instrumentation/EmitFunctions.cpp
@@ -110,7 +110,7 @@
 
   M.getGlobalList().push_back(funcArray);
 
-  ConstantInt *cnst = ConstantSInt::get(Type::IntTy, counter);
+  ConstantInt *cnst = ConstantInt::get(Type::IntTy, counter);
   GlobalVariable *fnCount = new GlobalVariable(Type::IntTy, true,
                                                GlobalValue::ExternalLinkage,
                                                cnst, "llvmFunctionCount");
diff --git a/llvm/lib/Transforms/Instrumentation/ProfilingUtils.cpp b/llvm/lib/Transforms/Instrumentation/ProfilingUtils.cpp
index 82e7ae7..4c31793 100644
--- a/llvm/lib/Transforms/Instrumentation/ProfilingUtils.cpp
+++ b/llvm/lib/Transforms/Instrumentation/ProfilingUtils.cpp
@@ -51,7 +51,7 @@
     // pass null.
     Args[2] = ConstantPointerNull::get(UIntPtr);
   }
-  Args[3] = ConstantUInt::get(Type::UIntTy, NumElements);
+  Args[3] = ConstantInt::get(Type::UIntTy, NumElements);
 
   Instruction *InitCall = new CallInst(InitFn, Args, "newargc", InsertPos);
 
@@ -96,7 +96,7 @@
   // Create the getelementptr constant expression
   std::vector<Constant*> Indices(2);
   Indices[0] = Constant::getNullValue(Type::IntTy);
-  Indices[1] = ConstantSInt::get(Type::IntTy, CounterNum);
+  Indices[1] = ConstantInt::get(Type::IntTy, CounterNum);
   Constant *ElementPtr = ConstantExpr::getGetElementPtr(CounterArray, Indices);
 
   // Load, increment and store the value back.
diff --git a/llvm/lib/Transforms/Instrumentation/RSProfiling.cpp b/llvm/lib/Transforms/Instrumentation/RSProfiling.cpp
index 54a9ef7..5d6654d 100644
--- a/llvm/lib/Transforms/Instrumentation/RSProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/RSProfiling.cpp
@@ -188,10 +188,10 @@
   
 GlobalRandomCounter::GlobalRandomCounter(Module& M, const Type* t, 
                                          uint64_t resetval) : T(t) {
+  ConstantInt* Init = ConstantInt::get(T, resetval); 
+  ResetValue = Init;
   Counter = new GlobalVariable(T, false, GlobalValue::InternalLinkage,
-                               ConstantUInt::get(T, resetval),
-                               "RandomSteeringCounter", &M);
-  ResetValue = ConstantUInt::get(T, resetval);
+                               Init, "RandomSteeringCounter", &M);
 }
 
 GlobalRandomCounter::~GlobalRandomCounter() {}
@@ -205,7 +205,7 @@
   LoadInst* l = new LoadInst(Counter, "counter", t);
   
   SetCondInst* s = new SetCondInst(Instruction::SetEQ, l, 
-				   ConstantUInt::get(T, 0), 
+				   ConstantInt::get(T, 0), 
                                    "countercc", t);
   Value* nv = BinaryOperator::createSub(l, ConstantInt::get(T, 1),
                                      "counternew", t);
@@ -225,10 +225,10 @@
 GlobalRandomCounterOpt::GlobalRandomCounterOpt(Module& M, const Type* t, 
                                                uint64_t resetval) 
   : AI(0), T(t) {
+  ConstantInt* Init = ConstantInt::get(T, resetval);
+  ResetValue  = Init;
   Counter = new GlobalVariable(T, false, GlobalValue::InternalLinkage,
-                               ConstantUInt::get(T, resetval),
-                               "RandomSteeringCounter", &M);
-  ResetValue = ConstantUInt::get(T, resetval);
+                               Init, "RandomSteeringCounter", &M);
 }
 
 GlobalRandomCounterOpt::~GlobalRandomCounterOpt() {}
@@ -278,7 +278,7 @@
   LoadInst* l = new LoadInst(AI, "counter", t);
   
   SetCondInst* s = new SetCondInst(Instruction::SetEQ, l, 
-				   ConstantUInt::get(T, 0), 
+				   ConstantInt::get(T, 0), 
                                    "countercc", t);
   Value* nv = BinaryOperator::createSub(l, ConstantInt::get(T, 1),
                                      "counternew", t);
@@ -309,11 +309,11 @@
   
   CallInst* c = new CallInst(F, "rdcc", t);
   BinaryOperator* b = 
-    BinaryOperator::createAnd(c, ConstantUInt::get(Type::ULongTy, rm),
+    BinaryOperator::createAnd(c, ConstantInt::get(Type::ULongTy, rm),
 			      "mrdcc", t);
   
   SetCondInst* s = new SetCondInst(Instruction::SetEQ, b, 
-				   ConstantUInt::get(Type::ULongTy, 0), 
+				   ConstantInt::get(Type::ULongTy, 0), 
                                    "mrdccc", t);
   t->setCondition(s);
 }
@@ -339,7 +339,7 @@
   // Create the getelementptr constant expression
   std::vector<Constant*> Indices(2);
   Indices[0] = Constant::getNullValue(Type::IntTy);
-  Indices[1] = ConstantSInt::get(Type::IntTy, CounterNum);
+  Indices[1] = ConstantInt::get(Type::IntTy, CounterNum);
   Constant *ElementPtr = ConstantExpr::getGetElementPtr(CounterArray, Indices);
   
   // Load, increment and store the value back.
diff --git a/llvm/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp b/llvm/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp
index d3af056..8bf6001 100644
--- a/llvm/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp
+++ b/llvm/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp
@@ -49,7 +49,7 @@
   Function *InstrFn = M.getOrInsertFunction (FnName, Type::VoidTy,
                                              Type::UIntTy, (Type *)0);
   std::vector<Value*> Args (1);
-  Args[0] = ConstantUInt::get (Type::UIntTy, BBNumber);
+  Args[0] = ConstantInt::get (Type::UIntTy, BBNumber);
 
   // Insert the call after any alloca or PHI instructions...
   BasicBlock::iterator InsertPos = BB->begin();
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 4a7edba..c30c0c9 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -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);
     
@@ -1795,14 +1798,14 @@
       if (Anded == CRHS) {
         // See if all bits from the first bit set in the Add RHS up are included
         // in the mask.  First, get the rightmost bit.
-        uint64_t AddRHSV = CRHS->getRawValue();
+        uint64_t AddRHSV = CRHS->getZExtValue();
 
         // Form a mask of all bits from the lowest bit added through the top.
         uint64_t AddRHSHighBits = ~((AddRHSV & -AddRHSV)-1);
         AddRHSHighBits &= C2->getType()->getIntegralTypeMask();
 
         // See if the and mask includes all of these bits.
-        uint64_t AddRHSHighBitsAnd = AddRHSHighBits & C2->getRawValue();
+        uint64_t AddRHSHighBitsAnd = AddRHSHighBits & C2->getZExtValue();
 
         if (AddRHSHighBits == AddRHSHighBitsAnd) {
           // Okay, the xform is safe.  Insert the new add pronto.
@@ -1845,7 +1848,7 @@
 // highest order bit set.
 static bool isSignBit(ConstantInt *CI) {
   unsigned NumBits = CI->getType()->getPrimitiveSizeInBits();
-  return (CI->getRawValue() & (~0ULL >> (64-NumBits))) == (1ULL << (NumBits-1));
+  return (CI->getZExtValue() & (~0ULL >> (64-NumBits))) == (1ULL << (NumBits-1));
 }
 
 /// RemoveNoopCast - Strip off nonconverting casts from the value.
@@ -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;
@@ -2060,11 +2064,11 @@
       if (CI->isAllOnesValue())              // X * -1 == 0 - X
         return BinaryOperator::createNeg(Op0, I.getName());
 
-      int64_t Val = (int64_t)cast<ConstantInt>(CI)->getRawValue();
+      int64_t Val = (int64_t)cast<ConstantInt>(CI)->getZExtValue();
       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);
+    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 = 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);
+            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))->getZExtValue();
         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,46 +2490,42 @@
 
 // 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
 // constant.
 static bool isOneBitSet(const ConstantInt *CI) {
-  uint64_t V = CI->getRawValue();
+  uint64_t V = CI->getZExtValue();
   return V && (V & (V-1)) == 0;
 }
 
 #if 0   // Currently unused
 // isLowOnes - Return true if the constant is of the form 0+1+.
 static bool isLowOnes(const ConstantInt *CI) {
-  uint64_t V = CI->getRawValue();
+  uint64_t V = CI->getZExtValue();
 
   // There won't be bits set in parts that the type doesn't contain.
-  V &= ConstantInt::getAllOnesValue(CI->getType())->getRawValue();
+  V &= ConstantInt::getAllOnesValue(CI->getType())->getZExtValue();
 
   uint64_t U = V+1;  // If it is low ones, this should be a power of two.
   return U && V && (U & V) == 0;
@@ -2527,11 +2535,11 @@
 // isHighOnes - Return true if the constant is of the form 1+0+.
 // This is the same as lowones(~X).
 static bool isHighOnes(const ConstantInt *CI) {
-  uint64_t V = ~CI->getRawValue();
+  uint64_t V = ~CI->getZExtValue();
   if (~V == 0) return false;  // 0's does not match "1+"
 
   // There won't be bits set in parts that the type doesn't contain.
-  V &= ConstantInt::getAllOnesValue(CI->getType())->getRawValue();
+  V &= ConstantInt::getAllOnesValue(CI->getType())->getZExtValue();
 
   uint64_t U = V+1;  // If it is low ones, this should be a power of two.
   return U && V && (U & V) == 0;
@@ -2656,7 +2664,7 @@
       // Adding a one to a single bit bit-field should be turned into an XOR
       // of the bit.  First thing to check is to see if this AND is with a
       // single bit constant.
-      uint64_t AndRHSV = cast<ConstantInt>(AndRHS)->getRawValue();
+      uint64_t AndRHSV = cast<ConstantInt>(AndRHS)->getZExtValue();
 
       // Clear bits that are not part of the constant.
       AndRHSV &= AndRHS->getType()->getIntegralTypeMask();
@@ -2666,7 +2674,7 @@
         // Ok, at this point, we know that we are masking the result of the
         // ADD down to exactly one bit.  If the constant we are adding has
         // no bits set below this bit, then we can eliminate the ADD.
-        uint64_t AddRHS = cast<ConstantInt>(OpRHS)->getRawValue();
+        uint64_t AddRHS = cast<ConstantInt>(OpRHS)->getZExtValue();
 
         // Check to see if any bits below the one bit set in AndRHSV are set.
         if ((AddRHS & (AndRHSV-1)) == 0) {
@@ -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
@@ -2800,7 +2810,7 @@
 // MSB, so 0x000FFF0, 0x0000FFFF, and 0xFF0000FF are all runs.  0x0F0F0000 is
 // not, since all 1s are not contiguous.
 static bool isRunOfOnes(ConstantIntegral *Val, unsigned &MB, unsigned &ME) {
-  uint64_t V = Val->getRawValue();
+  uint64_t V = Val->getZExtValue();
   if (!isShiftedMask_64(V)) return false;
 
   // look for the first zero bit after the run of ones
@@ -2836,7 +2846,7 @@
   case Instruction::And:
     if (ConstantExpr::getAnd(N, Mask) == Mask) {
       // If the AndRHS is a power of two minus one (0+1+), this is simple.
-      if ((Mask->getRawValue() & Mask->getRawValue()+1) == 0)
+      if ((Mask->getZExtValue() & Mask->getZExtValue()+1) == 0)
         break;
 
       // Otherwise, if Mask is 0+1+0+, and if B is known to have the low 0+
@@ -2854,7 +2864,7 @@
   case Instruction::Or:
   case Instruction::Xor:
     // If the AndRHS is a power of two minus one (0+1+), and N&Mask == 0
-    if ((Mask->getRawValue() & Mask->getRawValue()+1) == 0 &&
+    if ((Mask->getZExtValue() & Mask->getZExtValue()+1) == 0 &&
         ConstantExpr::getAnd(N, Mask)->isNullValue())
       break;
     return 0;
@@ -3168,7 +3178,7 @@
   // defines a byte.  We only handle unsigned types here.
   if (isa<ShiftInst>(I) && isa<ConstantInt>(I->getOperand(1))) {
     // Not shifting the entire input by N-1 bytes?
-    if (cast<ConstantInt>(I->getOperand(1))->getRawValue() !=
+    if (cast<ConstantInt>(I->getOperand(1))->getZExtValue() !=
         8*(ByteValues.size()-1))
       return true;
     
@@ -3199,19 +3209,19 @@
   Instruction *SI = cast<Instruction>(Shift);
 
   // Make sure that the shift amount is by a multiple of 8 and isn't too big.
-  if (ShiftAmt->getRawValue() & 7 ||
-      ShiftAmt->getRawValue() > 8*ByteValues.size())
+  if (ShiftAmt->getZExtValue() & 7 ||
+      ShiftAmt->getZExtValue() > 8*ByteValues.size())
     return true;
   
   // Turn 0xFF -> 0, 0xFF00 -> 1, 0xFF0000 -> 2, etc.
   unsigned DestByte;
   for (DestByte = 0; DestByte != ByteValues.size(); ++DestByte)
-    if (AndAmt->getRawValue() == uint64_t(0xFF) << 8*DestByte)
+    if (AndAmt->getZExtValue() == uint64_t(0xFF) << 8*DestByte)
       break;
   // Unknown mask for bswap.
   if (DestByte == ByteValues.size()) return true;
   
-  unsigned ShiftBytes = ShiftAmt->getRawValue()/8;
+  unsigned ShiftBytes = ShiftAmt->getZExtValue()/8;
   unsigned SrcByte;
   if (SI->getOpcode() == Instruction::Shl)
     SrcByte = DestByte - ShiftBytes;
@@ -3372,7 +3382,7 @@
     // replace with V+N.
     if (C1 == ConstantExpr::getNot(C2)) {
       Value *V1 = 0, *V2 = 0;
-      if ((C2->getRawValue() & (C2->getRawValue()+1)) == 0 && // C2 == 0+1+
+      if ((C2->getZExtValue() & (C2->getZExtValue()+1)) == 0 && // C2 == 0+1+
           match(A, m_Add(m_Value(V1), m_Value(V2)))) {
         // Add commutes, try both ways.
         if (V1 == B && MaskedValueIsZero(V2, C2->getZExtValue()))
@@ -3381,7 +3391,7 @@
           return ReplaceInstUsesWith(I, A);
       }
       // Or commutes, try both ways.
-      if ((C1->getRawValue() & (C1->getRawValue()+1)) == 0 &&
+      if ((C1->getZExtValue() & (C1->getZExtValue()+1)) == 0 &&
           match(B, m_Add(m_Value(V1), m_Value(V2)))) {
         // Add commutes, try both ways.
         if (V1 == A && MaskedValueIsZero(V2, C1->getZExtValue()))
@@ -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));
@@ -4815,13 +4842,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();
@@ -4885,7 +4912,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);
 
@@ -4906,13 +4933,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();
@@ -4929,11 +4957,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;
     }
   }
@@ -5069,7 +5097,7 @@
         // operation.
         //
         if (isValid && !isLeftShift && isSignedShift) {
-          uint64_t Val = Op0C->getRawValue();
+          uint64_t Val = Op0C->getZExtValue();
           isValid = ((Val & (1 << (TypeBits-1))) != 0) == highBitSet;
         }
         
@@ -5103,7 +5131,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.
@@ -5111,10 +5139,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) {
@@ -5132,7 +5160,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
@@ -5159,7 +5187,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.
@@ -5167,12 +5195,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
@@ -5181,7 +5209,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());
@@ -5221,33 +5249,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;
+            }
           }
         }
       }
@@ -5321,9 +5353,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);
@@ -5331,7 +5366,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);
   }
@@ -5467,7 +5502,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);
@@ -5595,7 +5630,8 @@
             unsigned SrcBitSize = Src->getType()->getPrimitiveSizeInBits();
             unsigned DestBitSize = CI.getType()->getPrimitiveSizeInBits();
             assert(SrcBitSize < DestBitSize && "Not a zext?");
-            Constant *C = ConstantUInt::get(Type::ULongTy, (1ULL << SrcBitSize)-1);
+            Constant *C = 
+              ConstantInt::get(Type::ULongTy, (1ULL << SrcBitSize)-1);
             C = ConstantExpr::getCast(C, CI.getType());
             return BinaryOperator::createAnd(Res, C);
           }
@@ -5660,7 +5696,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,
@@ -5941,9 +5977,9 @@
   if (ConstantInt *TrueValC = dyn_cast<ConstantInt>(TrueVal))
     if (ConstantInt *FalseValC = dyn_cast<ConstantInt>(FalseVal)) {
       // select C, 1, 0 -> cast C to int
-      if (FalseValC->isNullValue() && TrueValC->getRawValue() == 1) {
+      if (FalseValC->isNullValue() && TrueValC->getZExtValue() == 1) {
         return new CastInst(CondVal, SI.getType());
-      } else if (TrueValC->isNullValue() && FalseValC->getRawValue() == 1) {
+      } else if (TrueValC->isNullValue() && FalseValC->getZExtValue() == 1) {
         // select C, 0, 1 -> cast !C to int
         Value *NotCond =
           InsertNewInstBefore(BinaryOperator::createNot(CondVal,
@@ -5963,7 +5999,7 @@
                          IC->getOpcode() == Instruction::SetLT;
             else {
               unsigned Bits = CmpCst->getType()->getPrimitiveSizeInBits();
-              CanXForm = (CmpCst->getRawValue() == ~0ULL >> (64-Bits+1)) &&
+              CanXForm = (CmpCst->getZExtValue() == ~0ULL >> (64-Bits+1)) &&
                          IC->getOpcode() == Instruction::SetGT;
             }
             
@@ -5978,7 +6014,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);
@@ -6245,7 +6281,7 @@
       if (NumBytes->isNullValue()) return EraseInstFromFunction(CI);
 
       if (ConstantInt *CI = dyn_cast<ConstantInt>(NumBytes))
-        if (CI->getRawValue() == 1) {
+        if (CI->getZExtValue() == 1) {
           // Replace the instruction with just byte operations.  We would
           // transform other cases to loads/stores, but we don't know if
           // alignment is sufficient.
@@ -6278,14 +6314,14 @@
       unsigned Alignment1 = GetKnownAlignment(MI->getOperand(1), TD);
       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));
+      if (MI->getAlignment()->getZExtValue() < 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));
+      if (MI->getAlignment()->getZExtValue() < Alignment) {
+        MI->setAlignment(ConstantInt::get(Type::UIntTy, Alignment));
         Changed = true;
       }
     }
@@ -6368,7 +6404,7 @@
           for (unsigned i = 0; i != 16; ++i) {
             if (isa<UndefValue>(Mask->getOperand(i)))
               continue;
-            unsigned Idx =cast<ConstantInt>(Mask->getOperand(i))->getRawValue();
+            unsigned Idx =cast<ConstantInt>(Mask->getOperand(i))->getZExtValue();
             Idx &= 31;  // Match the hardware behavior.
             
             if (ExtractedElts[Idx] == 0) {
@@ -6542,14 +6578,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;
   }
 
@@ -6874,11 +6910,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;
 
@@ -7049,11 +7086,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))) {
@@ -7064,15 +7102,11 @@
 
         // 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(),
-                                      Scale->getRawValue() / ArrayEltSize);
-          if (Scale->getRawValue() != 1) {
+        if (Scale && Scale->getZExtValue() % ArrayEltSize == 0) {
+          if (ConstantInt *C = dyn_cast<ConstantInt>(Scale))
+            Scale = ConstantInt::get(Scale->getType(),
+                                      Scale->getZExtValue() / ArrayEltSize);
+          if (Scale->getZExtValue() != 1) {
             Constant *C = ConstantExpr::getCast(Scale, NewIdx->getType());
             Instruction *Sc = BinaryOperator::createMul(NewIdx, C, "idxscale");
             NewIdx = InsertNewInstBefore(Sc, GEP);
@@ -7095,8 +7129,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...
@@ -7688,7 +7723,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;
 }
 
@@ -7710,12 +7745,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.
@@ -7759,21 +7796,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);
   }
   
@@ -7819,8 +7857,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);
@@ -7851,11 +7889,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.
@@ -7865,7 +7903,7 @@
     
     if (!isa<ConstantInt>(IdxOp))
       return false;
-    unsigned InsertedIdx = cast<ConstantInt>(IdxOp)->getRawValue();
+    unsigned InsertedIdx = cast<ConstantInt>(IdxOp)->getZExtValue();
     
     if (isa<UndefValue>(ScalarOp)) {  // inserting undef into vector.
       // Okay, we can handle this if the vector we are insertinting into is
@@ -7879,7 +7917,7 @@
       if (isa<ConstantInt>(EI->getOperand(1)) &&
           EI->getOperand(0)->getType() == V->getType()) {
         unsigned ExtractedIdx =
-          cast<ConstantInt>(EI->getOperand(1))->getRawValue();
+          cast<ConstantInt>(EI->getOperand(1))->getZExtValue();
         
         // This must be extracting from either LHS or RHS.
         if (EI->getOperand(0) == LHS || EI->getOperand(0) == RHS) {
@@ -7889,11 +7927,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;
@@ -7921,7 +7959,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.
@@ -7933,8 +7971,8 @@
       if (isa<ConstantInt>(EI->getOperand(1)) && isa<ConstantInt>(IdxOp) &&
           EI->getOperand(0)->getType() == V->getType()) {
         unsigned ExtractedIdx =
-          cast<ConstantInt>(EI->getOperand(1))->getRawValue();
-        unsigned InsertedIdx = cast<ConstantInt>(IdxOp)->getRawValue();
+          cast<ConstantInt>(EI->getOperand(1))->getZExtValue();
+        unsigned InsertedIdx = cast<ConstantInt>(IdxOp)->getZExtValue();
         
         // Either the extracted from or inserted into vector must be RHSVec,
         // otherwise we'd end up with a shuffle of three inputs.
@@ -7942,7 +7980,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;
         }
         
@@ -7951,7 +7989,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;
         }
@@ -7968,7 +8006,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;
 }
 
@@ -7983,8 +8021,8 @@
     if (isa<ConstantInt>(EI->getOperand(1)) && isa<ConstantInt>(IdxOp) &&
         EI->getOperand(0)->getType() == IE.getType()) {
       unsigned NumVectorElts = IE.getType()->getNumElements();
-      unsigned ExtractedIdx=cast<ConstantInt>(EI->getOperand(1))->getRawValue();
-      unsigned InsertedIdx = cast<ConstantInt>(IdxOp)->getRawValue();
+      unsigned ExtractedIdx=cast<ConstantInt>(EI->getOperand(1))->getZExtValue();
+      unsigned InsertedIdx = cast<ConstantInt>(IdxOp)->getZExtValue();
       
       if (ExtractedIdx >= NumVectorElts) // Out of range extract.
         return ReplaceInstUsesWith(IE, VecOp);
@@ -8010,10 +8048,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));
       }
@@ -8068,7 +8106,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));
@@ -8123,7 +8161,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),
@@ -8193,7 +8231,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());
     }
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index 7f02488..e498860 100644
--- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -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);
     }
@@ -861,7 +861,7 @@
 ///
 static bool isZero(SCEVHandle &V) {
   if (SCEVConstant *SC = dyn_cast<SCEVConstant>(V))
-    return SC->getValue()->getRawValue() == 0;
+    return SC->getValue()->getZExtValue() == 0;
   return false;
 }
 
diff --git a/llvm/lib/Transforms/Scalar/LoopUnroll.cpp b/llvm/lib/Transforms/Scalar/LoopUnroll.cpp
index f1a826e..9c59dd3 100644
--- a/llvm/lib/Transforms/Scalar/LoopUnroll.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopUnroll.cpp
@@ -190,8 +190,8 @@
   ConstantInt *TripCountC = dyn_cast_or_null<ConstantInt>(L->getTripCount());
   if (!TripCountC) return Changed;  // Must have constant trip count!
 
-  uint64_t TripCountFull = TripCountC->getRawValue();
-  if (TripCountFull != TripCountC->getRawValue() || TripCountFull == 0)
+  uint64_t TripCountFull = TripCountC->getZExtValue();
+  if (TripCountFull != TripCountC->getZExtValue() || TripCountFull == 0)
     return Changed; // More than 2^32 iterations???
 
   unsigned LoopSize = ApproximateLoopSize(L);
diff --git a/llvm/lib/Transforms/Scalar/LowerGC.cpp b/llvm/lib/Transforms/Scalar/LowerGC.cpp
index 851009c..6a07691 100644
--- a/llvm/lib/Transforms/Scalar/LowerGC.cpp
+++ b/llvm/lib/Transforms/Scalar/LowerGC.cpp
@@ -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");
diff --git a/llvm/lib/Transforms/Scalar/LowerPacked.cpp b/llvm/lib/Transforms/Scalar/LowerPacked.cpp
index 79a55ee..5eb8911 100644
--- a/llvm/lib/Transforms/Scalar/LowerPacked.cpp
+++ b/llvm/lib/Transforms/Scalar/LowerPacked.cpp
@@ -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);
diff --git a/llvm/lib/Transforms/Scalar/Reassociate.cpp b/llvm/lib/Transforms/Scalar/Reassociate.cpp
index 250d62b..64b7b12 100644
--- a/llvm/lib/Transforms/Scalar/Reassociate.cpp
+++ b/llvm/lib/Transforms/Scalar/Reassociate.cpp
@@ -549,7 +549,7 @@
       if (CstVal->isNullValue()) {           // ... * 0 -> 0
         ++NumAnnihil;
         return CstVal;
-      } else if (cast<ConstantInt>(CstVal)->getRawValue() == 1) {
+      } else if (cast<ConstantInt>(CstVal)->getZExtValue() == 1) {
         Ops.pop_back();                      // ... * 1 -> ...
       }
       break;
diff --git a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp
index 87952be..496449f 100644
--- a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp
+++ b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp
@@ -203,7 +203,7 @@
       GetElementPtrInst *GEPI = cast<GetElementPtrInst>(User);
       // We now know that the GEP is of the form: GEP <ptr>, 0, <cst>
       unsigned Idx =
-         (unsigned)cast<ConstantInt>(GEPI->getOperand(2))->getRawValue();
+         (unsigned)cast<ConstantInt>(GEPI->getOperand(2))->getZExtValue();
 
       assert(Idx < ElementAllocas.size() && "Index out of range?");
       AllocaInst *AllocaToUse = ElementAllocas[Idx];
@@ -306,7 +306,7 @@
       // Check to make sure that index falls within the array.  If not,
       // something funny is going on, so we won't do the optimization.
       //
-      if (cast<ConstantInt>(GEPI->getOperand(2))->getRawValue() >= NumElements)
+      if (cast<ConstantInt>(GEPI->getOperand(2))->getZExtValue() >= NumElements)
         return 0;
 
       // We cannot scalar repl this level of the array unless any array
@@ -320,7 +320,7 @@
         const ArrayType *SubArrayTy = cast<ArrayType>(*I);
         uint64_t NumElements = SubArrayTy->getNumElements();
         if (!isa<ConstantInt>(I.getOperand())) return 0;
-        if (cast<ConstantInt>(I.getOperand())->getRawValue() >= NumElements)
+        if (cast<ConstantInt>(I.getOperand())->getZExtValue() >= NumElements)
           return 0;
       }
       
@@ -499,7 +499,7 @@
     } else if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(User)) {
       // Check to see if this is stepping over an element: GEP Ptr, int C
       if (GEP->getNumOperands() == 2 && isa<ConstantInt>(GEP->getOperand(1))) {
-        unsigned Idx = cast<ConstantInt>(GEP->getOperand(1))->getRawValue();
+        unsigned Idx = cast<ConstantInt>(GEP->getOperand(1))->getZExtValue();
         unsigned ElSize = TD.getTypeSize(PTy->getElementType());
         unsigned BitOffset = Idx*ElSize*8;
         if (BitOffset > 64 || !isPowerOf2_32(ElSize)) return 0;
@@ -520,7 +520,7 @@
         // We are stepping into an element, e.g. a structure or an array:
         // GEP Ptr, int 0, uint C
         const Type *AggTy = PTy->getElementType();
-        unsigned Idx = cast<ConstantInt>(GEP->getOperand(2))->getRawValue();
+        unsigned Idx = cast<ConstantInt>(GEP->getOperand(2))->getZExtValue();
         
         if (const ArrayType *ATy = dyn_cast<ArrayType>(AggTy)) {
           if (Idx >= ATy->getNumElements()) return 0;  // Out of range.
@@ -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);
           }
@@ -688,7 +688,7 @@
       // Check to see if this is stepping over an element: GEP Ptr, int C
       unsigned NewOffset = Offset;
       if (GEP->getNumOperands() == 2) {
-        unsigned Idx = cast<ConstantInt>(GEP->getOperand(1))->getRawValue();
+        unsigned Idx = cast<ConstantInt>(GEP->getOperand(1))->getZExtValue();
         unsigned BitOffset = Idx*AggSizeInBits;
         
         if (TD.isLittleEndian() || isVectorInsert)
@@ -698,7 +698,7 @@
         
       } else if (GEP->getNumOperands() == 3) {
         // We know that operand #2 is zero.
-        unsigned Idx = cast<ConstantInt>(GEP->getOperand(2))->getRawValue();
+        unsigned Idx = cast<ConstantInt>(GEP->getOperand(2))->getZExtValue();
         const Type *AggTy = AggPtrTy->getElementType();
         if (const SequentialType *SeqTy = dyn_cast<SequentialType>(AggTy)) {
           unsigned ElSizeBits = TD.getTypeSize(SeqTy->getElementType())*8;
diff --git a/llvm/lib/Transforms/TransformInternals.cpp b/llvm/lib/Transforms/TransformInternals.cpp
index 8cd2511..b6739f4 100644
--- a/llvm/lib/Transforms/TransformInternals.cpp
+++ b/llvm/lib/Transforms/TransformInternals.cpp
@@ -34,7 +34,7 @@
          (i == SL->MemberOffsets.size()-1 || Offset < SL->MemberOffsets[i+1]));
 
   // Make sure to save the current index...
-  Indices.push_back(ConstantUInt::get(Type::UIntTy, i));
+  Indices.push_back(ConstantInt::get(Type::UIntTy, i));
   Offset = SL->MemberOffsets[i];
   return STy->getContainedType(i);
 }
@@ -73,10 +73,11 @@
 
     NextType = ATy->getElementType();
     unsigned ChildSize = (unsigned)TD.getTypeSize(NextType);
-    if (ConstantSInt::isValueValidForType(Type::IntTy, Offset/ChildSize))
-      Indices.push_back(ConstantSInt::get(Type::IntTy, Offset/ChildSize));
+    if (ConstantInt::isValueValidForType(Type::IntTy, 
+                                         uint64_t(Offset/ChildSize)))
+      Indices.push_back(ConstantInt::get(Type::IntTy, Offset/ChildSize));
     else
-      Indices.push_back(ConstantSInt::get(Type::LongTy, Offset/ChildSize));
+      Indices.push_back(ConstantInt::get(Type::LongTy, Offset/ChildSize));
     ThisOffset = (Offset/ChildSize)*ChildSize;
   } else {
     Offset = 0;   // Return the offset that we were able to achieve
diff --git a/llvm/lib/Transforms/TransformInternals.h b/llvm/lib/Transforms/TransformInternals.h
index 51e32c8..4e28904 100644
--- a/llvm/lib/Transforms/TransformInternals.h
+++ b/llvm/lib/Transforms/TransformInternals.h
@@ -25,7 +25,7 @@
 namespace llvm {
 
 static inline int64_t getConstantValue(const ConstantInt *CPI) {
-  return (int64_t)cast<ConstantInt>(CPI)->getRawValue();
+  return (int64_t)cast<ConstantInt>(CPI)->getZExtValue();
 }
 
 
diff --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
index f264cff..ba40345 100644
--- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -305,7 +305,7 @@
     if (AggregateArgs) {
       std::vector<Value*> Indices;
       Indices.push_back(Constant::getNullValue(Type::UIntTy));
-      Indices.push_back(ConstantUInt::get(Type::UIntTy, i));
+      Indices.push_back(ConstantInt::get(Type::UIntTy, i));
       std::string GEPname = "gep_" + inputs[i]->getName();
       TerminatorInst *TI = newFunction->begin()->getTerminator();
       GetElementPtrInst *GEP = new GetElementPtrInst(AI, Indices, GEPname, TI);
@@ -392,7 +392,7 @@
     for (unsigned i = 0, e = inputs.size(); i != e; ++i) {
       std::vector<Value*> Indices;
       Indices.push_back(Constant::getNullValue(Type::UIntTy));
-      Indices.push_back(ConstantUInt::get(Type::UIntTy, i));
+      Indices.push_back(ConstantInt::get(Type::UIntTy, i));
       GetElementPtrInst *GEP =
         new GetElementPtrInst(Struct, Indices,
                               "gep_" + StructValues[i]->getName());
@@ -418,7 +418,7 @@
     if (AggregateArgs) {
       std::vector<Value*> Indices;
       Indices.push_back(Constant::getNullValue(Type::UIntTy));
-      Indices.push_back(ConstantUInt::get(Type::UIntTy, FirstOut + i));
+      Indices.push_back(ConstantInt::get(Type::UIntTy, FirstOut + i));
       GetElementPtrInst *GEP
         = new GetElementPtrInst(Struct, Indices,
                                 "gep_reload_" + outputs[i]->getName());
@@ -439,7 +439,7 @@
 
   // Now we can emit a switch statement using the call as a value.
   SwitchInst *TheSwitch =
-    new SwitchInst(ConstantUInt::getNullValue(Type::UShortTy),
+    new SwitchInst(ConstantInt::getNullValue(Type::UShortTy),
                    codeReplacer, 0, codeReplacer);
 
   // Since there may be multiple exits from the original region, make the new
@@ -473,14 +473,14 @@
             brVal = ConstantBool::get(!SuccNum);
             break;
           default:
-            brVal = ConstantUInt::get(Type::UShortTy, SuccNum);
+            brVal = ConstantInt::get(Type::UShortTy, SuccNum);
             break;
           }
 
           ReturnInst *NTRet = new ReturnInst(brVal, NewTarget);
 
           // Update the switch instruction.
-          TheSwitch->addCase(ConstantUInt::get(Type::UShortTy, SuccNum),
+          TheSwitch->addCase(ConstantInt::get(Type::UShortTy, SuccNum),
                              OldTarget);
 
           // Restore values just before we exit
@@ -519,7 +519,7 @@
               if (AggregateArgs) {
                 std::vector<Value*> Indices;
                 Indices.push_back(Constant::getNullValue(Type::UIntTy));
-                Indices.push_back(ConstantUInt::get(Type::UIntTy,FirstOut+out));
+                Indices.push_back(ConstantInt::get(Type::UIntTy,FirstOut+out));
                 GetElementPtrInst *GEP =
                   new GetElementPtrInst(OAI, Indices,
                                         "gep_" + outputs[out]->getName(),
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 3d1faff..28864fd 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -272,10 +272,10 @@
   gep_type_iterator I = gep_type_begin(CE), E = gep_type_end(CE);
   for (++I; I != E; ++I)
     if (const StructType *STy = dyn_cast<StructType>(*I)) {
-      ConstantUInt *CU = cast<ConstantUInt>(I.getOperand());
-      assert(CU->getValue() < STy->getNumElements() &&
+      ConstantInt *CU = cast<ConstantInt>(I.getOperand());
+      assert(CU->getZExtValue() < STy->getNumElements() &&
              "Struct index out of range!");
-      unsigned El = (unsigned)CU->getValue();
+      unsigned El = (unsigned)CU->getZExtValue();
       if (ConstantStruct *CS = dyn_cast<ConstantStruct>(C)) {
         C = CS->getOperand(El);
       } else if (isa<ConstantAggregateZero>(C)) {
@@ -287,10 +287,10 @@
       }
     } else if (ConstantInt *CI = dyn_cast<ConstantInt>(I.getOperand())) {
       if (const ArrayType *ATy = dyn_cast<ArrayType>(*I)) {
-        if ((uint64_t)CI->getRawValue() >= ATy->getNumElements())
+        if (CI->getZExtValue() >= ATy->getNumElements())
          return 0;
         if (ConstantArray *CA = dyn_cast<ConstantArray>(C))
-          C = CA->getOperand((unsigned)CI->getRawValue());
+          C = CA->getOperand(CI->getZExtValue());
         else if (isa<ConstantAggregateZero>(C))
           C = Constant::getNullValue(ATy->getElementType());
         else if (isa<UndefValue>(C))
@@ -298,10 +298,10 @@
         else
           return 0;
       } else if (const PackedType *PTy = dyn_cast<PackedType>(*I)) {
-        if ((uint64_t)CI->getRawValue() >= PTy->getNumElements())
+        if (CI->getZExtValue() >= PTy->getNumElements())
           return 0;
         if (ConstantPacked *CP = dyn_cast<ConstantPacked>(C))
-          C = CP->getOperand((unsigned)CI->getRawValue());
+          C = CP->getOperand(CI->getZExtValue());
         else if (isa<ConstantAggregateZero>(C))
           C = Constant::getNullValue(PTy->getElementType());
         else if (isa<UndefValue>(C))
diff --git a/llvm/lib/Transforms/Utils/LowerAllocations.cpp b/llvm/lib/Transforms/Utils/LowerAllocations.cpp
index 451df70..d08235c 100644
--- a/llvm/lib/Transforms/Utils/LowerAllocations.cpp
+++ b/llvm/lib/Transforms/Utils/LowerAllocations.cpp
@@ -119,14 +119,14 @@
       // malloc(type) becomes sbyte *malloc(size)
       Value *MallocArg;
       if (LowerMallocArgToInteger)
-        MallocArg = ConstantUInt::get(Type::ULongTy, TD.getTypeSize(AllocTy));
+        MallocArg = ConstantInt::get(Type::ULongTy, TD.getTypeSize(AllocTy));
       else
         MallocArg = ConstantExpr::getSizeOf(AllocTy);
       MallocArg = ConstantExpr::getCast(cast<Constant>(MallocArg), IntPtrTy);
 
       if (MI->isArrayAllocation()) {
         if (isa<ConstantInt>(MallocArg) &&
-            cast<ConstantInt>(MallocArg)->getRawValue() == 1) {
+            cast<ConstantInt>(MallocArg)->getZExtValue() == 1) {
           MallocArg = MI->getOperand(0);         // Operand * 1 = Operand
         } else if (Constant *CO = dyn_cast<Constant>(MI->getOperand(0))) {
           CO = ConstantExpr::getCast(CO, IntPtrTy);
diff --git a/llvm/lib/Transforms/Utils/LowerInvoke.cpp b/llvm/lib/Transforms/Utils/LowerInvoke.cpp
index 9180557..1816144 100644
--- a/llvm/lib/Transforms/Utils/LowerInvoke.cpp
+++ b/llvm/lib/Transforms/Utils/LowerInvoke.cpp
@@ -269,7 +269,7 @@
 void LowerInvoke::rewriteExpensiveInvoke(InvokeInst *II, unsigned InvokeNo,
                                          AllocaInst *InvokeNum,
                                          SwitchInst *CatchSwitch) {
-  ConstantUInt *InvokeNoC = ConstantUInt::get(Type::UIntTy, InvokeNo);
+  ConstantInt *InvokeNoC = ConstantInt::get(Type::UIntTy, InvokeNo);
 
   // Insert a store of the invoke num before the invoke and store zero into the
   // location afterward.
@@ -461,7 +461,7 @@
     
     std::vector<Value*> Idx;
     Idx.push_back(Constant::getNullValue(Type::IntTy));
-    Idx.push_back(ConstantUInt::get(Type::UIntTy, 1));
+    Idx.push_back(ConstantInt::get(Type::UIntTy, 1));
     OldJmpBufPtr = new GetElementPtrInst(JmpBuf, Idx, "OldBuf",
                                          EntryBB->getTerminator());
 
@@ -500,7 +500,7 @@
     BasicBlock *ContBlock = EntryBB->splitBasicBlock(EntryBB->getTerminator(),
                                                      "setjmp.cont");
 
-    Idx[1] = ConstantUInt::get(Type::UIntTy, 0);
+    Idx[1] = ConstantInt::get(Type::UIntTy, 0);
     Value *JmpBufPtr = new GetElementPtrInst(JmpBuf, Idx, "TheJmpBuf",
                                              EntryBB->getTerminator());
     Value *SJRet = new CallInst(SetJmpFn, JmpBufPtr, "sjret",
@@ -550,7 +550,7 @@
   // Get a pointer to the jmpbuf and longjmp.
   std::vector<Value*> Idx;
   Idx.push_back(Constant::getNullValue(Type::IntTy));
-  Idx.push_back(ConstantUInt::get(Type::UIntTy, 0));
+  Idx.push_back(ConstantInt::get(Type::UIntTy, 0));
   Idx[0] = new GetElementPtrInst(BufPtr, Idx, "JmpBuf", UnwindBlock);
   Idx[1] = ConstantInt::get(Type::IntTy, 1);
   new CallInst(LongJmpFn, Idx, "", UnwindBlock);
diff --git a/llvm/lib/Transforms/Utils/LowerSwitch.cpp b/llvm/lib/Transforms/Utils/LowerSwitch.cpp
index 12a32f1..724499d 100644
--- a/llvm/lib/Transforms/Utils/LowerSwitch.cpp
+++ b/llvm/lib/Transforms/Utils/LowerSwitch.cpp
@@ -60,11 +60,12 @@
   struct CaseCmp {
     bool operator () (const LowerSwitch::Case& C1,
                       const LowerSwitch::Case& C2) {
-      if (const ConstantUInt* U1 = dyn_cast<const ConstantUInt>(C1.first))
-        return U1->getValue() < cast<const ConstantUInt>(C2.first)->getValue();
 
-      const ConstantSInt* S1 = dyn_cast<const ConstantSInt>(C1.first);
-      return S1->getValue() < cast<const ConstantSInt>(C2.first)->getValue();
+      const ConstantInt* CI1 = cast<const ConstantInt>(C1.first);
+      const ConstantInt* CI2 = cast<const ConstantInt>(C2.first);
+      if (CI1->getType()->isUnsigned()) 
+        return CI1->getZExtValue() < CI2->getZExtValue();
+      return CI1->getSExtValue() < CI2->getSExtValue();
     }
   };
 
@@ -129,7 +130,7 @@
 
   Case& Pivot = *(Begin + Mid);
   DEBUG(std::cerr << "Pivot ==> "
-                  << (int64_t)cast<ConstantInt>(Pivot.first)->getRawValue()
+                  << cast<ConstantInt>(Pivot.first)->getSExtValue()
                   << "\n");
 
   BasicBlock* LBranch = switchConvert(LHS.begin(), LHS.end(), Val,
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 867455e..de2ab06 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1160,7 +1160,7 @@
   /// applications that sort ConstantInt's to ensure uniqueness.
   struct ConstantIntOrdering {
     bool operator()(const ConstantInt *LHS, const ConstantInt *RHS) const {
-      return LHS->getRawValue() < RHS->getRawValue();
+      return LHS->getZExtValue() < RHS->getZExtValue();
     }
   };
 }