[llvm] [X86] For minsize, use size for alignment, rather than actual alignment (PR #87003)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 5 14:50:31 PDT 2024
================
@@ -66,11 +66,30 @@ SDValue X86SelectionDAGInfo::EmitTargetCodeForMemset(
// If not DWORD aligned or size is more than the threshold, call the library.
// The libc version is likely to be faster for these cases. It can use the
// address value and run time information about the CPU.
- if (Alignment < Align(4) || !ConstantSize ||
- ConstantSize->getZExtValue() > Subtarget.getMaxInlineSizeThreshold())
+ if (!ConstantSize ||
+ (!AlwaysInline &&
+ (Alignment < Align(4) ||
+ ConstantSize->getZExtValue() > Subtarget.getMaxInlineSizeThreshold())))
return SDValue();
+ // If we have minsize, then don't care about the alignment.
+ // On x86, the CPU doesn't care and neither should you.
+ // As long as the count is aligned, we can use the minimum number of
+ // instructions without always having to resort to stosb.
+ //
+ // Because this is a feature specific to x86, we must handle it here.
uint64_t SizeVal = ConstantSize->getZExtValue();
----------------
RKSimon wrote:
(See #87825 - split the if statement to simplify)
https://github.com/llvm/llvm-project/pull/87003
More information about the llvm-commits
mailing list