1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 03:23:01 +02:00

Fix PR1181 and CodeGen/CBackend/2007-02-05-memset.ll

llvm-svn: 33957
This commit is contained in:
Chris Lattner 2007-02-06 06:07:51 +00:00
parent 9263720b2b
commit fc117b2338

View File

@ -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;