Currently we expand a memcpy/memset node to a call to the libc implementation if
if ((Align & 3) != 0 || (I && I->getValue() < Subtarget->getMinRepStrSizeThreshold())) { Shouldn't this be a ">". The libc memcpy/memset are very fast for big arrays. If I compile --------------------------------------- #include <string.h> void f1(long *a, long *b) { memcpy(a, b, 8 * 16); } void f2(long *a, long *b) { memcpy(a, b, 8 * 32); } --------------------------------------- with gcc 4.2 (-O2), it will call memcpy for f2 and not for f1. Cheers, -- Rafael Avila de Espindola Google Ireland Ltd. Gordon House Barrow Street Dublin 4 Ireland Registered in Dublin, Ireland Registration Number: 368047
Index: lib/Target/X86/X86ISelLowering.cpp =================================================================== --- lib/Target/X86/X86ISelLowering.cpp (revision 41327) +++ lib/Target/X86/X86ISelLowering.cpp (working copy) @@ -3753,10 +3753,10 @@ if (Align == 0) Align = 1; ConstantSDNode *I = dyn_cast<ConstantSDNode>(Op.getOperand(3)); - // If not DWORD aligned, call memset if size is less than the threshold. + // If not DWORD aligned or size is more than the threshold, call memset. // It knows how to align to the right boundary first. if ((Align & 3) != 0 || - (I && I->getValue() < Subtarget->getMinRepStrSizeThreshold())) { + (I && I->getValue() > Subtarget->getMinRepStrSizeThreshold())) { MVT::ValueType IntPtr = getPointerTy(); const Type *IntPtrTy = getTargetData()->getIntPtrType(); TargetLowering::ArgListTy Args; @@ -3909,10 +3909,10 @@ if (Align == 0) Align = 1; ConstantSDNode *I = dyn_cast<ConstantSDNode>(Op.getOperand(3)); - // If not DWORD aligned, call memcpy if size is less than the threshold. + // If not DWORD aligned or size is more than the threshold, call memcpy. // It knows how to align to the right boundary first. if ((Align & 3) != 0 || - (I && I->getValue() < Subtarget->getMinRepStrSizeThreshold())) { + (I && I->getValue() > Subtarget->getMinRepStrSizeThreshold())) { MVT::ValueType IntPtr = getPointerTy(); TargetLowering::ArgListTy Args; TargetLowering::ArgListEntry Entry;
_______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits