cpu: add dedicated cpu_avx_round_aot lifter for VROUNDPS, VROUNDPD, VROUNDSS, and VROUNDSD #2382

Merged
Ammmae0x merged 4 commits from upstream-pr/2390 into main 2026-12-02 12:19:29 +00:00
Ammmae0x commented 2026-11-25 14:57:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-25T14:57:32Z.


Change

Add a dedicated standalone AOT lifter (tools/cpu_avx_round_aot.py), source-built MASM fixture (tests/cpu/avx_round.asm, tests/cpu/avx_round.def), and differential/mutant/rejection check suite (tests/cpu/avx_round_check.py) for VEX AVX floating-point rounding instructions VROUNDPS, VROUNDPD, VROUNDSS, and VROUNDSD (docs/coverage/x64_zen2.tsv group AVX).

Why a separate lifter alongside cpu_aot_avx_shuffle_blend / cpu_aot_avx_scalar_fp (tools/ffx_version_query.py): those shared lowerings reject imm8[2]=1 (MXCSR rounding mode); this dedicated leaf lifter implements full live MXCSR rounding (std::fegetround()), imm8[3]=1 FE_INEXACT suppression, host DAZ (_mm_getcsr() & 0x0040u) subnormal flushing before rounding, and sNaN FE_INVALID + payload-preserving quieting with portable IEEE-754 integer arithmetic and ALTER_ROUND / /O2 controls.

  • Lowers 128-bit and 256-bit VROUNDPS / VROUNDPD and scalar VROUNDSS / VROUNDSD (register and flat [rcx|rdx|r8] memory sources) in pure portable IEEE-754 integer bit arithmetic with no <immintrin.h> rounding intrinsics.
  • Implements exact IEEE-754 round-to-nearest-even (0), floor (1), ceil (2), and trunc (3), live std::fegetround() dispatch when imm8[2]=1, FE_INEXACT raising/suppression (imm8[3]=1), DAZ subnormal flushing (host_daz_enabled() via _mm_getcsr() & 0x0040u), FE_INVALID + payload-preserving quieting on sNaN, signed-zero preservation, YMM[255:128] zeroing on all VEX.128 writes, and scalar high-lane preservation.
  • Documents the contract and reproduction command in docs/experiments.md.

Verification

Commit: 7e907313 (merged with upstream/main 7e5c378d) across both dev (Debug) and release (/O2) presets on Windows x64:

  • cmake --build --preset dev --target cpu_sse_fp_harness cpu_avx_round_original cpu_avx_round_original_lifted cpu_avx_round_altered cpu_avx_round_altered_lifted -> exit 0.
  • ctest --preset dev -R "^cpu_aot_avx_round$" -E "cpu_native_archive_" --output-on-failure -V -> 100% tests passed, 0 tests failed out of 1 (0 skips):
    • rejections passed: 6 alt + 36 IR + 4 raw + 9 PE-patched + CLI
    • avx_round passed: 2580 native + 2580 lifted + 2494 /O2 cases across 43 exports; 4896 native + 4896 lifted + 4896 /O2 MXCSR runs; ALTER_ROUND diverged on 37 exports + 29 mutants caught
  • cmake --build --preset release --target cpu_sse_fp_harness cpu_avx_round_original cpu_avx_round_original_lifted cpu_avx_round_altered cpu_avx_round_altered_lifted -> exit 0.
  • ctest --preset release -R "^cpu_aot_avx_round$" -E "cpu_native_archive_" --output-on-failure -V -> 100% tests passed, 0 tests failed out of 1 (0 skips).
  • out/pe-env/Scripts/python.exe -B tests/form_coverage_check.py, tests/docs_links_check.py (154 md / 677 links), tests/bidi_controls_check.py (2542 files) -> all exit 0.

