aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/ExprTypeConvert.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms/ExprTypeConvert.cpp')
-rw-r--r--lib/Transforms/ExprTypeConvert.cpp31
1 files changed, 17 insertions, 14 deletions
diff --git a/lib/Transforms/ExprTypeConvert.cpp b/lib/Transforms/ExprTypeConvert.cpp
index b30ddf1f29..bde24f0158 100644
--- a/lib/Transforms/ExprTypeConvert.cpp
+++ b/lib/Transforms/ExprTypeConvert.cpp
@@ -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...