Skip to content

Commit b6f210b

Browse files
[X86] Correct CPUID checks for AVX10 (#172350)
This corrects a wrong condition for avx10 (AVX10Ver is always set to 0/1) and corrects how CPUID for avx10 is queried: per ISE table 1-3 we should query with EAX = 0x24 and ECX = 0x0 -- previously we omitted the latter. Issue reported by user Seraphimt here https://discourse.llvm.org/t/test-for-sys-gethostcpufeatures/89130
1 parent 055864c commit b6f210b

File tree

2 files changed

+5
-5
lines changed
  • compiler-rt/lib/builtins/cpu_model
  • llvm/lib/TargetParser

2 files changed

+5
-5
lines changed

compiler-rt/lib/builtins/cpu_model/x86.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,8 +1090,8 @@ static void getAvailableFeatures(unsigned ECX, unsigned EDX, unsigned MaxLeaf,
10901090
if (HasLeaf1E && (EAX & 0x100))
10911091
setFeature(FEATURE_AMX_MOVRS);
10921092

1093-
bool HasLeaf24 =
1094-
MaxLevel >= 0x24 && !getX86CpuIDAndInfo(0x24, &EAX, &EBX, &ECX, &EDX);
1093+
bool HasLeaf24 = MaxLevel >= 0x24 &&
1094+
!getX86CpuIDAndInfoEx(0x24, 0x0, &EAX, &EBX, &ECX, &EDX);
10951095
if (HasLeaf7Subleaf1 && ((EDX >> 19) & 1) && HasLeaf24) {
10961096
int AVX10Ver = EBX & 0xff;
10971097
if (AVX10Ver >= 1)

llvm/lib/TargetParser/Host.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2192,10 +2192,10 @@ StringMap<bool> sys::getHostCPUFeatures() {
21922192
Features["amx-avx512"] = HasLeaf1E && ((EAX >> 7) & 1) && HasAMXSave;
21932193
Features["amx-movrs"] = HasLeaf1E && ((EAX >> 8) & 1) && HasAMXSave;
21942194

2195-
bool HasLeaf24 =
2196-
MaxLevel >= 0x24 && !getX86CpuIDAndInfo(0x24, &EAX, &EBX, &ECX, &EDX);
2195+
bool HasLeaf24 = MaxLevel >= 0x24 &&
2196+
!getX86CpuIDAndInfoEx(0x24, 0x0, &EAX, &EBX, &ECX, &EDX);
21972197

2198-
int AVX10Ver = HasLeaf24 && (EBX & 0xff);
2198+
int AVX10Ver = HasLeaf24 ? (EBX & 0xff) : 0;
21992199
Features["avx10.1"] = HasAVX10 && AVX10Ver >= 1;
22002200
Features["avx10.2"] = HasAVX10 && AVX10Ver >= 2;
22012201

0 commit comments

Comments
 (0)