Skip to content

Commit

Permalink
Fixing TargetHasAVXSupportCheck to read ECX not EDX (#42089)
Browse files Browse the repository at this point in the history
  • Loading branch information
tannergooding authored Sep 11, 2020
1 parent 0956285 commit ff533b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/coreclr/src/vm/cgensys.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,17 @@ extern "C" void __stdcall __cpuidex(int cpuInfo[4], int function_id, int subFunc
extern "C" DWORD __stdcall xmmYmmStateSupport();
#endif

const int CPUID_EAX = 0;
const int CPUID_EBX = 1;
const int CPUID_ECX = 2;
const int CPUID_EDX = 3;

inline bool TargetHasAVXSupport()
{
#if (defined(TARGET_X86) || defined(TARGET_AMD64)) && !defined(CROSSGEN_COMPILE)
int cpuInfo[4];
__cpuid(cpuInfo, 0x00000001); // All x86/AMD64 targets support cpuid.
return ((cpuInfo[3] & (1 << 28)) != 0); // The AVX feature is ECX bit 28.
return ((cpuInfo[CPUID_ECX] & (1 << 28)) != 0); // The AVX feature is ECX bit 28.
#endif // (defined(TARGET_X86) || defined(TARGET_AMD64)) && !defined(CROSSGEN_COMPILE)
return false;
}
Expand Down
8 changes: 4 additions & 4 deletions src/coreclr/src/vm/codeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1353,10 +1353,10 @@ void EEJitManager::SetCpuInfo()

int cpuidInfo[4];

const int EAX = 0;
const int EBX = 1;
const int ECX = 2;
const int EDX = 3;
const int EAX = CPUID_EAX;
const int EBX = CPUID_EBX;
const int ECX = CPUID_ECX;
const int EDX = CPUID_EDX;

__cpuid(cpuidInfo, 0x00000000);
uint32_t maxCpuId = static_cast<uint32_t>(cpuidInfo[EAX]);
Expand Down

0 comments on commit ff533b8

Please sign in to comment.