Evidence and follow-up

  • tests/cpu/avx_round.{asm,def,_check.py} is a clean-room, source-built MASM fixture (MIT, repo-authored; no game files, dumps, or binaries).
  • Uses an independent exact-rational fractions.Fraction reference model; runs lift, rejection, portable lifted, MXCSR (DAZ off/on + subnormals under RD/RU), FE_INEXACT, FE_INVALID (sNaN vs qNaN), mutant, and /O2 checks before any host_has_avx() exit-77 capability skip (0 skips on this AVX-capable host).

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.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5493772103 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2390). Originally posted by [Ammmae0x](https://github.com/Ammmae0x) on 2026-11-25T14:57:32Z. --- ## Change Add a dedicated standalone AOT lifter (`tools/cpu_avx_round_aot.py`), source-built MASM fixture (`tests/cpu/avx_round.asm`, `tests/cpu/avx_round.def`), and differential/mutant/rejection check suite (`tests/cpu/avx_round_check.py`) for VEX AVX floating-point rounding instructions `VROUNDPS`, `VROUNDPD`, `VROUNDSS`, and `VROUNDSD` (`docs/coverage/x64_zen2.tsv` group `AVX`). Why a separate lifter alongside `cpu_aot_avx_shuffle_blend` / `cpu_aot_avx_scalar_fp` (`tools/ffx_version_query.py`): those shared lowerings reject `imm8[2]=1` (MXCSR rounding mode); this dedicated leaf lifter implements full live MXCSR rounding (`std::fegetround()`), `imm8[3]=1` `FE_INEXACT` suppression, host DAZ (`_mm_getcsr() & 0x0040u`) subnormal flushing before rounding, and `sNaN` `FE_INVALID` + payload-preserving quieting with portable IEEE-754 integer arithmetic and `ALTER_ROUND` / `/O2` controls. - Lowers 128-bit and 256-bit `VROUNDPS` / `VROUNDPD` and scalar `VROUNDSS` / `VROUNDSD` (register and flat `[rcx|rdx|r8]` memory sources) in pure portable IEEE-754 integer bit arithmetic with no `<immintrin.h>` rounding intrinsics. - Implements exact IEEE-754 round-to-nearest-even (`0`), floor (`1`), ceil (`2`), and trunc (`3`), live `std::fegetround()` dispatch when `imm8[2]=1`, `FE_INEXACT` raising/suppression (`imm8[3]=1`), DAZ subnormal flushing (`host_daz_enabled()` via `_mm_getcsr() & 0x0040u`), `FE_INVALID` + payload-preserving quieting on `sNaN`, signed-zero preservation, `YMM[255:128]` zeroing on all VEX.128 writes, and scalar high-lane preservation. - Documents the contract and reproduction command in `docs/experiments.md`. ## Verification Commit: `7e907313` (merged with `upstream/main` `7e5c378d`) across both `dev` (Debug) and `release` (`/O2`) presets on Windows x64: - `cmake --build --preset dev --target cpu_sse_fp_harness cpu_avx_round_original cpu_avx_round_original_lifted cpu_avx_round_altered cpu_avx_round_altered_lifted` -> exit 0. - `ctest --preset dev -R "^cpu_aot_avx_round$" -E "cpu_native_archive_" --output-on-failure -V` -> `100% tests passed, 0 tests failed out of 1` (0 skips): - `rejections passed: 6 alt + 36 IR + 4 raw + 9 PE-patched + CLI` - `avx_round passed: 2580 native + 2580 lifted + 2494 /O2 cases across 43 exports; 4896 native + 4896 lifted + 4896 /O2 MXCSR runs; ALTER_ROUND diverged on 37 exports + 29 mutants caught` - `cmake --build --preset release --target cpu_sse_fp_harness cpu_avx_round_original cpu_avx_round_original_lifted cpu_avx_round_altered cpu_avx_round_altered_lifted` -> exit 0. - `ctest --preset release -R "^cpu_aot_avx_round$" -E "cpu_native_archive_" --output-on-failure -V` -> `100% tests passed, 0 tests failed out of 1` (0 skips). - `out/pe-env/Scripts/python.exe -B tests/form_coverage_check.py`, `tests/docs_links_check.py` (154 md / 677 links), `tests/bidi_controls_check.py` (2542 files) -> all exit 0. ## Evidence and follow-up - `tests/cpu/avx_round.{asm,def,_check.py}` is a clean-room, source-built MASM fixture (MIT, repo-authored; no game files, dumps, or binaries). - Uses an independent exact-rational `fractions.Fraction` reference model; runs lift, rejection, portable lifted, MXCSR (DAZ off/on + subnormals under RD/RU), `FE_INEXACT`, `FE_INVALID` (`sNaN` vs `qNaN`), mutant, and `/O2` checks before any `host_has_avx()` exit-77 capability skip (0 skips on this AVX-capable host). ## 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. AI-assisted.
R0Y00 commented 2026-11-25 15:04:36 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T15:04:36Z.

Review: CHANGES_REQUESTED


The current Release test passes, but an extra native/lifted run at 4a38e19b found a result mismatch. Using the existing MXCSR driver and op_vroundps_xmm_ru with input lane bits 00000001, both implementations return 3f800000 at MXCSR 0x1f80. At 0x1fc0 (DAZ), native returns 00000000 and lifted still returns 3f800000. Please handle DAZ at the rounding input or constrain and enforce the entry profile so the unsupported mode cannot silently produce a different result. Cover positive and negative subnormals with directed rounding for f32 and f64. Also clarify whether MXCSR invalid sticky status on signaling NaNs is in the proposed contract, since the current evidence covers the output payload and precision status.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6060113306 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2390#pullrequestreview-6060113306). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T15:04:36Z. **Review:** CHANGES_REQUESTED --- The current Release test passes, but an extra native/lifted run at `4a38e19b` found a result mismatch. Using the existing MXCSR driver and `op_vroundps_xmm_ru` with input lane bits `00000001`, both implementations return `3f800000` at MXCSR `0x1f80`. At `0x1fc0` (DAZ), native returns `00000000` and lifted still returns `3f800000`. Please handle DAZ at the rounding input or constrain and enforce the entry profile so the unsupported mode cannot silently produce a different result. Cover positive and negative subnormals with directed rounding for f32 and f64. Also clarify whether MXCSR invalid sticky status on signaling NaNs is in the proposed contract, since the current evidence covers the output payload and precision status.
Ammmae0x commented 2026-11-25 16:05:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-25T15:20:31Z.


Addressed in 00548e41:

  1. MXCSR DAZ handling: tools/cpu_avx_round_aot.py now reads live MXCSR DAZ (_mm_getcsr() & 0x0040u) in host_daz_enabled() and flushes subnormal inputs to signed zero (+/-0.0) before rounding in round_f32_bits and round_f64_bits (matching native hardware at 0x1fc0 for 0x00000001 -> 0x00000000, without raising FE_INEXACT).
  2. Positive/negative subnormal directed-rounding coverage: tests/cpu/avx_round_check.py now tests MXCSR_EXPORTS across all 4 rounding modes x DAZ 0/1, plus all 18 explicit directed-rounding _rd/_ru/_rz exports (f32 and f64, XMM/YMM/SS/SD) under 0x1f80 and 0x1fc0, explicit +/-min and +/-max subnormal assertions, and 8 ignore_daz mutant controls.
  3. Signaling NaN FE_INVALID contract: round_f32_bits and round_f64_bits now raise FE_INVALID on sNaN inputs (unaffected by imm8[3] inexact suppress) and quiet them preserving sign/payload; verified on both native AVX and lifted code (with negative checks on qNaN).

Verified on 00548e41 on both --preset dev and --preset release (ctest -R "^cpu_aot_avx_round$"): 2580 native + 2580 lifted + 2494 /O2 cases across 43 exports, 4896 native + 4896 lifted + 4896 /O2 MXCSR runs, 37 ALTER_ROUND + 29 mutants + 2 spot-mutations (DAZ, FE_INVALID) caught, plus form_coverage_check.py, docs_links_check.py, and bidi_controls_check.py (all exit 0).

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7166689683 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2390#issuecomment-7166689683). Originally posted by [Ammmae0x](https://github.com/Ammmae0x) on 2026-11-25T15:20:31Z. --- Addressed in `00548e41`: 1. **MXCSR DAZ handling**: `tools/cpu_avx_round_aot.py` now reads live MXCSR DAZ (`_mm_getcsr() & 0x0040u`) in `host_daz_enabled()` and flushes subnormal inputs to signed zero (`+/-0.0`) before rounding in `round_f32_bits` and `round_f64_bits` (matching native hardware at `0x1fc0` for `0x00000001` -> `0x00000000`, without raising `FE_INEXACT`). 2. **Positive/negative subnormal directed-rounding coverage**: `tests/cpu/avx_round_check.py` now tests `MXCSR_EXPORTS` across all 4 rounding modes x DAZ `0/1`, plus all 18 explicit directed-rounding `_rd`/`_ru`/`_rz` exports (f32 and f64, XMM/YMM/SS/SD) under `0x1f80` and `0x1fc0`, explicit `+/-min` and `+/-max` subnormal assertions, and 8 `ignore_daz` mutant controls. 3. **Signaling NaN `FE_INVALID` contract**: `round_f32_bits` and `round_f64_bits` now raise `FE_INVALID` on sNaN inputs (unaffected by `imm8[3]` inexact suppress) and quiet them preserving sign/payload; verified on both native AVX and lifted code (with negative checks on qNaN). Verified on `00548e41` on both `--preset dev` and `--preset release` (`ctest -R "^cpu_aot_avx_round$"`): 2580 native + 2580 lifted + 2494 `/O2` cases across 43 exports, 4896 native + 4896 lifted + 4896 `/O2` MXCSR runs, 37 `ALTER_ROUND` + 29 mutants + 2 spot-mutations (DAZ, `FE_INVALID`) caught, plus `form_coverage_check.py`, `docs_links_check.py`, and `bidi_controls_check.py` (all exit 0). AI-assisted.
KelboLive commented 2026-11-25 16:05:26 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-25T16:02:37Z.


APPROVED: AVX rounding AOT lifter by Ammmae0x. Author self-addressed DAZ handling per R0Y00's feedback.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7167542201 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2390#issuecomment-7167542201). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-25T16:02:37Z. --- APPROVED: AVX rounding AOT lifter by Ammmae0x. Author self-addressed DAZ handling per R0Y00's feedback.
pigalot commented 2026-11-27 22:18:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T22:18:40Z.

Review: APPROVED


I reviewed 00548e41 merged over current main e582a9a4. The merge is clean and git diff --cached --check is clean. The merged diff is the five files of the PR.

R0Y00's findings on 4a38e19b are addressed.

  • DAZ: round_f32_bits and round_f64_bits now read MXCSR bit 6 through host_daz_enabled(). With DAZ set, a subnormal input becomes signed zero before the mode is applied, so op_vroundps_xmm_ru on 00000001 at 0x1fc0 now returns 00000000, as native does.
  • Coverage: avx_round_check.py runs the MXCSR exports in all four modes with DAZ off and on. It runs the 18 explicit _rd/_ru/_rz exports at 0x1f80 and 0x1fc0, comparing native, lifted and /O2 against the reference. The inputs include positive and negative minimum and maximum subnormals in f32 and f64, and the check asserts that RD and RU separate DAZ=0 from DAZ=1.
  • sNaN invalid status: this is now in the contract. An sNaN input raises FE_INVALID and is quieted with its sign and payload kept, while a qNaN raises nothing. Native and lifted are both checked for this.

What I ran. I built cpu_sse_fp_harness, cpu_avx_round_original, cpu_avx_round_altered and both _lifted targets in dev and release, then ran

ctest --test-dir out/build/<preset> --no-tests=error -R '^cpu_aot_avx_round$' --output-on-failure -V

The test passes in both presets with no skip. The output reads: 2580 native + 2580 lifted + 2494 /O2 cases across 43 exports; 4896 native + 4896 lifted + 4896 /O2 MXCSR runs; ALTER_ROUND diverged on 37 exports + 29 mutants caught, and rejections passed: 6 alt + 36 IR + 4 raw + 9 PE-patched + CLI.

Mutants in tools/cpu_avx_round_aot.py. For each, I rebuilt the lifted targets in dev and reran cpu_aot_avx_round:

Mutant Result
f32 DAZ check removed killed
f64 DAZ check removed killed
host_daz_enabled reads FTZ (bit 15) instead of DAZ (bit 6) killed
f32 DAZ flush returns +0 instead of the signed zero killed
f32 sNaN no longer raises FE_INVALID killed (sNaN f32 unexpected flags)
f64 sNaN no longer raises FE_INVALID killed (sNaN f64 unexpected flags)
f32 ` x
f64 ` x

Restored and rebuilt afterwards; git diff --quiet is clean.

Non-blocking. The PR description still reads "Verified on commit 4a38e19b", and its Change list doesn't mention DAZ or FE_INVALID. The 00548e41 comment has the current receipt, so moving that into the description would keep the two in step.

Verdict: approve on 00548e41. R0Y00's changes request on 4a38e19b still stands, so the merge waits for R0Y00 to re-check it.

Environment: Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10; AVX-capable host. No GPU is involved in this test.
CI: Build and test on Windows, Assemble and translate gfx1013 fixtures and Run platform-independent Python checks on Linux pass on 00548e41.

This reply was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6093884558 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2390#pullrequestreview-6093884558). Originally posted by [pigalot](https://github.com/pigalot) on 2026-11-27T22:18:40Z. **Review:** APPROVED --- I reviewed `00548e41` merged over current `main` `e582a9a4`. The merge is clean and `git diff --cached --check` is clean. The merged diff is the five files of the PR. **R0Y00's findings on `4a38e19b` are addressed.** - **DAZ:** `round_f32_bits` and `round_f64_bits` now read MXCSR bit 6 through `host_daz_enabled()`. With DAZ set, a subnormal input becomes signed zero before the mode is applied, so `op_vroundps_xmm_ru` on `00000001` at `0x1fc0` now returns `00000000`, as native does. - **Coverage:** `avx_round_check.py` runs the MXCSR exports in all four modes with DAZ off and on. It runs the 18 explicit `_rd`/`_ru`/`_rz` exports at `0x1f80` and `0x1fc0`, comparing native, lifted and `/O2` against the reference. The inputs include positive and negative minimum and maximum subnormals in f32 and f64, and the check asserts that RD and RU separate DAZ=0 from DAZ=1. - **sNaN invalid status:** this is now in the contract. An sNaN input raises `FE_INVALID` and is quieted with its sign and payload kept, while a qNaN raises nothing. Native and lifted are both checked for this. **What I ran.** I built `cpu_sse_fp_harness`, `cpu_avx_round_original`, `cpu_avx_round_altered` and both `_lifted` targets in `dev` and `release`, then ran ```powershell ctest --test-dir out/build/<preset> --no-tests=error -R '^cpu_aot_avx_round$' --output-on-failure -V ``` The test passes in both presets with no skip. The output reads: `2580 native + 2580 lifted + 2494 /O2 cases across 43 exports; 4896 native + 4896 lifted + 4896 /O2 MXCSR runs; ALTER_ROUND diverged on 37 exports + 29 mutants caught`, and `rejections passed: 6 alt + 36 IR + 4 raw + 9 PE-patched + CLI`. **Mutants** in `tools/cpu_avx_round_aot.py`. For each, I rebuilt the lifted targets in `dev` and reran `cpu_aot_avx_round`: | Mutant | Result | |---|---| | f32 DAZ check removed | killed | | f64 DAZ check removed | killed | | `host_daz_enabled` reads FTZ (bit 15) instead of DAZ (bit 6) | killed | | f32 DAZ flush returns `+0` instead of the signed zero | killed | | f32 sNaN no longer raises `FE_INVALID` | killed (`sNaN f32 unexpected flags`) | | f64 sNaN no longer raises `FE_INVALID` | killed (`sNaN f64 unexpected flags`) | | f32 `|x| < 1` nearest rounds 0.5 up | killed | | f64 `|x| < 1` nearest rounds 0.5 up | killed | Restored and rebuilt afterwards; `git diff --quiet` is clean. **Non-blocking.** The PR description still reads "Verified on commit `4a38e19b`", and its Change list doesn't mention DAZ or `FE_INVALID`. The `00548e41` comment has the current receipt, so moving that into the description would keep the two in step. **Verdict:** approve on `00548e41`. R0Y00's changes request on `4a38e19b` still stands, so the merge waits for R0Y00 to re-check it. Environment: Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10; AVX-capable host. No GPU is involved in this test. CI: `Build and test on Windows`, `Assemble and translate gfx1013 fixtures` and `Run platform-independent Python checks on Linux` pass on `00548e41`. This reply was AI-assisted.
JohnConnorNPC commented 2026-11-28 08:12:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-28T08:12:32Z.


Review of head 00548e41: I'd merge this with the notes below. This is a comment, not an approval. reviewDecision is still CHANGES_REQUESTED, so it needs R0Y00's re-review before it can land.

The three requested changes are all on the head. DAZ: abs_bits < 0x00800000u && host_daz_enabled() returns the signed zero, f64 does the same, and the bit comes from _mm_getcsr() & 0x0040u. ± subnormals under RD/RU: 0x80000001, # -min subnormal and for rc in (1, 2): are in avx_round_check.py. sNaN: std::feraiseexcept(FE_INVALID) on both widths, checked by sNaN f32 unexpected flags. pigalot's review table on this head shows 8/8 mutants killed.

Rounding core. I ported round_f32_bits/round_f64_bits to Python and compared it with an exact fractions.Fraction reference. The cases covered every exponent, ties and near-ties, both signs and all 4 modes, and compared the result plus the inexact flag: 0 of 689256 mismatches. Two controls both go red: ties-away gives 104 mismatches and rounding 0.5 up for |x|<1 gives 8.

Merge. git merge-tree --write-tree origin/main pr2390 (main 1f07b2c1) has rc=0. On the merged tree, tests/form_coverage_check.py, tests/docs_links_check.py and tests/bidi_controls_check.py all exit 0. Scope: static review plus Python on Linux. I didn't do a Windows or Wine build.

Should fix

  1. The diff has no docs row (git diff --name-only → 0 .md files), but the checklist ticks "I updated README/docs". Sibling lifters each have a paragraph with their ctest line. A note with ctest --preset dev --no-tests=error -R '^cpu_aot_avx_round$' -V and the DAZ/FE_INVALID contract would match them.
  2. CI doesn't run the new test. The Windows job runs ctest --preset pr (100% tests passed out of 33), and grep -c cpu_aot_avx_round on that log gives 0. The only runs are the author's and pigalot's. A run on the current merge would be worth having before landing.

Nits
3. The body still says "Verified on commit 4a38e19b" with 1392 MXCSR runs, and it doesn't mention DAZ or FE_INVALID. The current receipt is in the 00548e41 comment.
4. cpu_aot_avx_shuffle_blend and cpu_aot_avx_scalar_fp already lift vroundps/pd/ss/sd and reject the MXCSR mode. A line explaining why this is a separate lifter would help. That's a maintainer call, not a defect.

This comment was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7236434108 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2390#issuecomment-7236434108). Originally posted by [JohnConnorNPC](https://github.com/JohnConnorNPC) on 2026-11-28T08:12:32Z. --- Review of head `00548e41`: I'd merge this with the notes below. This is a comment, not an approval. `reviewDecision` is still `CHANGES_REQUESTED`, so it needs R0Y00's re-review before it can land. **The three requested changes are all on the head.** DAZ: `abs_bits < 0x00800000u && host_daz_enabled()` returns the signed zero, f64 does the same, and the bit comes from `_mm_getcsr() & 0x0040u`. ± subnormals under RD/RU: `0x80000001, # -min subnormal` and `for rc in (1, 2):` are in `avx_round_check.py`. sNaN: `std::feraiseexcept(FE_INVALID)` on both widths, checked by `sNaN f32 unexpected flags`. pigalot's review table on this head shows 8/8 mutants killed. **Rounding core.** I ported `round_f32_bits`/`round_f64_bits` to Python and compared it with an exact `fractions.Fraction` reference. The cases covered every exponent, ties and near-ties, both signs and all 4 modes, and compared the result plus the inexact flag: `0 of 689256` mismatches. Two controls both go red: ties-away gives `104` mismatches and rounding 0.5 up for `|x|<1` gives `8`. **Merge.** `git merge-tree --write-tree origin/main pr2390` (main `1f07b2c1`) has rc=0. On the merged tree, `tests/form_coverage_check.py`, `tests/docs_links_check.py` and `tests/bidi_controls_check.py` all exit 0. Scope: static review plus Python on Linux. I didn't do a Windows or Wine build. **Should fix** 1. The diff has no docs row (`git diff --name-only` → 0 `.md` files), but the checklist ticks "I updated README/docs". Sibling lifters each have a paragraph with their ctest line. A note with `ctest --preset dev --no-tests=error -R '^cpu_aot_avx_round$' -V` and the DAZ/FE_INVALID contract would match them. 2. CI doesn't run the new test. The Windows job runs `ctest --preset pr` (`100% tests passed out of 33`), and `grep -c cpu_aot_avx_round` on that log gives `0`. The only runs are the author's and pigalot's. A run on the current merge would be worth having before landing. **Nits** 3. The body still says "Verified on commit `4a38e19b`" with `1392` MXCSR runs, and it doesn't mention DAZ or FE_INVALID. The current receipt is in the `00548e41` comment. 4. `cpu_aot_avx_shuffle_blend` and `cpu_aot_avx_scalar_fp` already lift `vroundps/pd/ss/sd` and reject the MXCSR mode. A line explaining why this is a separate lifter would help. That's a maintainer call, not a defect. This comment was AI-assisted.
Ammmae0x commented 2026-11-28 11:17:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-28T11:17:08Z.


Addressed the remaining documentation and receipt items from pigalot and JohnConnorNPC in 7e907313 (merged with upstream/main 7e5c378d):

  • Added cpu_aot_avx_round to docs/experiments.md documenting the DAZ (_mm_getcsr() & 0x0040u), FE_INVALID (sNaN vs qNaN), FE_INEXACT suppression, and live std::fegetround() contract alongside the ctest --preset dev --no-tests=error -R '^cpu_aot_avx_round$' -V reproduction command and measured counts.
  • Updated the PR body to reflect the current DAZ/FE_INVALID receipt (4896 MXCSR runs, 29 mutants caught), explain why cpu_avx_round_aot is a separate dedicated leaf lifter alongside cpu_aot_avx_shuffle_blend/cpu_aot_avx_scalar_fp, and record the current Windows dev + release (/O2) verification output (100% tests passed, 0 tests failed out of 1 in both presets; form_coverage_check.py, docs_links_check.py, and bidi_controls_check.py exit 0).

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7238449969 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2390#issuecomment-7238449969). Originally posted by [Ammmae0x](https://github.com/Ammmae0x) on 2026-11-28T11:17:08Z. --- Addressed the remaining documentation and receipt items from pigalot and JohnConnorNPC in `7e907313` (merged with `upstream/main` `7e5c378d`): - Added `cpu_aot_avx_round` to `docs/experiments.md` documenting the DAZ (`_mm_getcsr() & 0x0040u`), `FE_INVALID` (`sNaN` vs `qNaN`), `FE_INEXACT` suppression, and live `std::fegetround()` contract alongside the `ctest --preset dev --no-tests=error -R '^cpu_aot_avx_round$' -V` reproduction command and measured counts. - Updated the PR body to reflect the current DAZ/`FE_INVALID` receipt (`4896` MXCSR runs, `29` mutants caught), explain why `cpu_avx_round_aot` is a separate dedicated leaf lifter alongside `cpu_aot_avx_shuffle_blend`/`cpu_aot_avx_scalar_fp`, and record the current Windows `dev` + `release` (`/O2`) verification output (`100% tests passed, 0 tests failed out of 1` in both presets; `form_coverage_check.py`, `docs_links_check.py`, and `bidi_controls_check.py` exit 0). AI-assisted.
pigalot commented 2026-11-28 11:29:48 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-28T11:29:48Z.

Review: APPROVED


Retested 7e907313 integrated over main 24fcd0b5 (tree 0ec9b3e4). This follows my approval on 00548e41.

What changed since 00548e41. Two commits, both by the author:

  • 8aeab5de merges main. git show --remerge-diff 8aeab5de is empty, so it resolved without hand edits. The lifter, fixture, .def and check script are byte-identical to 00548e41, and the PR's CMakeLists.txt hunk is unchanged.
  • 7e907313 adds one paragraph for cpu_aot_avx_round to docs/experiments.md. I checked it against the code and the test output: the DAZ bit (_mm_getcsr() & 0x0040u), FE_INVALID on sNaN with the payload kept, FE_INEXACT suppression on imm8[3], live std::fegetround() on imm8[2], and the counts all match what the test prints.

The trial merge over current main is clean, git diff --cached --check is clean, and the merged diff is the six files of the PR.

Earlier findings. My review on 00548e41 had no blocking finding. Its one non-blocking note (the description still cited 4a38e19b and didn't mention DAZ or FE_INVALID) is addressed: the description now gives the 7e907313 receipt. JohnConnorNPC's notes 1, 3 and 4 (docs entry, stale receipt, why a separate lifter) are addressed in the docs paragraph and the description. Note 2 still holds: the pr preset in CI doesn't run cpu_aot_avx_round, so the runs below are local.

What I ran. Built cpu_sse_fp_harness, cpu_avx_round_original, cpu_avx_round_altered and both _lifted targets in dev and release, then

ctest --test-dir out/build/<preset> --no-tests=error -j 1 -V -R '^cpu_aot_avx_round$'

1 passed in Debug and in Release /O2, no skip. Both print 2580 native + 2580 lifted + 2494 /O2 cases across 43 exports; 4896 native + 4896 lifted + 4896 /O2 MXCSR runs; ALTER_ROUND diverged on 37 exports + 29 mutants caught and rejections passed: 6 alt + 36 IR + 4 raw + 9 PE-patched + CLI. On the merged tree, tests/form_coverage_check.py, tests/docs_links_check.py and tests/bidi_controls_check.py exit 0.

Mutants in tools/cpu_avx_round_aot.py, mostly different from the eight in my last review. For each I rebuilt both lifted targets in dev and reran the test.

Killed (12):

Mutant First failure
f32 DAZ check removed MXCSR run assertion
f64 sNaN no longer raises FE_INVALID sNaN f64 unexpected flags
FE_DOWNWARD mapped to ceil MXCSR run assertion
FE_TOWARDZERO mapped to nearest MXCSR run assertion
f32 already-integer threshold 2^23 lowered to 2^22 got ... != exp ...
f64 already-integer threshold 2^52 lowered to 2^51 got ... != exp ...
f32 ties away from zero got ... != exp ...
f64 ties away from zero got ... != exp ...
vroundss drops source-1 bits 63:32 got ... != exp ...
vroundsd zeroes the high qword instead of taking source 1 got ... != exp ...
vroundpd xmm keeps YMM[255:128] got ... != exp ...
f32 NaN returned without the quiet bit got ... != exp ...

Surviving: none. Equivalent: none.

The file was restored from its raw bytes, the targets rebuilt and the test passes again; git diff --quiet is clean.

Non-blocking.

  • AGENTS.md now says new notes go in docs/experiments/<topic>.md and new test families in tests/cmake/<family>.cmake. This PR adds its paragraph to docs/experiments.md and its 34 lines to the root CMakeLists.txt, next to the sibling AVX lifters. I'm not asking for a move; it's the maintainer's call whether the older placement is fine here.

Verdict: approve on 7e907313. R0Y00's changes request on 4a38e19b still stands on the PR, so I'm not merging it; its three points (DAZ, subnormal directed-rounding coverage, sNaN invalid status) were addressed in 00548e41 and are unchanged at this head.

Environment: Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10; AVX-capable host. No GPU is involved in this test.
CI: Build and test on Windows, Assemble and translate gfx1013 fixtures and Run platform-independent Python checks on Linux pass on 7e907313.

This reply was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6097499359 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2390#pullrequestreview-6097499359). Originally posted by [pigalot](https://github.com/pigalot) on 2026-11-28T11:29:48Z. **Review:** APPROVED --- Retested `7e907313` integrated over `main` `24fcd0b5` (tree `0ec9b3e4`). This follows my approval on `00548e41`. **What changed since `00548e41`.** Two commits, both by the author: - `8aeab5de` merges `main`. `git show --remerge-diff 8aeab5de` is empty, so it resolved without hand edits. The lifter, fixture, `.def` and check script are byte-identical to `00548e41`, and the PR's `CMakeLists.txt` hunk is unchanged. - `7e907313` adds one paragraph for `cpu_aot_avx_round` to `docs/experiments.md`. I checked it against the code and the test output: the DAZ bit (`_mm_getcsr() & 0x0040u`), `FE_INVALID` on sNaN with the payload kept, `FE_INEXACT` suppression on `imm8[3]`, live `std::fegetround()` on `imm8[2]`, and the counts all match what the test prints. The trial merge over current `main` is clean, `git diff --cached --check` is clean, and the merged diff is the six files of the PR. **Earlier findings.** My review on `00548e41` had no blocking finding. Its one non-blocking note (the description still cited `4a38e19b` and didn't mention DAZ or `FE_INVALID`) is addressed: the description now gives the `7e907313` receipt. JohnConnorNPC's notes 1, 3 and 4 (docs entry, stale receipt, why a separate lifter) are addressed in the docs paragraph and the description. Note 2 still holds: the `pr` preset in CI doesn't run `cpu_aot_avx_round`, so the runs below are local. **What I ran.** Built `cpu_sse_fp_harness`, `cpu_avx_round_original`, `cpu_avx_round_altered` and both `_lifted` targets in `dev` and `release`, then ```powershell ctest --test-dir out/build/<preset> --no-tests=error -j 1 -V -R '^cpu_aot_avx_round$' ``` 1 passed in Debug and in Release `/O2`, no skip. Both print `2580 native + 2580 lifted + 2494 /O2 cases across 43 exports; 4896 native + 4896 lifted + 4896 /O2 MXCSR runs; ALTER_ROUND diverged on 37 exports + 29 mutants caught` and `rejections passed: 6 alt + 36 IR + 4 raw + 9 PE-patched + CLI`. On the merged tree, `tests/form_coverage_check.py`, `tests/docs_links_check.py` and `tests/bidi_controls_check.py` exit 0. **Mutants** in `tools/cpu_avx_round_aot.py`, mostly different from the eight in my last review. For each I rebuilt both lifted targets in `dev` and reran the test. Killed (12): | Mutant | First failure | |---|---| | f32 DAZ check removed | MXCSR run assertion | | f64 sNaN no longer raises `FE_INVALID` | `sNaN f64 unexpected flags` | | `FE_DOWNWARD` mapped to ceil | MXCSR run assertion | | `FE_TOWARDZERO` mapped to nearest | MXCSR run assertion | | f32 already-integer threshold 2^23 lowered to 2^22 | `got ... != exp ...` | | f64 already-integer threshold 2^52 lowered to 2^51 | `got ... != exp ...` | | f32 ties away from zero | `got ... != exp ...` | | f64 ties away from zero | `got ... != exp ...` | | `vroundss` drops source-1 bits 63:32 | `got ... != exp ...` | | `vroundsd` zeroes the high qword instead of taking source 1 | `got ... != exp ...` | | `vroundpd xmm` keeps `YMM[255:128]` | `got ... != exp ...` | | f32 NaN returned without the quiet bit | `got ... != exp ...` | Surviving: none. Equivalent: none. The file was restored from its raw bytes, the targets rebuilt and the test passes again; `git diff --quiet` is clean. **Non-blocking.** - `AGENTS.md` now says new notes go in `docs/experiments/<topic>.md` and new test families in `tests/cmake/<family>.cmake`. This PR adds its paragraph to `docs/experiments.md` and its 34 lines to the root `CMakeLists.txt`, next to the sibling AVX lifters. I'm not asking for a move; it's the maintainer's call whether the older placement is fine here. **Verdict:** approve on `7e907313`. R0Y00's changes request on `4a38e19b` still stands on the PR, so I'm not merging it; its three points (DAZ, subnormal directed-rounding coverage, sNaN invalid status) were addressed in `00548e41` and are unchanged at this head. Environment: Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; Python 3.12.10; AVX-capable host. No GPU is involved in this test. CI: `Build and test on Windows`, `Assemble and translate gfx1013 fixtures` and `Run platform-independent Python checks on Linux` pass on `7e907313`. This reply was AI-assisted.
JohnConnorNPC commented 2026-11-29 13:24:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by JohnConnorNPC on 2026-11-29T13:24:32Z.


Re-review of head 7e907313, trial-merged onto main c04e0dd6 (git merge-tree --write-tree exits 0, git diff --check clean). Static review plus Python on Linux. I did no Windows or Wine build.

Since my comment on 00548e41:

  • 8aeab5de is a clean merge of main (git show --remerge-diff 8aeab5de prints nothing). tools/cpu_avx_round_aot.py, avx_round.asm, avx_round.def and avx_round_check.py have the same blob ids as at 00548e41.
  • I re-ran my Python port of round_f32_bits/round_f64_bits against an exact fractions.Fraction reference, covering every exponent, ties and near-ties, both signs and all four modes: port!=Fraction ref: 0 of 689256. It is still a faithful port, because the lifter is byte-identical.
  • I read the semantics against the SDM ROUNDPS/PD/SS/SD rules. DAZ is applied only to the element being rounded, and op_vroundss copies src1[63:32] and src1.q[1] bit for bit. An sNaN raises FE_INVALID and comes back quiet with its payload kept, while a qNaN passes through. A DAZ-flushed input returns the signed zero without FE_INEXACT. Nothing raises a denormal flag, and the SDM lists no denormal exception for these instructions.
  • The new docs/experiments.md paragraph matches the code. host_daz_enabled reads _mm_getcsr() & 0x0040u. Its claim that the portable checks run before the AVX skip is right: avx_round_check.py's main() runs verify_against_ref(lifted), verify_mxcsr_modes, check_altered_and_mutants and compile_o2_and_verify before if not host_has_avx(...): sys.exit(77). The .def has 43 exports, as the paragraph says.
  • The description now gives the current receipt and explains why this is a separate lifter. That closes my two nits.
  • On the merged tree, form_coverage_check, docs_links_check (Checked 171 Markdown files and 711 links.) and bidi_controls_check exit 0.

MUST: none.
SHOULD: none from me. The CI coverage and the file-placement notes are already in the latest approval, so I won't repeat them.
NIT: the paragraph calls the code "pure portable IEEE-754 integer bit arithmetic", but DAZ is read with the x86 _mm_getcsr() intrinsic. "Integer bit arithmetic, with DAZ read from MXCSR" would be exact.

From my side this is ready to merge. It is still blocked by the changes request on 4a38e19b. All three of its points (DAZ at the rounding input, ± subnormals under directed rounding, sNaN FE_INVALID) are on this head, so it needs a re-review or a dismissal by the reviewer who opened it.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7256515463 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2390#issuecomment-7256515463). Originally posted by [JohnConnorNPC](https://github.com/JohnConnorNPC) on 2026-11-29T13:24:32Z. --- Re-review of head `7e907313`, trial-merged onto `main` `c04e0dd6` (`git merge-tree --write-tree` exits 0, `git diff --check` clean). Static review plus Python on Linux. I did no Windows or Wine build. Since my comment on `00548e41`: - `8aeab5de` is a clean merge of `main` (`git show --remerge-diff 8aeab5de` prints nothing). `tools/cpu_avx_round_aot.py`, `avx_round.asm`, `avx_round.def` and `avx_round_check.py` have the same blob ids as at `00548e41`. - I re-ran my Python port of `round_f32_bits`/`round_f64_bits` against an exact `fractions.Fraction` reference, covering every exponent, ties and near-ties, both signs and all four modes: `port!=Fraction ref: 0 of 689256`. It is still a faithful port, because the lifter is byte-identical. - I read the semantics against the SDM `ROUNDPS/PD/SS/SD` rules. DAZ is applied only to the element being rounded, and `op_vroundss` copies `src1[63:32]` and `src1.q[1]` bit for bit. An sNaN raises `FE_INVALID` and comes back quiet with its payload kept, while a qNaN passes through. A DAZ-flushed input returns the signed zero without `FE_INEXACT`. Nothing raises a denormal flag, and the SDM lists no denormal exception for these instructions. - The new `docs/experiments.md` paragraph matches the code. `host_daz_enabled` reads `_mm_getcsr() & 0x0040u`. Its claim that the portable checks run before the AVX skip is right: `avx_round_check.py`'s `main()` runs `verify_against_ref(lifted)`, `verify_mxcsr_modes`, `check_altered_and_mutants` and `compile_o2_and_verify` before `if not host_has_avx(...): sys.exit(77)`. The `.def` has 43 exports, as the paragraph says. - The description now gives the current receipt and explains why this is a separate lifter. That closes my two nits. - On the merged tree, `form_coverage_check`, `docs_links_check` (`Checked 171 Markdown files and 711 links.`) and `bidi_controls_check` exit 0. MUST: none. SHOULD: none from me. The CI coverage and the file-placement notes are already in the latest approval, so I won't repeat them. NIT: the paragraph calls the code "pure portable IEEE-754 integer bit arithmetic", but DAZ is read with the x86 `_mm_getcsr()` intrinsic. "Integer bit arithmetic, with DAZ read from MXCSR" would be exact. From my side this is ready to merge. It is still blocked by the changes request on `4a38e19b`. All three of its points (DAZ at the rounding input, ± subnormals under directed rounding, sNaN `FE_INVALID`) are on this head, so it needs a re-review or a dismissal by the reviewer who opened it. AI-assisted.
Ammmae0x commented 2026-12-01 03:22:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-12-01T03:22:00Z.


@R0Y00 Friendly re-review ping: your CHANGES_REQUESTED review on 4a38e19b is currently the only merge block on this PR.

Head 7e907313 addresses live MXCSR DAZ subnormal flushing (_mm_getcsr() & 0x0040u), FE_INVALID on sNaN inputs, directed-rounding subnormal coverage, and docs/experiments.md. All 5 CI checks pass, git merge-tree --write-tree onto upstream/main (1c634037) exits 0, and @pigalot has reviewed and approved 7e907313 (confirming the findings on 4a38e19b are addressed).

Could you re-review when you have a moment so this can land? Thank you!

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7299630632 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2390#issuecomment-7299630632). Originally posted by [Ammmae0x](https://github.com/Ammmae0x) on 2026-12-01T03:22:00Z. --- @R0Y00 Friendly re-review ping: your `CHANGES_REQUESTED` review on `4a38e19b` is currently the only merge block on this PR. Head `7e907313` addresses live MXCSR DAZ subnormal flushing (`_mm_getcsr() & 0x0040u`), `FE_INVALID` on sNaN inputs, directed-rounding subnormal coverage, and `docs/experiments.md`. All 5 CI checks pass, `git merge-tree --write-tree` onto `upstream/main` (`1c634037`) exits `0`, and `@pigalot` has reviewed and approved `7e907313` (confirming the findings on `4a38e19b` are addressed). Could you re-review when you have a moment so this can land? Thank you! AI-assisted.
R0Y00 commented 2026-12-02 12:18:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T12:18:44Z.

Review: APPROVED


The original DAZ mismatch is covered by the signed-subnormal f32/f64 controls, and the sNaN invalid-status contract is specified and tested. Pigalot independently checked native/lifted results in Debug and Release and confirmed the reviewed implementation is byte-identical on 7e907313. The current trial merge and required Windows job are green.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6150574957 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2390#pullrequestreview-6150574957). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-02T12:18:44Z. **Review:** APPROVED --- The original DAZ mismatch is covered by the signed-subnormal f32/f64 controls, and the sNaN invalid-status contract is specified and tested. Pigalot independently checked native/lifted results in Debug and Release and confirmed the reviewed implementation is byte-identical on `7e907313`. The current trial merge and required Windows job are green.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2382
No description provided.