[llvm-commits] CVS: llvm/lib/CodeGen/IntrinsicLowering.cpp
Chris Lattner
sabre at nondot.org
Mon Feb 5 22:08:07 PST 2007
Changes in directory llvm/lib/CodeGen:
IntrinsicLowering.cpp updated: 1.64 -> 1.65
---
Log message:
Fix PR1181: http://llvm.org/PR1181 and CodeGen/CBackend/2007-02-05-memset.ll
---
Diffs of the changes: (+16 -6)
IntrinsicLowering.cpp | 22 ++++++++++++++++------
1 files changed, 16 insertions(+), 6 deletions(-)
Index: llvm/lib/CodeGen/IntrinsicLowering.cpp
diff -u llvm/lib/CodeGen/IntrinsicLowering.cpp:1.64 llvm/lib/CodeGen/IntrinsicLowering.cpp:1.65
--- llvm/lib/CodeGen/IntrinsicLowering.cpp:1.64 Fri Feb 2 08:09:34 2007
+++ llvm/lib/CodeGen/IntrinsicLowering.cpp Tue Feb 6 00:07:51 2007
@@ -394,17 +394,27 @@
}
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;
More information about the llvm-commits
mailing list