fix: compute RndneF32 with a single return so the RX 9070 XT keeps v_bfrev_b32 #341

Open
github-bot wants to merge 1 commit from github-bot/gh-341 into main AGit
Owner

@⁠Cai-piroska on GitHub · 2026-11-26 09:12 UTC · original
Cai-piroska:fix/rndne-f32-single-return → main · +17 −6 · 2 files · 1 commits · open

Change

#260 moved v_rndne_f32 to integer HLSL, with early returns in RndneF32. On an RX 9070 XT (RDNA 4, driver 32.0.32029.2010), those early returns make the driver miscompile the neighbouring v_bfrev_b32 in test_extended_alu_matches_interpreter_on_gpu: on all 32 lanes, v13 (slot 9) comes back as 0x60c04080 where the interpreter gives 0x20c04080, with bit 30 set. v_rndne_f32 itself is right. #160 hit the same thing on this card and was fixed in 855e527, but #160 was closed for a conflict, so neither the fix nor its test reached main. I reported it on #260 before the merge.

This PR keeps #260's integer algorithm and replaces the early returns with selects: each case is computed and the result chosen at the end. shift stays at 1 outside the range where it is used, so every shift stays defined. It also brings back #160's test_rndne_helper_has_a_single_return.

Linked issue: Refs #260, Refs #160, Refs #227

Verification

Windows 11 26300, Python 3.12.10, pytest 8.3.5, ruff 0.17.6, dxc 1.9.2602.17 (Windows SDK 10.0.26100). C++ runtime built with VS 2022 Build Tools from 9a06443; runtime/ has not changed between 9a06443 and c4c93bd. Trees: main c4c93bd and this branch on top of it.

python -m pytest                → main: 1649 passed, 16 skipped; this PR: 1650 passed, 16 skipped (default adapter: RTX 3080 Ti)
python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools → All checks passed!

python -m pytest tests/test_rdna2*.py, 2 runs per adapter, the same result in both runs:

Adapter main c4c93bd this PR
RX 9070 XT (RDNA 4), driver 32.0.32029.2010, ANYXBOXX_GPU=Radeon 1241 passed, 1 failed 1243 passed
RTX 3080 Ti (Ampere), driver 32.0.16.2114, ANYXBOXX_GPU=NVIDIA 1242 passed 1243 passed
WARP 10.0.26100.9818, ANYXBOXX_GPU=warp 1242 passed 1243 passed

The failure on main is test_extended_alu_matches_interpreter_on_gpu; the only differing words are slot 9 (v_bfrev_b32), lanes 0-31: interpreter 0x20c04080, GPU 0x60c04080. #260's test_v_rndne_f32_ties_to_even_and_specials_on_gpu passes on all three adapters on both trees.

Oracle and test data

  • HLSL translation: compared with the reference interpreter, byte for byte, on the three adapters above, through the existing test_extended_alu_matches_interpreter_on_gpu and test_v_rndne_f32_ties_to_even_and_specials_on_gpu (ties, signed zeros, subnormals, infinities, quiet and signalling NaNs).
  • No new test data. The new test only reads the RndneF32 source in HELPERS.
  • Failure case without this change: test_rndne_helper_has_a_single_return on every adapter (the helper on main has 4 returns), and test_extended_alu_matches_interpreter_on_gpu on the RX 9070 XT.

