cpu: lower all 24 VEX-encoded scalar FMA3 instructions (ss/sd) #342
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/347"
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 Vonsek on 2026-11-21T22:56:53Z.
Change
vfmadd/vfmsub/vfnmadd/vfnmsub×132/213/231×ss/sd) intools/ffx_version_query.pyusing single-roundingstd::fmaf/std::fma, preserving upper XMM bytes ofdst, zeroing the upper 128 bits of YMM, and rejecting EVEX forms.tests/cpu/fma_scalar.asm,tests/cpu/fma_scalar.def) and differential test (tests/cpu/fma_scalar.py) wired intoCMakeLists.txtascpu_aot_fma_scalarwith ahost_has_fma()check (OSXSAVE,XCR0YMM state, and CPUID leaf 1 ECX bit 12FMA) andSKIP_RETURN_CODE 77on unsupported hosts.fma_scalar->cpu_aot_fma_scalarintools/form_coverage.py(+24 FMA mnemonics, raising FMA from 0/60 to 24/60 indocs/coverage/x64_zen2.tsv) and document the test indocs/experiments.md.Verification
Tested on Windows 11 (VS 2022 Build Tools 17.14, MSVC 19.44, ML64 14.44, Windows SDK 10.0.26100, Python 3.12):
cmake --build --preset dev --target cpu_fma_scalar_liftedfailed with:cmake --build --preset dev --target cpu_fma_scalar_liftedsucceeded.ctest --preset dev --no-tests=error -R "^cpu_aot_fma_scalar$" -V: passed (120 scalar FMA3 cases across all 24 ss/sd forms matched native and translated DLLs bit-for-bit).python -B tests/form_coverage_check.py:form coverage checks passed.Evidence and follow-up
0/60 -> 24/60) indocs/coverage/x64_zen2.tsv; the remaining 36 packed FMA3 forms (ps/pdandmaddsub/msubadd) can follow in a separate focused PR.Checklist
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T23:06:35Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
609b97b613ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T23:00:44Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
609b97bℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T23:14:56Z.
Added
fma_x86/quiet_nanhelpers intools/ffx_version_query.pyto propagate NaNs in x86(dst, src1, src2)order without flipping their sign bits, and added raw-bit qNaN and sNaN inputs across all three operand positions intests/cpu/fma_scalar.py(192 bit-for-bit cases passing).Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T23:06:35Z.
Code review location:
tools/ffx_version_query.py; line 230When a negated operand is a NaN, these unary negations flip its sign bit, whereas the corresponding x86 FMA instruction propagates the NaN without applying that arithmetic sign change. For example, with low lanes
(1.0f, 1.0f, qNaN(0x7fc12345)), nativevfmsub213ssstores0x7fc12345, but the emittedstd::fmaf(1.0f, 1.0f, -qNaN)stores0xffc12345(reproduced using the actual emitter on x86-64 Linux/GCC 13); thesdform has the same mismatch. This breaks bit-for-bit translation for NaN inputs. Handle native NaN propagation before applying the sign inversions, and add raw-bit NaN inputs to the differential fixture.Useful? React with 👍 / 👎.