diff options
author | Chris Lattner <sabre@nondot.org> | 2007-02-06 06:07:51 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-02-06 06:07:51 +0000 |
commit | 1b4b054cbaf4a270b29c3f5b4b93c1d575d47857 (patch) | |
tree | 3e251babb76e7eef815b343a197572e9403f08a3 /llvm/lib/CodeGen/IntrinsicLowering.cpp | |
parent | 07e13789e5d836e537d1e3e2da795972d6139fcc (diff) | |
download | bcm5719-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.cpp | 22 |
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; |