Checklist

  • The PR covers a single reviewable behaviour.
  • A test fails without this change and passes with it.
  • The commands and results of each check are given above.
  • An unimplemented function returns an error (E_NOTIMPL), never a fake success. (No new function.)
  • README: the same change in all 9 languages (test_readme_sync.py checks it). (No README change: 1,650 tests stays 1600+.)
  • No game, console or SDK file, no key, no dump, no download link.
  • Findings drawn from a title: limited to what rule 2 of AGENTS.md allows (names, slots, argument shapes, flag values, HRESULTs, IIDs, counts), with how they were obtained; no address or RVA. (None: everything comes from the test suite.)
  • Code taken from another project: compatible licence and credit in THIRD_PARTY.md. (None. The test comes from #160 in this repository, credited with Co-authored-by to its author.)

AI use: tests run, regression located and change written with Claude Code (Claude Opus 5.5) on my machine.

🤖 Generated with Claude Code

**@⁠Cai-piroska** on GitHub · 2026-11-26 09:12 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/341) `Cai-piroska:fix/rndne-f32-single-return` → `main` · +17 −6 · 2 files · 1 commits · open ## Change #260 moved `v_rndne_f32` to integer HLSL, with early `return`s in `RndneF32`. On an RX 9070 XT (RDNA 4, driver 32.0.32029.2010), those early returns make the driver miscompile the neighbouring `v_bfrev_b32` in `test_extended_alu_matches_interpreter_on_gpu`: on all 32 lanes, `v13` (slot 9) comes back as `0x60c04080` where the interpreter gives `0x20c04080`, with bit 30 set. `v_rndne_f32` itself is right. #160 hit the same thing on this card and was fixed in 855e527, but #160 was closed for a conflict, so neither the fix nor its test reached `main`. I reported it on #260 before the merge. This PR keeps #260's integer algorithm and replaces the early returns with selects: each case is computed and the result chosen at the end. `shift` stays at 1 outside the range where it is used, so every shift stays defined. It also brings back #160's `test_rndne_helper_has_a_single_return`. Linked issue: Refs #260, Refs #160, Refs #227 ## Verification Windows 11 26300, Python 3.12.10, pytest 8.3.5, ruff 0.17.6, dxc 1.9.2602.17 (Windows SDK 10.0.26100). C++ runtime built with VS 2022 Build Tools from `9a06443`; `runtime/` has not changed between `9a06443` and `c4c93bd`. Trees: `main` `c4c93bd` and this branch on top of it. ``` python -m pytest → main: 1649 passed, 16 skipped; this PR: 1650 passed, 16 skipped (default adapter: RTX 3080 Ti) python -m ruff check --select W605,F,E9 PrototypeScarlett tests tools → All checks passed! ``` `python -m pytest tests/test_rdna2*.py`, 2 runs per adapter, the same result in both runs: | Adapter | `main` `c4c93bd` | this PR | |---|---|---| | RX 9070 XT (RDNA 4), driver 32.0.32029.2010, `ANYXBOXX_GPU=Radeon` | 1241 passed, **1 failed** | 1243 passed | | RTX 3080 Ti (Ampere), driver 32.0.16.2114, `ANYXBOXX_GPU=NVIDIA` | 1242 passed | 1243 passed | | WARP 10.0.26100.9818, `ANYXBOXX_GPU=warp` | 1242 passed | 1243 passed | The failure on `main` is `test_extended_alu_matches_interpreter_on_gpu`; the only differing words are slot 9 (`v_bfrev_b32`), lanes 0-31: interpreter `0x20c04080`, GPU `0x60c04080`. #260's `test_v_rndne_f32_ties_to_even_and_specials_on_gpu` passes on all three adapters on both trees. ## Oracle and test data - HLSL translation: compared with the reference interpreter, byte for byte, on the three adapters above, through the existing `test_extended_alu_matches_interpreter_on_gpu` and `test_v_rndne_f32_ties_to_even_and_specials_on_gpu` (ties, signed zeros, subnormals, infinities, quiet and signalling NaNs). - No new test data. The new test only reads the `RndneF32` source in `HELPERS`. - Failure case without this change: `test_rndne_helper_has_a_single_return` on every adapter (the helper on `main` has 4 `return`s), and `test_extended_alu_matches_interpreter_on_gpu` on the RX 9070 XT. ## Checklist - [x] The PR covers a single reviewable behaviour. - [x] A test fails without this change and passes with it. - [x] The commands and results of each check are given above. - [x] An unimplemented function returns an error (`E_NOTIMPL`), never a fake success. (No new function.) - [x] README: the same change in all 9 languages (`test_readme_sync.py` checks it). (No README change: 1,650 tests stays `1600+`.) - [x] No game, console or SDK file, no key, no dump, no download link. - [x] Findings drawn from a title: limited to what rule 2 of `AGENTS.md` allows (names, slots, argument shapes, flag values, HRESULTs, IIDs, counts), with how they were obtained; no address or RVA. (None: everything comes from the test suite.) - [x] Code taken from another project: compatible licence and credit in `THIRD_PARTY.md`. (None. The test comes from #160 in this repository, credited with `Co-authored-by` to its author.) AI use: tests run, regression located and change written with Claude Code (Claude Opus 5.5) on my machine. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
With the early returns merged in #260, the AMD driver for the RX 9070 XT
(32.0.32029.2010) miscompiles the neighbouring v_bfrev_b32 in
test_extended_alu_matches_interpreter_on_gpu: bit 30 is set on all 32
lanes (0x60c04080 instead of 0x20c04080). The same integer algorithm now
computes each case and picks the result at the end, and the shift stays
at 1 outside the range where it is used. The test from #160 checks that
the helper keeps a single return.

Co-authored-by: marquezini <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 11:03:12 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/341/head:github-bot/gh-341'
git switch 'github-bot/gh-341'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-341'
git switch 'github-bot/gh-341'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-341'
git switch 'github-bot/gh-341'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-341'
git switch 'main'
git merge --squash 'github-bot/gh-341'
git switch 'main'
git merge --ff-only 'github-bot/gh-341'
git switch 'main'
git merge 'github-bot/gh-341'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.