cpu: lower all 60 VEX FMA3 scalar and packed instructions #497
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/503"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by PrivacyOnion on 2026-11-22T08:21:30Z.
### Summary
Adds AOT lowering in
tools/cpu_avx2_aot.pyfor all 60 VEX-encoded x64 FMA3 instructions listed indocs/coverage/x64_zen2.tsvgroupFMA(96iced_x86.Codevariants across scalarss/sdand packed 128-bit/256-bitps/pd, supporting both register and flat memoryop2operands):vfmadd,vfmsub,vfnmadd,vfnmsub(ss,sd,ps,pd) andvfmaddsub,vfmsubadd(ps,pd)132,213,231std::fmaf/std::fma, x86 semantic(a, b, c)NaN priority with QNaN quietening and sign preservation on negated-product forms, scalar upper-lane preservation (op0[127:32]/op0[127:64]), and VEX 128-bit upper-lane zeroing ([255:128]).Fixture & Coverage
tests/cpu/fma3_leaf.asm(; coverage: source cpu_aot_fma3) +tests/cpu/fma3_leaf.defwith 102 exports (all 96 register variants + 6 memory-operand variants coveringm32,m64,m128,m256) and anALTER_FMAmutation variant.tests/cpu/fma3_leaf_check.pyrunning 714 bit-exact differential comparisons (native hardware DLL vs lifted C++ DLL) covering single-rounding witnesses, signed zeros, infinities, subnormals, QNaN/SNaN priority, randomized inputs, mutation control, and 5 rejection controls (undefinedop0, nonvolatileymm6, EVEX FMA3, unsupportedRSPmemory base, and AMD FMA4).check_fma3_leaf()totests/form_coverage_check.pyverifying 60/60FMAcoverage.Test Commands & Results
ctest --preset dev --no-tests=error -R "^(cpu_aot_fma3|cpu_aot_avx2_regs)$" -V-> 2/2 passed (cpu_aot_fma3 passed (102 exports, 714 bit-exact differential evaluations))ctest --preset release --no-tests=error -R "^cpu_aot_fma3$" -V-> 1/1 passed at/O2.\out\pe-env\Scripts\python.exe -B tests/form_coverage_check.py-> passed (FMA 60/60).\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py-> passed.\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py-> passedImported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-22T14:53:05Z.
Verification of
c5626econ an Intel Core i7-6820HQ (Skylake; FMA3 and AVX2, no AVX-512). Windows 11 26100.9168, MSVC 19.52.37029,devpreset:python -B tests/form_coverage_check.pyalso reports "form coverage checks passed". The FMA results come from a CPU generation different from the Zen 2 coverage table, and all 714 evaluations match bit for bit.Two notes for coordination:
c5626ecno longer merges cleanly withmainatf8d11ad.git merge-treereports a conflict inCMakeLists.txt.tests/form_coverage_check.pymerges automatically.tools/ffx_version_query.py). This PR covers them intools/cpu_avx2_aot.py. The code does not overlap. Both PRs do claim the sameFMArows ofdocs/coverage/x64_zen2.tsv, so whichever lands second may want to state which translator its coverage entry refers to.AI-assisted: run and summarized with Claude Code; outputs copied from the local runs.
Imported from R0Y00/Xbox2Windows. Originally posted by PrivacyOnion on 2026-11-22T15:07:05Z.
Rebased onto current
main(c8a3fd9); the only conflict was inCMakeLists.txt(both sides appended independent CPU test blocks, both kept). No code change otherwise.Thanks for the independent Skylake verification.
Coordination with #349: that PR lowers the 36 packed VEX FMA3 forms in
tools/ffx_version_query.py. This PR covers all 60 FMA forms intools/cpu_avx2_aot.py. The code does not overlap. Both claim the same FMA rows ofdocs/coverage/x64_zen2.tsv; this PR's coverage entry (cpu_aot_fma3) refers to thecpu_avx2_aottranslator.Re-run after rebase (dev preset, Windows 11, MSVC):
ctest --preset dev --no-tests=error -R "^(cpu_aot_fma3|cpu_aot_avx2_regs)$"-> 2/2 passedtests/form_coverage_check.py,tests/bidi_controls_check.py-> passedImported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-22T15:21:34Z.
Re-checked the rebased head
d9382c3on the same Skylake i7-6820HQ with a fresh configure and build. The FMA and AVX2 tests already onmainpass alongside this PR's test:AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-23T12:56:07Z.
I resolved the coverage-test conflict on your original branch in
1dce507. The FMA3 and shader coverage checks both remain registered. The native FMA3 test now reuses the existing CPUID/XGETBV probe and reports a capability skip when FMA or OS-enabled XMM/YMM state is unavailable.On Windows with MSVC 19.51, both the dev and release presets passed
ctest --preset <preset> --no-tests=error -R "^(cpu_aot_fma3|cpu_aot_fma_packed)$" -V. The leaf fixture matched 714 comparisons across 102 exports, and the existing packed fixture matched 196. The form coverage check also passed. GitHub CI is running on the updated head.