summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/IntrinsicLowering.cpp
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
commit1b4b054cbaf4a270b29c3f5b4b93c1d575d47857 (patch)
tree3e251babb76e7eef815b343a197572e9403f08a3 /llvm/lib/CodeGen/IntrinsicLowering.cpp
parent07e13789e5d836e537d1e3e2da795972d6139fcc (diff)
downloadbcm5719-llvm-1b4b054cbaf4a270b29c3f5b4b93c1d575d47857.tar.gz
bcm5719-llvm-1b4b054cbaf4a270b29c3f5b4b93c1d575d47857.zip
Fix PR1181 and CodeGen/CBackend/2007-02-05-memset.ll
llvm-svn: 33957
Diffstat (limited to 'llvm/lib/CodeGen/IntrinsicLowering.cpp')
-rw-r--r--llvm/lib/CodeGen/IntrinsicLowering.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/IntrinsicLowering.cpp b/llvm/lib/CodeGen/IntrinsicLowering.cpp
index ee2f79e5b54..320c5a57516 100644
--- a/llvm/lib/CodeGen/IntrinsicLowering.cpp
+++ b/llvm/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;
OpenPOWER on IntegriCloud