Skip to content

Commit

Permalink
JIT: emit vzeroupper before calls to the bulk write barrier helper (#…
Browse files Browse the repository at this point in the history
…106908)

The helper uses SSE2, so we need to take care to avoid AVX-SSE
transition penalties.

Fixes #106679.
  • Loading branch information
AndyAyersMS authored Aug 25, 2024
1 parent f61ca08 commit 5fd3f22
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1997,9 +1997,14 @@ void CallArgs::Remove(CallArg* arg)
//
bool GenTreeCall::NeedsVzeroupper(Compiler* comp)
{
if (!comp->canUseVexEncoding())
{
return false;
}

bool needsVzeroupper = false;

if (IsPInvoke() && comp->canUseVexEncoding())
if (IsPInvoke())
{
// The Intel optimization manual guidance in `3.11.5.3 Fixing Instruction Slowdowns` states:
// Insert a VZEROUPPER to tell the hardware that the state of the higher registers is clean
Expand Down Expand Up @@ -2028,6 +2033,7 @@ bool GenTreeCall::NeedsVzeroupper(Compiler* comp)
if (varTypeUsesFloatReg(this))
{
needsVzeroupper = true;
break;
}
else
{
Expand All @@ -2050,6 +2056,13 @@ bool GenTreeCall::NeedsVzeroupper(Compiler* comp)
}
}

// Other special cases
//
if (!needsVzeroupper && IsHelperCall(comp, CORINFO_HELP_BULK_WRITEBARRIER))
{
needsVzeroupper = true;
}

return needsVzeroupper;
}
#endif // TARGET_XARCH
Expand Down

0 comments on commit 5fd3f22

Please sign in to comment.