From eae05a86f57b8261122ff06778dc473f459f0d96 Mon Sep 17 00:00:00 2001 From: Ruihan-Yin Date: Wed, 18 Feb 2026 11:11:11 -0800 Subject: [PATCH 1/7] update the CPUID check logics for APX. --- src/native/minipal/cpufeatures.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/native/minipal/cpufeatures.c b/src/native/minipal/cpufeatures.c index 5b12f4fc76babf..4a6a3a7c33f38c 100644 --- a/src/native/minipal/cpufeatures.c +++ b/src/native/minipal/cpufeatures.c @@ -406,13 +406,23 @@ int minipal_getcpufeatures(void) if (IsApxEnabled() && apxStateSupport()) { - if ((cpuidInfo[CPUID_EDX] & (1 << 21)) != 0) // Apx + if ((cpuidInfo[CPUID_EDX] & (1 << 21)) != 0) // Apx_F { - result |= XArchIntrinsicConstants_Apx; + __cpuidex(cpuidInfo, 0x00000029, 0x00000000); + if ((cpuidInfo[CPUID_EBX] & (1 << 0)) != 0) // Apx_NCI_NDD_NF + { + // As documented in the "Intel® Advanced Performance Extensions (Intel® APX) Software Developer’s Manual" revision 7.0 + // APX_F (CPUID.(EAX=07H,ECX=1H):EDX[bit 21]) indicates the basic support for APX, and + // APX_NCI_NDD_NF (CPUID.(EAX=29H,ECX=0H):EBX[bit 0]) indicates support for the NCI/NDD/NF features. + // As of now, both bits are required to turn on APX in JIT. + result |= XArchIntrinsicConstants_Apx; + } } } } + __cpuidex(cpuidInfo, 0x00000007, 0x00000001); + if (maxCpuId >= 0x24) { if ((cpuidInfo[CPUID_EDX] & (1 << 19)) != 0) // Avx10 From f6c6e306ed40ca64eea2eb42d222c049e32c27b9 Mon Sep 17 00:00:00 2001 From: Ruihan-Yin Date: Fri, 20 Feb 2026 10:23:49 -0800 Subject: [PATCH 2/7] add maxCpuId check when checking cpuid(0x29, 0) --- src/native/minipal/cpufeatures.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/native/minipal/cpufeatures.c b/src/native/minipal/cpufeatures.c index 4a6a3a7c33f38c..e8149594d5cc6f 100644 --- a/src/native/minipal/cpufeatures.c +++ b/src/native/minipal/cpufeatures.c @@ -406,13 +406,13 @@ int minipal_getcpufeatures(void) if (IsApxEnabled() && apxStateSupport()) { - if ((cpuidInfo[CPUID_EDX] & (1 << 21)) != 0) // Apx_F + if (((cpuidInfo[CPUID_EDX] & (1 << 21)) != 0) && maxCpuId >= 0x29) // Apx_F { __cpuidex(cpuidInfo, 0x00000029, 0x00000000); if ((cpuidInfo[CPUID_EBX] & (1 << 0)) != 0) // Apx_NCI_NDD_NF { // As documented in the "Intel® Advanced Performance Extensions (Intel® APX) Software Developer’s Manual" revision 7.0 - // APX_F (CPUID.(EAX=07H,ECX=1H):EDX[bit 21]) indicates the basic support for APX, and + // APX_F (CPUID.(EAX=07H,ECX=1H):EDX[bit 21]) indicates the basic support for APX, and // APX_NCI_NDD_NF (CPUID.(EAX=29H,ECX=0H):EBX[bit 0]) indicates support for the NCI/NDD/NF features. // As of now, both bits are required to turn on APX in JIT. result |= XArchIntrinsicConstants_Apx; From 3d157c9ad4a79f1894f45ab37cffe5f260b96634 Mon Sep 17 00:00:00 2001 From: Ruihan-Yin Date: Fri, 27 Feb 2026 10:49:16 -0800 Subject: [PATCH 3/7] resolve comments --- src/native/minipal/cpufeatures.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/native/minipal/cpufeatures.c b/src/native/minipal/cpufeatures.c index e8149594d5cc6f..53b04670e6b3ee 100644 --- a/src/native/minipal/cpufeatures.c +++ b/src/native/minipal/cpufeatures.c @@ -237,6 +237,7 @@ int minipal_getcpufeatures(void) bool hasAvx2Dependencies = false; bool hasAvx10v1Dependencies = false; + bool hasApxDependencies = false; if (((cpuidInfo[CPUID_EDX] & (1 << 25)) == 0) || // SSE ((cpuidInfo[CPUID_EDX] & (1 << 26)) == 0) || // SSE2 @@ -406,23 +407,17 @@ int minipal_getcpufeatures(void) if (IsApxEnabled() && apxStateSupport()) { - if (((cpuidInfo[CPUID_EDX] & (1 << 21)) != 0) && maxCpuId >= 0x29) // Apx_F + if (((cpuidInfo[CPUID_EDX] & (1 << 21)) != 0)) // Apx_F { - __cpuidex(cpuidInfo, 0x00000029, 0x00000000); - if ((cpuidInfo[CPUID_EBX] & (1 << 0)) != 0) // Apx_NCI_NDD_NF - { - // As documented in the "Intel® Advanced Performance Extensions (Intel® APX) Software Developer’s Manual" revision 7.0 - // APX_F (CPUID.(EAX=07H,ECX=1H):EDX[bit 21]) indicates the basic support for APX, and - // APX_NCI_NDD_NF (CPUID.(EAX=29H,ECX=0H):EBX[bit 0]) indicates support for the NCI/NDD/NF features. - // As of now, both bits are required to turn on APX in JIT. - result |= XArchIntrinsicConstants_Apx; - } + // APX availability check is split to 2 part, Apx_F here + // checks the fundamental support, and APX_NCI_NDD_NF checks + // feature support. + // Full APX requires 2 parts both present to be enabled. + hasApxDependencies = true; } } } - __cpuidex(cpuidInfo, 0x00000007, 0x00000001); - if (maxCpuId >= 0x24) { if ((cpuidInfo[CPUID_EDX] & (1 << 19)) != 0) // Avx10 @@ -456,6 +451,15 @@ int minipal_getcpufeatures(void) } } } + + if (maxCpuId >= 0x29) + { + __cpuidex(cpuidInfo, 0x00000029, 0x00000000); + if (((cpuidInfo[CPUID_EBX] & (1 << 0)) != 0) && hasApxDependencies) // AMX-TILE + { + result |= XArchIntrinsicConstants_Apx; + } + } } #endif // HOST_X86 || HOST_AMD64 From 6d42295938d5d76a69e8f684779f486b48e8dd42 Mon Sep 17 00:00:00 2001 From: Ruihan-Yin <107431934+Ruihan-Yin@users.noreply.github.com> Date: Fri, 27 Feb 2026 14:40:54 -0800 Subject: [PATCH 4/7] Update src/native/minipal/cpufeatures.c resolve comments Co-authored-by: Tanner Gooding --- src/native/minipal/cpufeatures.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/minipal/cpufeatures.c b/src/native/minipal/cpufeatures.c index 53b04670e6b3ee..9d17c364328fb0 100644 --- a/src/native/minipal/cpufeatures.c +++ b/src/native/minipal/cpufeatures.c @@ -407,7 +407,7 @@ int minipal_getcpufeatures(void) if (IsApxEnabled() && apxStateSupport()) { - if (((cpuidInfo[CPUID_EDX] & (1 << 21)) != 0)) // Apx_F + if ((cpuidInfo[CPUID_EDX] & (1 << 21)) != 0) // Apx_F { // APX availability check is split to 2 part, Apx_F here // checks the fundamental support, and APX_NCI_NDD_NF checks From 993a8d47a5188f32b73d86dd7366043072e6857a Mon Sep 17 00:00:00 2001 From: Ruihan-Yin <107431934+Ruihan-Yin@users.noreply.github.com> Date: Sun, 1 Mar 2026 19:30:31 -0800 Subject: [PATCH 5/7] Update comments Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/native/minipal/cpufeatures.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/native/minipal/cpufeatures.c b/src/native/minipal/cpufeatures.c index 9d17c364328fb0..19b9ddde422c9c 100644 --- a/src/native/minipal/cpufeatures.c +++ b/src/native/minipal/cpufeatures.c @@ -409,10 +409,10 @@ int minipal_getcpufeatures(void) { if ((cpuidInfo[CPUID_EDX] & (1 << 21)) != 0) // Apx_F { - // APX availability check is split to 2 part, Apx_F here - // checks the fundamental support, and APX_NCI_NDD_NF checks + // APX availability check is split into two parts, Apx_F here + // checks the fundamental support, and APX_NCI_NDD_NF checks // feature support. - // Full APX requires 2 parts both present to be enabled. + // Full APX requires both parts to be present to be enabled. hasApxDependencies = true; } } From f046b4e77e0c87955edb220281d233aaaea270f7 Mon Sep 17 00:00:00 2001 From: Ruihan-Yin <107431934+Ruihan-Yin@users.noreply.github.com> Date: Thu, 5 Mar 2026 14:48:34 -0800 Subject: [PATCH 6/7] Update src/native/minipal/cpufeatures.c Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/native/minipal/cpufeatures.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/minipal/cpufeatures.c b/src/native/minipal/cpufeatures.c index 19b9ddde422c9c..2ef5d7ab944947 100644 --- a/src/native/minipal/cpufeatures.c +++ b/src/native/minipal/cpufeatures.c @@ -455,7 +455,7 @@ int minipal_getcpufeatures(void) if (maxCpuId >= 0x29) { __cpuidex(cpuidInfo, 0x00000029, 0x00000000); - if (((cpuidInfo[CPUID_EBX] & (1 << 0)) != 0) && hasApxDependencies) // AMX-TILE + if (((cpuidInfo[CPUID_EBX] & (1 << 0)) != 0) && hasApxDependencies) // APX_NCI_NDD_NF { result |= XArchIntrinsicConstants_Apx; } From e0dba1c1faacacfa250046a4098931df32165fa5 Mon Sep 17 00:00:00 2001 From: Ruihan-Yin <107431934+Ruihan-Yin@users.noreply.github.com> Date: Thu, 5 Mar 2026 14:56:37 -0800 Subject: [PATCH 7/7] Update src/native/minipal/cpufeatures.c Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/native/minipal/cpufeatures.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/minipal/cpufeatures.c b/src/native/minipal/cpufeatures.c index 2ef5d7ab944947..5df296a940046a 100644 --- a/src/native/minipal/cpufeatures.c +++ b/src/native/minipal/cpufeatures.c @@ -407,7 +407,7 @@ int minipal_getcpufeatures(void) if (IsApxEnabled() && apxStateSupport()) { - if ((cpuidInfo[CPUID_EDX] & (1 << 21)) != 0) // Apx_F + if ((cpuidInfo[CPUID_EDX] & (1 << 21)) != 0) // Apx_F { // APX availability check is split into two parts, Apx_F here // checks the fundamental support, and APX_NCI_NDD_NF checks