From 25f565839b729b6aff9e852a02bb7260a647d55a Mon Sep 17 00:00:00 2001 From: Egor Chesakov Date: Tue, 11 Aug 2020 15:54:12 -0700 Subject: [PATCH] Unconditionally expand some of the Vector128 methods on x86/x64 in zapinfo.cpp --- src/coreclr/src/zap/zapinfo.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/coreclr/src/zap/zapinfo.cpp b/src/coreclr/src/zap/zapinfo.cpp index ff12d9631621d1..90b047b80e7eed 100644 --- a/src/coreclr/src/zap/zapinfo.cpp +++ b/src/coreclr/src/zap/zapinfo.cpp @@ -2176,6 +2176,30 @@ DWORD FilterNamedIntrinsicMethodAttribs(ZapInfo* pZapInfo, DWORD attribs, CORINF fTreatAsRegularMethodCall |= !fIsPlatformHWIntrinsic && fIsHWIntrinsic && (strncmp(className, "Vector64", _countof("Vector64") - 1) != 0) && (strncmp(className, "Vector128", _countof("Vector128") - 1) != 0); + +#elif defined(TARGET_X86) || defined(TARGET_AMD64) + // The following methods should be safe to expand unconditionally, since JIT either + // 1) does not generate code for them (e.g. for Vector128.AsByte() or get_Count) or + // 2) uses instructions that belong to Sse or Sse2 (these are required baseline ISAs). + static const char* vector128MethodsSafeToExpand[] = { "As", "AsByte", "AsDouble", "AsInt16", "AsInt32", "AsInt64", "AsSByte", + "AsSingle", "AsUInt16", "AsUInt32", "AsUInt64", "Create", "CreateScalarUnsafe", "ToScalar", "get_Count", "get_Zero" }; + + if (!fIsPlatformHWIntrinsic && fIsHWIntrinsic) + { + fTreatAsRegularMethodCall = true; + + if (strncmp(className, "Vector128", _countof("Vector128") - 1) == 0) + { + for (size_t i = 0; i < _countof(vector128MethodsSafeToExpand); i++) + { + if (strcmp(methodName, vector128MethodsSafeToExpand[i]) == 0) + { + fTreatAsRegularMethodCall = false; + break; + } + } + } + } #else fTreatAsRegularMethodCall |= !fIsPlatformHWIntrinsic && fIsHWIntrinsic; #endif