Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use AVX512 to zero locals #91166

Merged
merged 2 commits into from
Aug 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/coreclr/jit/codegenxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10894,9 +10894,12 @@ void CodeGen::genZeroInitFrameUsingBlockInit(int untrLclHi, int untrLclLo, regNu
assert((blkSize + alignmentHiBlkSize) == (untrLclHi - untrLclLo));
#endif // !defined(TARGET_AMD64)

const int maxSimdSize = (int)compiler->roundDownSIMDSize(blkSize);
EgorBo marked this conversation as resolved.
Show resolved Hide resolved
assert((maxSimdSize >= XMM_REGSIZE_BYTES) && (maxSimdSize <= ZMM_REGSIZE_BYTES));

// The loop is unrolled 3 times so we do not move to the loop block until it
// will loop at least once so the threshold is 6.
if (blkSize < (6 * XMM_REGSIZE_BYTES))
if (blkSize < (6 * maxSimdSize))
{
// Generate the following code:
//
Expand All @@ -10905,10 +10908,22 @@ void CodeGen::genZeroInitFrameUsingBlockInit(int untrLclHi, int untrLclLo, regNu
// ...
// movups xmmword ptr [ebp/esp-OFFS], xmm4
// mov qword ptr [ebp/esp-OFFS], rax

//
// NOTE: it implicitly zeroes YMM4 and ZMM4 as well.
emit->emitIns_SIMD_R_R_R(INS_xorps, EA_16BYTE, zeroSIMDReg, zeroSIMDReg, zeroSIMDReg);

int i = 0;
if (maxSimdSize > XMM_REGSIZE_BYTES)
{
for (; i <= blkSize - maxSimdSize; i += maxSimdSize)
{
// We previously aligned data to 16 bytes which might not be aligned to maxSimdSize
emit->emitIns_AR_R(simdUnalignedMovIns(), EA_ATTR(maxSimdSize), zeroSIMDReg, frameReg,
alignedLclLo + i);
}
// Remainder will be handled by the xmm loop below
}

for (; i < blkSize; i += XMM_REGSIZE_BYTES)
{
emit->emitIns_AR_R(simdMov, EA_ATTR(XMM_REGSIZE_BYTES), zeroSIMDReg, frameReg, alignedLclLo + i);
Expand Down