From ce498e9eb295feea7c15c137531f817b54b5e495 Mon Sep 17 00:00:00 2001 From: tronLives111 Date: Mon, 23 Nov 2026 17:24:32 -0600 Subject: [PATCH] Fix the expected ADCX probe result MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The first ADCX wraps UINT64_MAX + 1 to zero and sets CF. The second adds one and the carry, producing 2 with CF clear. Verified the result and carry through Leonida’s Rosetta fallback on Apple M1. The raw ISA probe rebuilt and ran, and raw ADX traps under Rosetta on this host. AI-assisted. --- runtime/macos_host/isa_probe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/macos_host/isa_probe.c b/runtime/macos_host/isa_probe.c index 13019fe98b..e3aee7ecd0 100644 --- a/runtime/macos_host/isa_probe.c +++ b/runtime/macos_host/isa_probe.c @@ -16,7 +16,7 @@ static int t_lzcnt(void) { uint64_t r, x = 1; __asm__ volatile("lzcnt %1,%0" : static int t_movbe(void) { uint32_t r, x = 0x11223344; __asm__ volatile("movbe %1,%0" : "=r"(r) : "m"(x)); return r == 0x44332211; } static int t_bmi1(void) { uint64_t r, x = 0xF0; __asm__ volatile("tzcnt %1,%0" : "=r"(r) : "r"(x)); uint64_t a; __asm__ volatile("andn %2,%1,%0" : "=r"(a) : "r"(0x0Full), "r"(0xFFull)); return r == 4 && a == 0xF0; } static int t_bmi2(void) { uint64_t r; __asm__ volatile("pdep %2,%1,%0" : "=r"(r) : "r"(0b101ull), "r"(0b11010ull)); return r == 0b10010; } -static int t_adx(void) { uint64_t a = ~0ull, b = 1; __asm__ volatile("clc; adcx %1,%0; adcx %1,%0" : "+r"(a) : "r"(b) : "cc"); return a == 1; } +static int t_adx(void) { uint64_t a = ~0ull, b = 1; __asm__ volatile("clc; adcx %1,%0; adcx %1,%0" : "+r"(a) : "r"(b) : "cc"); return a == 2; } static int t_avx(void) { float o[8], i[8] = {1,2,3,4,5,6,7,8}; __asm__ volatile("vmovups %1,%%ymm0; vaddps %%ymm0,%%ymm0,%%ymm0; vmovups %%ymm0,%0; vzeroupper" : "=m"(o) : "m"(i) : "xmm0"); return o[7] == 16; } static int t_avx2(void) { int o[8], i[8] = {1,2,3,4,5,6,7,8}; __asm__ volatile("vmovdqu %1,%%ymm0; vpmulld %%ymm0,%%ymm0,%%ymm0; vpermq $0x1b,%%ymm0,%%ymm0; vmovdqu %%ymm0,%0; vzeroupper" : "=m"(o) : "m"(i) : "xmm0"); return o[0] == 49 && o[7] == 4; } static int t_fma(void) { float o[8], a[8] = {2,2,2,2,2,2,2,2}, c[8] = {1,1,1,1,1,1,1,1}; __asm__ volatile("vmovups %1,%%ymm0; vmovups %2,%%ymm1; vfmadd213ps %%ymm1,%%ymm0,%%ymm0; vmovups %%ymm0,%0; vzeroupper" : "=m"(o) : "m"(a), "m"(c) : "xmm0", "xmm1"); return o[3] == 5; }