cpu: accept FTZ and DAZ in host-MXCSR profile #1052

Closed
github-bot wants to merge 3 commits from gh-pr/1052/head into gh-pr/1052/base
Owner

@⁠romn4rch on GitHub · 2026-11-23 23:30 UTC · original
romn4rch:romn4rch-ftz-daz-mxcsr-1048 → main · +282 −28 · 8 files · 3 commits · closed without merging

Change

The host-MXCSR profile previously refused both denormal controls, preventing opt-in translated code from matching native FTZ behavior and from using DAZ where supported. This change adds Mxcsr(reject, denormals=True): FTZ is accepted on x64 SSE2, while DAZ is gated by a per-load FXSAVE/MXCSR_MASK probe. Existing default refusals, exception checks, caller-state restoration, and VEX exclusions remain unchanged. FTZ and DAZ fixtures run separately so unsupported DAZ does not hide FTZ results.

The fixture uses runtime-fed synthetic binary32 operands, with negative controls for ignored loads/stores, FTZ/DAZ rejection, and ignoring a synthetic mask without DAZ.

Fixes #1048

Verification

  • python -B -m py_compile tests\cpu\mxcsr.py tools\ffx_version_query.py - passed.
  • python -B tests\docs_links_check.py - passed; checked 15 Markdown files and 235 links.
  • python -B tests\form_coverage_check.py - passed.
  • python -B tests\bidi_controls_check.py - passed; checked 885 tracked files.
  • git diff --check - passed.
  • Direct iced-x86 source-generation smoke checks for the default/opt-in profiles, VEX refusals, control replacements, and signed-subnormal expected bits - passed.
  • ctest --preset dev --no-tests=error -R '^cpu_aot_mxcsr(_daz)?$' -V - not run: this host lacks cl.exe, ml64.exe, and a configured dev build.

Evidence and follow-up

The MASM fixture generates its inputs at runtime and compares native and translated ADDPS results to fixed binary32 expectations. It checks signed FTZ outputs, signed DAZ inputs, all four FTZ/DAZ combinations under two rounding modes, read-back, and caller restoration. On hosts without DAZ, the translated path verifies refusal and the DAZ-specific CTest reports capability skip 77; FTZ remains independently testable. docs/experiments.md documents the behavior and reproduction command; the README has no MXCSR-specific capability row. No hardware run was performed.

AI-assisted: implemented with GitHub Copilot.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed.
  • I did not include game files, dumps, distribution links or secrets.

Inline source-generation smoke command

