Skip to content

Commit a508a99

Browse files
committed
Don't force vzeroupper for helpers written in managed
1 parent 34fe382 commit a508a99

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

src/coreclr/jit/gentree.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2040,8 +2040,13 @@ bool GenTreeCall::NeedsVzeroupper(Compiler* comp)
20402040

20412041
// Most other helpers are well known to not use any floating-point or SIMD logic internally, but
20422042
// a few do exist so we need to ensure they are handled. They are identified by taking or
2043-
// returning a floating-point or SIMD type, regardless of how it is actually passed/returned.
2044-
checkSignature = !needsVzeroupper;
2043+
// returning a floating-point or SIMD type, regardless of how it is actually passed/returned but
2044+
// are excluded if we know they are implemented in managed.
2045+
checkSignature = !needsVzeroupper &&
2046+
!IsHelperCall(comp, CORINFO_HELP_DBL2INT_OVF) &&
2047+
!IsHelperCall(comp, CORINFO_HELP_DBL2LNG_OVF) &&
2048+
!IsHelperCall(comp, CORINFO_HELP_DBL2UINT_OVF) &&
2049+
!IsHelperCall(comp, CORINFO_HELP_DBL2ULNG_OVF);
20452050
break;
20462051
}
20472052

src/coreclr/jit/importercalls.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9549,9 +9549,15 @@ GenTree* Compiler::impMathIntrinsic(CORINFO_METHOD_HANDLE method,
95499549

95509550
if (isIntrinsicImplementedByUserCall)
95519551
{
9552+
#if defined(TARGET_XARCH)
95529553
// We want to track math intrinsics implemented as user calls as special
95539554
// to ensure we don't lose track of the fact it will call into native code
9555+
//
9556+
// This is used on xarch to track that it may need vzeroupper inserted to
9557+
// avoid the perf penalty on some hardware.
9558+
95549559
*isSpecial = true;
9560+
#endif // TARGET_XARCH
95559561
}
95569562

95579563
#if !defined(TARGET_X86)

src/coreclr/jit/rationalize.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,14 @@ void Rationalizer::RewriteNodeAsCall(GenTree** use,
4444

4545
if (isSpecialIntrinsic)
4646
{
47+
#if defined(TARGET_XARCH)
4748
// Mark this as having been a special intrinsic node
49+
//
50+
// This is used on xarch to track that it may need vzeroupper inserted to
51+
// avoid the perf penalty on some hardware.
52+
4853
call->gtCallMoreFlags |= GTF_CALL_M_SPECIAL_INTRINSIC;
54+
#endif // TARGET_XARCH
4955
}
5056

5157
assert(sig != nullptr);

0 commit comments

Comments
 (0)