- Change getelementptr instruction to use long indexes instead of uint
    indexes for sequential types.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3681 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/TransformInternals.cpp b/lib/Transforms/TransformInternals.cpp
index f9ee232..8586832 100644
--- a/lib/Transforms/TransformInternals.cpp
+++ b/lib/Transforms/TransformInternals.cpp
@@ -66,7 +66,7 @@
 
     NextType = ATy->getElementType();
     unsigned ChildSize = TD.getTypeSize(NextType);
-    Indices.push_back(ConstantUInt::get(Type::UIntTy, Offset/ChildSize));
+    Indices.push_back(ConstantSInt::get(Type::LongTy, Offset/ChildSize));
     ThisOffset = (Offset/ChildSize)*ChildSize;
   } else {
     Offset = 0;   // Return the offset that we were able to acheive
@@ -141,13 +141,13 @@
 
         if (BI) {              // Generate code?
           BasicBlock *BB = (*BI)->getParent();
-          if (Expr.Var->getType() != Type::UIntTy)
-            Expr.Var = new CastInst(Expr.Var, Type::UIntTy,
+          if (Expr.Var->getType() != Type::LongTy)
+            Expr.Var = new CastInst(Expr.Var, Type::LongTy,
                                     Expr.Var->getName()+"-idxcast", *BI);
 
           if (ScaleAmt && ScaleAmt != 1) {
             // If we have to scale up our index, do so now
-            Value *ScaleAmtVal = ConstantUInt::get(Type::UIntTy,
+            Value *ScaleAmtVal = ConstantSInt::get(Type::LongTy,
                                                    (unsigned)ScaleAmt);
             Expr.Var = BinaryOperator::create(Instruction::Mul, Expr.Var,
                                               ScaleAmtVal,
@@ -155,7 +155,7 @@
           }
 
           if (Index) {  // Add an offset to the index
-            Value *IndexAmt = ConstantUInt::get(Type::UIntTy, (unsigned)Index);
+            Value *IndexAmt = ConstantSInt::get(Type::LongTy, (unsigned)Index);
             Expr.Var = BinaryOperator::create(Instruction::Add, Expr.Var,
                                               IndexAmt,
                                               Expr.Var->getName()+"-offset",
@@ -168,14 +168,14 @@
       } else if (Offset >= (int)ElSize || -Offset >= (int)ElSize) {
         // Calculate the index that we are entering into the array cell with
         unsigned Index = Offset/ElSize;
-        Indices.push_back(ConstantUInt::get(Type::UIntTy, Index));
+        Indices.push_back(ConstantSInt::get(Type::LongTy, Index));
         Offset -= (int)(Index*ElSize);            // Consume part of the offset
 
       } else if (isa<ArrayType>(CompTy) || Indices.empty()) {
         // Must be indexing a small amount into the first cell of the array
         // Just index into element zero of the array here.
         //
-        Indices.push_back(ConstantUInt::get(Type::UIntTy, 0));
+        Indices.push_back(ConstantSInt::get(Type::LongTy, 0));
       } else {
         return 0;  // Hrm. wierd, can't handle this case.  Bail
       }