aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-02-06 06:07:51 +0000
committerChris Lattner <sabre@nondot.org>2007-02-06 06:07:51 +0000
commit7d6f77db284913a1dd4b5f362fd62ba65b76784b (patch)
treed0422069fd285b6992a8b693e3091fd86b7ed33d
parentba1469278eb4c1fa06a48036c1534fcf83a50e23 (diff)
downloadexternal_llvm-7d6f77db284913a1dd4b5f362fd62ba65b76784b.zip
external_llvm-7d6f77db284913a1dd4b5f362fd62ba65b76784b.tar.gz
external_llvm-7d6f77db284913a1dd4b5f362fd62ba65b76784b.tar.bz2
Fix PR1181 and CodeGen/CBackend/2007-02-05-memset.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33957 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/IntrinsicLowering.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/CodeGen/IntrinsicLowering.cpp b/lib/CodeGen/IntrinsicLowering.cpp
index ee2f79e..320c5a5 100644
--- a/lib/CodeGen/IntrinsicLowering.cpp
+++ b/lib/CodeGen/IntrinsicLowering.cpp
@@ -394,17 +394,27 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
}
case Intrinsic::memset_i32: {
static Constant *MemsetFCache = 0;
- Value * Size = cast<Value>(CI->op_end()-1);
- if (Size->getType() != TD.getIntPtrType())
- Size->replaceAllUsesWith(new ZExtInst(Size, TD.getIntPtrType()));
+ Value *Size = cast<Value>(CI->op_end()-1);
+ const Type *IntPtr = TD.getIntPtrType();
+ if (Size->getType()->getPrimitiveSizeInBits() <
+ IntPtr->getPrimitiveSizeInBits())
+ Size = new ZExtInst(Size, IntPtr, "", CI);
+ else if (Size->getType()->getPrimitiveSizeInBits() >
+ IntPtr->getPrimitiveSizeInBits())
+ Size = new TruncInst(Size, IntPtr, "", CI);
ReplaceCallWith("memset", CI, CI->op_begin()+1, CI->op_end()-1,
(*(CI->op_begin()+1))->getType(), MemsetFCache);
}
case Intrinsic::memset_i64: {
static Constant *MemsetFCache = 0;
- Value * Size = cast<Value>(CI->op_end()-1);
- if (Size->getType() != TD.getIntPtrType())
- Size->replaceAllUsesWith(new TruncInst(Size, TD.getIntPtrType()));
+ Value *Size = cast<Value>(CI->op_end()-1);
+ const Type *IntPtr = TD.getIntPtrType();
+ if (Size->getType()->getPrimitiveSizeInBits() <
+ IntPtr->getPrimitiveSizeInBits())
+ Size = new ZExtInst(Size, IntPtr, "", CI);
+ else if (Size->getType()->getPrimitiveSizeInBits() >
+ IntPtr->getPrimitiveSizeInBits())
+ Size = new TruncInst(Size, IntPtr, "", CI);
ReplaceCallWith("memset", CI, CI->op_begin()+1, CI->op_end()-1,
(*(CI->op_begin()+1))->getType(), MemsetFCache);
break;