$check = "import runpy; from iced_x86 import Decoder; m=runpy.run_path('tests/cpu/mxcsr.py'); m['rejected_vex'](); c=m['lower'](list(Decoder(64, bytes.fromhex('0fae10 0fae19 c3'), ip=0x1000)), ['rax = a;', 'rcx = b;'], {}, {}, {}, host_mxcsr=m['Mxcsr'](m['REJECT'], denormals=True)); assert all(c.count(n) for v in m['CONTROLS'] for n, _ in ([m['CONTROLS'][v]] + ([(m['DAZ_MASK_CHECK'], '')] if v == 'nomask' else []))); assert m['f32'](m['MIN_NORMAL'] - m['SUBNORMAL_INPUT']) == 0x007FFE00; assert m['f32'](-m['MIN_NORMAL'] + m['SUBNORMAL_INPUT']) == 0x807FFE00; print('profile, VEX, control, and signed-subnormal smoke checks passed')"; $check | .\out\pe-env\Scripts\python.exe -
**@⁠romn4rch** on GitHub · 2026-11-23 23:30 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1052) `romn4rch:romn4rch-ftz-daz-mxcsr-1048` → `main` · +282 −28 · 8 files · 3 commits · closed without merging ## Change The host-MXCSR profile previously refused both denormal controls, preventing opt-in translated code from matching native FTZ behavior and from using DAZ where supported. This change adds `Mxcsr(reject, denormals=True)`: FTZ is accepted on x64 SSE2, while DAZ is gated by a per-load `FXSAVE`/`MXCSR_MASK` probe. Existing default refusals, exception checks, caller-state restoration, and VEX exclusions remain unchanged. FTZ and DAZ fixtures run separately so unsupported DAZ does not hide FTZ results. The fixture uses runtime-fed synthetic binary32 operands, with negative controls for ignored loads/stores, FTZ/DAZ rejection, and ignoring a synthetic mask without DAZ. Fixes #1048 ## Verification - `python -B -m py_compile tests\cpu\mxcsr.py tools\ffx_version_query.py` - passed. - `python -B tests\docs_links_check.py` - passed; checked 15 Markdown files and 235 links. - `python -B tests\form_coverage_check.py` - passed. - `python -B tests\bidi_controls_check.py` - passed; checked 885 tracked files. - `git diff --check` - passed. - Direct `iced-x86` source-generation smoke checks for the default/opt-in profiles, VEX refusals, control replacements, and signed-subnormal expected bits - passed. - `ctest --preset dev --no-tests=error -R '^cpu_aot_mxcsr(_daz)?$' -V` - not run: this host lacks `cl.exe`, `ml64.exe`, and a configured `dev` build. ## Evidence and follow-up The MASM fixture generates its inputs at runtime and compares native and translated ADDPS results to fixed binary32 expectations. It checks signed FTZ outputs, signed DAZ inputs, all four FTZ/DAZ combinations under two rounding modes, read-back, and caller restoration. On hosts without DAZ, the translated path verifies refusal and the DAZ-specific CTest reports capability skip 77; FTZ remains independently testable. `docs/experiments.md` documents the behavior and reproduction command; the README has no MXCSR-specific capability row. No hardware run was performed. AI-assisted: implemented with GitHub Copilot. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed. - [x] I did not include game files, dumps, distribution links or secrets. ## Inline source-generation smoke command ```powershell $check = "import runpy; from iced_x86 import Decoder; m=runpy.run_path('tests/cpu/mxcsr.py'); m['rejected_vex'](); c=m['lower'](list(Decoder(64, bytes.fromhex('0fae10 0fae19 c3'), ip=0x1000)), ['rax = a;', 'rcx = b;'], {}, {}, {}, host_mxcsr=m['Mxcsr'](m['REJECT'], denormals=True)); assert all(c.count(n) for v in m['CONTROLS'] for n, _ in ([m['CONTROLS'][v]] + ([(m['DAZ_MASK_CHECK'], '')] if v == 'nomask' else []))); assert m['f32'](m['MIN_NORMAL'] - m['SUBNORMAL_INPUT']) == 0x007FFE00; assert m['f32'](-m['MIN_NORMAL'] + m['SUBNORMAL_INPUT']) == 0x807FFE00; print('profile, VEX, control, and signed-subnormal smoke checks passed')"; $check | .\out\pe-env\Scripts\python.exe - ```
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 22:37:52 +00:00
github-bot closed this pull request 2026-11-26 22:37:52 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-23 23:38 UTC · original

Thanks for adding the missing native export. I pushed 4f2435d6 on top after reproducing a second failure: with FTZ on and DAZ off, the DAZ probe's tiny sums have signs + and −, so native ADDPS produces +0 and −0 in that order. The normal-input FTZ probe still checks the opposite-sign pair. The opt-in now reads the host mask at the first DAZ load per invocation, with a zeroed aligned area and a byte copy, and does not cache across invocations.

On Windows x64 (MXCSR_MASK=0xFFFF), both native/lifted CTests passed in dev and release, including the separately compiled /O2 DLL, all four mode pairs, and simulated no-DAZ refusal. Command: ctest --preset <dev|release> --no-tests=error -R '^cpu_aot_mxcsr(_daz)?$' --output-on-failure

**@⁠R0Y00** on GitHub · 2026-11-23 23:38 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1052#issuecomment-7117193997) Thanks for adding the missing native export. I pushed 4f2435d6 on top after reproducing a second failure: with FTZ on and DAZ off, the DAZ probe's tiny sums have signs + and −, so native ADDPS produces +0 and −0 in that order. The normal-input FTZ probe still checks the opposite-sign pair. The opt-in now reads the host mask at the first DAZ load per invocation, with a zeroed aligned area and a byte copy, and does not cache across invocations. On Windows x64 (MXCSR_MASK=0xFFFF), both native/lifted CTests passed in dev and release, including the separately compiled /O2 DLL, all four mode pairs, and simulated no-DAZ refusal. Command: ctest --preset <dev|release> --no-tests=error -R '^cpu_aot_mxcsr(_daz)?$' --output-on-failure
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-24 00:12 UTC · original

The shared MXCSR-controlled path landed in #1057, including the co-authored denormal work from this PR. Thanks for the implementation and native comparisons. Closing this overlapping branch now that the consolidated version is on main.

**@⁠R0Y00** on GitHub · 2026-11-24 00:12 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/1052#issuecomment-7117814738) The shared MXCSR-controlled path landed in #1057, including the co-authored denormal work from this PR. Thanks for the implementation and native comparisons. Closing this overlapping branch now that the consolidated version is on main.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.