Implement select.ll:test11
[oota-llvm.git] / lib / Transforms / ExprTypeConvert.cpp
index b30ddf1f293c59519a38fbc5a9bfca6986a9ef56..bde24f0158a2210cf7f593dfe2bd936ffdf44ed8 100644 (file)
@@ -797,10 +797,13 @@ static bool OperandConvertibleToType(User *U, Value *V, const Type *Ty,
       // stream, so we have to delete it when we're done.
       //
       if (DataSize != 1) {
-        // FIXME, PR82
-        TempScale = BinaryOperator::create(Instruction::Mul, Index,
-                                           ConstantSInt::get(Type::LongTy,
-                                                             DataSize));
+        Value *CST;
+        if (Index->getType()->isSigned())
+          CST = ConstantSInt::get(Index->getType(), DataSize);
+        else
+          CST = ConstantUInt::get(Index->getType(), DataSize);
+                                  
+        TempScale = BinaryOperator::create(Instruction::Mul, Index, CST);
         Index = TempScale;
       }
 
@@ -1012,8 +1015,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
 
     if (const CompositeType *CT = dyn_cast<CompositeType>(LoadedTy)) {
       std::vector<Value*> Indices;
-      // FIXME, PR82
-      Indices.push_back(ConstantSInt::get(Type::LongTy, 0));
+      Indices.push_back(Constant::getNullValue(Type::UIntTy));
 
       unsigned Offset = 0;   // No offset, get first leaf.
       LoadedTy = getStructOffsetType(CT, Offset, Indices, TD, false);
@@ -1049,8 +1051,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
           const StructType *SElTy = cast<StructType>(ElTy);
           
           std::vector<Value*> Indices;
-          // FIXME, PR82
-          Indices.push_back(Constant::getNullValue(Type::LongTy));
+          Indices.push_back(Constant::getNullValue(Type::UIntTy));
 
           unsigned Offset = 0;
           const Type *Ty = getStructOffsetType(ElTy, Offset, Indices, TD,false);
@@ -1079,8 +1080,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
 
       if (isa<StructType>(ValTy)) {
         std::vector<Value*> Indices;
-        // FIXME: PR82
-        Indices.push_back(Constant::getNullValue(Type::LongTy));
+        Indices.push_back(Constant::getNullValue(Type::UIntTy));
 
         unsigned Offset = 0;
         ValTy = getStructOffsetType(ValTy, Offset, Indices, TD, false);
@@ -1112,10 +1112,13 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
 
     if (DataSize != 1) {
       // Insert a multiply of the old element type is not a unit size...
-      Index = BinaryOperator::create(Instruction::Mul, Index,
-                                     // FIXME: PR82
-                                     ConstantSInt::get(Type::LongTy, DataSize),
-                                     "scale", It);
+      Value *CST;
+      if (Index->getType()->isSigned())
+        CST = ConstantSInt::get(Index->getType(), DataSize);
+      else
+        CST = ConstantUInt::get(Index->getType(), DataSize);
+
+      Index = BinaryOperator::create(Instruction::Mul, Index, CST, "scale", It);
     }
 
     // Perform the conversion now...