MTBUF d16: RDNA2-measured conversions replace the ISA-only lowering #41

Closed
github-bot wants to merge 1 commit from gh-pr/41/head into gh-pr/41/base
Owner

@⁠SchmashinPrunes on GitHub · 2026-11-21 18:58 UTC · original
SchmashinPrunes:mtbuf-d16 → main · +1665 −167 · 16 files · 84 commits · closed without merging

Library / area: tombox-xshader (RDNA2 shader translator), MTBUF tbuffer_{load,store}_format_d16_*, plus a new tools/rdna2-hwprobe. Completes #17 (the LDS-atomics half landed on main in 1159c96).

Rebased onto 0fc7295. Main now carries an ISA-text-only d16 lowering (1159c96). This PR replaces it with the hardware-measured rules below. Compared with main it:

  • lowers UNORM/SNORM, 16-bit USCALED/SSCALED and 32-bit-component loads, which main refuses;
  • writes the whole element on partial d16 stores (main writes only the covered bytes);
  • rounds snorm store ties away from zero, as measured (main goes through the 32-bit pack, see #42).

The 8 d16 mnemonics are already counted as verified on main, so gen.py output is unchanged. The evidence caveat in progress.json ("tbuffer d16 refuses UNORM/SNORM and 32-bit-component formats") no longer applies after this PR; I left that text for you to edit.

Exports changed (exports.txt rows): none

Source of the behaviour: measurements on real RDNA2 hardware, the gfx1036 iGPU of a Ryzen 5 9600X under ROCm. I used the new tools/rdna2-hwprobe, which runs hand-written kernels; no game or console files are involved. The public ISA text only says "convert to packed 16-bit". It doesn't specify the rounding, the int narrowing, or what happens to the unused register half, so I measured those. Packed layout per LLVM's AMDGPU backend (HasPackedD16VMem on GFX9+).

Measured semantics (77 formats × 65536 elements, every 8/16-bit value)

RDNA2 behaviour
layout Packed: c0/c1 in vdata lo/hi, c2/c3 in vdata+1. _x / _xyz keep the upper half of their last VGPR
unorm / snorm / u- / sscaled → fp16 Exact value rounded once to nearest-even, saturating at ±65504. Not via fp32: unorm16 65519 gives 0x3bff, fp32-then-fp16 would give 0x3c00
32-bit float → fp16 Round toward zero. Finite overflow → ±65504, inf stays inf
NaN → fp16 sign|0x7c00|((mant>>13) or 1). Payload truncated, not quieted
32-bit int → 16 Clamped, never truncated
store: fp16 → unorm / snorm unorm rounds to nearest-even; snorm rounds halves away from zero (2-bit field: ±0.5 → ±1). NaN → 0
store: int 16-bit input zero-extended (uint) / sign-extended (sint), then clamped
store: fewer components than the format Writes the whole element, missing components 0

A missing w on d16 loads reads 1 (0x3c00 / 1), matching the existing 32-bit loads. On hardware that 1 comes from the descriptor's dst_sel. The probe used an identity swizzle, so it saw 0. Scaled and 11/10-bit-float stores didn't follow any simple rule and stay unlowered, the same as the 32-bit forms.

Translator

src/hlsl/mtbuf.rs: loads reuse the existing fetch and field extraction, then narrow each component with D16_HELPERS. Stores unpack the halves and pack them per format. All conversions are integer-only:

  • Exact rounding uses uint64_t.
  • fp16 → unorm/snorm is (M·max) >> sh.

A first version used float/double math, and WARP got it wrong twice: DXC folded x != x, and a double product was off by one. hlsl.rs gains a uses_d16 flag that emits the helpers.

Tests (tests/exec_mem/mtbuf.rs)

  • Reference model. Written independently of the HLSL (fp16 rounding by search over exact fp16 values).
    • Checked against all recorded hardware results (5.0M load + 14.4M store elements): 0 mismatches.
    • mtbuf_d16_model_matches_rdna2 pins it to 571 recorded vectors (mtbuf_hw.rs, regenerated by tools/rdna2-hwprobe/vectors.py), weighted to the cases where naive rules differ.
  • mtbuf_d16_load_formats: 539 cases on WARP, each rerun with runtime inputs.
    • 64 threads per case, all four ops over all 77 formats.
    • 8-bit fields exhaustive, then edge values.
    • VGPRs preset to sentinels to check the preserved halves.
  • mtbuf_d16_store_formats: 330 cases, output pre-filled with 0xAA.
  • Mutation check. Each of these makes the tests fail:
    • ties up instead of even;
    • f32 rounded to nearest;
    • u32 truncated instead of clamped;
    • _x zeroing the upper half;
    • snorm ties to even.
  • mtbuf_d16_load_addressing (308 cases) / mtbuf_d16_store_addressing (660 cases): immediate offset, SGPR offset and unaligned element addresses, adapted from the d16 tests in 1159c96 (thanks @⁠QuentinDanblon) and checked against the hardware-matched model.
  • mtbuf_refuses_unlowered: drops the now-lowered d16 rows and adds d16 scaled/f11 stores.
TOMBOX_DXC_DIR=<dxc 1.9.2609>\bin\x64 cargo test -p tombox-xshader --release --test exec mtbuf
mtbuf_d16_load: 4 mnemonics verified, 0 failing, 539 cases, 539 rerun with runtime inputs
mtbuf_d16_load_addr: 4 mnemonics verified, 0 failing, 308 cases, 308 rerun with runtime inputs
mtbuf_d16_store: 4 mnemonics verified, 0 failing, 330 cases
mtbuf_d16_store_addr: 4 mnemonics verified, 0 failing, 660 cases, 660 rerun with runtime inputs
mtbuf_load / mtbuf_store: unchanged, all pass
test result: ok. 8 passed; 0 failed

python tools/progress/gen.py: no change (main's 769/779 already counts the d16 rows).

Full cargo test -p tombox-xshader --release (Windows 11 Pro, WARP)

All green on the rebased branch: 0 failures in every target (exec 73 pass / 1 ignored; dump-fixture tests ignored as on main).

Also found

The 32-bit store path disagrees with hardware on partial stores and snorm ties. That's a separate issue: #42. This PR doesn't change any 32-bit behaviour.

  • cargo test -p tombox-xshader passes for the changed area
  • No game or console files and no binaries included (the probe generates its kernels and synthetic inputs)
  • No fake success; scaled / 11-10-bit float d16 stores stay unlowered with an explicit error

🤖 Generated with Claude Code

**@⁠SchmashinPrunes** on GitHub · 2026-11-21 18:58 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/41) `SchmashinPrunes:mtbuf-d16` → `main` · +1665 −167 · 16 files · 84 commits · closed without merging **Library / area:** tombox-xshader (RDNA2 shader translator), MTBUF `tbuffer_{load,store}_format_d16_*`, plus a new `tools/rdna2-hwprobe`. Completes #17 (the LDS-atomics half landed on main in 1159c96). **Rebased onto 0fc7295.** Main now carries an ISA-text-only d16 lowering (1159c96). This PR replaces it with the hardware-measured rules below. Compared with main it: - lowers UNORM/SNORM, 16-bit USCALED/SSCALED and 32-bit-component loads, which main refuses; - writes the **whole element** on partial d16 stores (main writes only the covered bytes); - rounds snorm store ties away from zero, as measured (main goes through the 32-bit pack, see #42). The 8 d16 mnemonics are already counted as verified on main, so `gen.py` output is unchanged. The `evidence` caveat in `progress.json` ("tbuffer d16 refuses UNORM/SNORM and 32-bit-component formats") no longer applies after this PR; I left that text for you to edit. **Exports changed (exports.txt rows):** none **Source of the behaviour:** measurements on real RDNA2 hardware, the gfx1036 iGPU of a Ryzen 5 9600X under ROCm. I used the new `tools/rdna2-hwprobe`, which runs hand-written kernels; no game or console files are involved. The public ISA text only says "convert to packed 16-bit". It doesn't specify the rounding, the int narrowing, or what happens to the unused register half, so I measured those. Packed layout per LLVM's AMDGPU backend (`HasPackedD16VMem` on GFX9+). ### Measured semantics (77 formats × 65536 elements, every 8/16-bit value) | | RDNA2 behaviour | |---|---| | layout | Packed: c0/c1 in `vdata` lo/hi, c2/c3 in `vdata+1`. `_x` / `_xyz` **keep the upper half** of their last VGPR | | unorm / snorm / u- / sscaled → fp16 | Exact value rounded **once** to nearest-even, saturating at ±65504. Not via fp32: unorm16 65519 gives `0x3bff`, fp32-then-fp16 would give `0x3c00` | | 32-bit float → fp16 | **Round toward zero**. Finite overflow → ±65504, inf stays inf | | NaN → fp16 | `sign\|0x7c00\|((mant>>13) or 1)`. Payload truncated, **not quieted** | | 32-bit int → 16 | **Clamped**, never truncated | | store: fp16 → unorm / snorm | unorm rounds to nearest-even; snorm rounds **halves away from zero** (2-bit field: ±0.5 → ±1). NaN → 0 | | store: int | 16-bit input zero-extended (uint) / sign-extended (sint), then clamped | | store: fewer components than the format | Writes the **whole element**, missing components 0 | A missing w on d16 loads reads 1 (0x3c00 / 1), matching the existing 32-bit loads. On hardware that 1 comes from the descriptor's dst_sel. The probe used an identity swizzle, so it saw 0. Scaled and 11/10-bit-float **stores** didn't follow any simple rule and stay unlowered, the same as the 32-bit forms. ### Translator `src/hlsl/mtbuf.rs`: loads reuse the existing fetch and field extraction, then narrow each component with `D16_HELPERS`. Stores unpack the halves and pack them per format. All conversions are integer-only: - Exact rounding uses `uint64_t`. - fp16 → unorm/snorm is `(M·max) >> sh`. A first version used float/double math, and WARP got it wrong twice: DXC folded `x != x`, and a double product was off by one. `hlsl.rs` gains a `uses_d16` flag that emits the helpers. ### Tests (`tests/exec_mem/mtbuf.rs`) - **Reference model.** Written independently of the HLSL (fp16 rounding by search over exact fp16 values). - Checked against **all** recorded hardware results (5.0M load + 14.4M store elements): 0 mismatches. - `mtbuf_d16_model_matches_rdna2` pins it to 571 recorded vectors (`mtbuf_hw.rs`, regenerated by `tools/rdna2-hwprobe/vectors.py`), weighted to the cases where naive rules differ. - **`mtbuf_d16_load_formats`**: 539 cases on WARP, each rerun with runtime inputs. - 64 threads per case, all four ops over all 77 formats. - 8-bit fields exhaustive, then edge values. - VGPRs preset to sentinels to check the preserved halves. - **`mtbuf_d16_store_formats`**: 330 cases, output pre-filled with 0xAA. - **Mutation check.** Each of these makes the tests fail: - ties up instead of even; - f32 rounded to nearest; - u32 truncated instead of clamped; - `_x` zeroing the upper half; - snorm ties to even. - **`mtbuf_d16_load_addressing`** (308 cases) / **`mtbuf_d16_store_addressing`** (660 cases): immediate offset, SGPR offset and unaligned element addresses, adapted from the d16 tests in 1159c96 (thanks @⁠QuentinDanblon) and checked against the hardware-matched model. - **`mtbuf_refuses_unlowered`**: drops the now-lowered d16 rows and adds d16 scaled/f11 stores. ``` TOMBOX_DXC_DIR=<dxc 1.9.2609>\bin\x64 cargo test -p tombox-xshader --release --test exec mtbuf mtbuf_d16_load: 4 mnemonics verified, 0 failing, 539 cases, 539 rerun with runtime inputs mtbuf_d16_load_addr: 4 mnemonics verified, 0 failing, 308 cases, 308 rerun with runtime inputs mtbuf_d16_store: 4 mnemonics verified, 0 failing, 330 cases mtbuf_d16_store_addr: 4 mnemonics verified, 0 failing, 660 cases, 660 rerun with runtime inputs mtbuf_load / mtbuf_store: unchanged, all pass test result: ok. 8 passed; 0 failed ``` `python tools/progress/gen.py`: no change (main's 769/779 already counts the d16 rows). ### Full `cargo test -p tombox-xshader --release` (Windows 11 Pro, WARP) All green on the rebased branch: 0 failures in every target (`exec` 73 pass / 1 ignored; dump-fixture tests ignored as on main). ### Also found The 32-bit store path disagrees with hardware on partial stores and snorm ties. That's a separate issue: #42. This PR doesn't change any 32-bit behaviour. - [x] `cargo test -p tombox-xshader` passes for the changed area - [x] No game or console files and no binaries included (the probe generates its kernels and synthetic inputs) - [x] No fake success; scaled / 11-10-bit float d16 stores stay unlowered with an explicit error 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Replaces the d16 tbuffer lowering with conversion rules measured on RDNA2
hardware (gfx1036 via ROCm, tools/rdna2-hwprobe):

- loads: UNORM/SNORM/USCALED/SSCALED round once to nearest-even fp16,
  saturating at +-65504; 32-bit float rounds toward zero (overflow ->
  +-65504, inf kept, NaN payload kept); 32-bit ints clamp. These were
  refused before.
- stores: fp16 widened exactly (NaN payload kept), unorm rounds to
  nearest-even, snorm rounds ties away from zero, ints extend then clamp;
  the whole element is written with missing components 0.

mtbuf_d16_model_matches_rdna2 checks the Rust reference model against
the recorded hardware vectors (mtbuf_hw.rs); the WARP tests compare the
translator with that model. The address-mode cases (imm/soffset/
unaligned) from the previous d16 tests are kept as
mtbuf_d16_{load,store}_addressing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:08:12 +00:00
github-bot closed this pull request 2026-11-26 06:08:12 +00:00
Author
Owner

@⁠QuentinDanblon on GitHub · 2026-11-21 21:44 UTC · original

Note for review: the d16 MTBUF code now on main (1159c96, hlsl/mtbuf.rs + the mtbuf_d16_* groups) is my version, written from the ISA text only. It refuses UNORM/SNORM, 32-bit components and 16-bit scaled formats, because the ISA gives no rounding/clamp rule for them. This PR measured those rules on real RDNA2 (gfx1036): single round-to-nearest-even to fp16 saturating at ±65504, 32-bit float to fp16 rounding toward zero, 32-bit int clamped, _x/_xyz keeping the upper half. That's strictly better evidence than mine, so where they differ I'd take this PR's semantics over main's refusals. The upper-half rule matches what main already does.

**@⁠QuentinDanblon** on GitHub · 2026-11-21 21:44 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/41#issuecomment-7069688504) Note for review: the d16 MTBUF code now on main (1159c96, `hlsl/mtbuf.rs` + the `mtbuf_d16_*` groups) is my version, written from the ISA text only. It **refuses** UNORM/SNORM, 32-bit components and 16-bit scaled formats, because the ISA gives no rounding/clamp rule for them. This PR measured those rules on real RDNA2 (gfx1036): single round-to-nearest-even to fp16 saturating at ±65504, 32-bit float to fp16 rounding toward zero, 32-bit int clamped, `_x`/`_xyz` keeping the upper half. That's strictly better evidence than mine, so where they differ I'd take this PR's semantics over main's refusals. The upper-half rule matches what main already does.
Author
Owner

@⁠SchmashinPrunes on GitHub · 2026-11-21 22:38 UTC · original

Thanks! Rebased onto 1159c96. Since main now has your d16 lowering, this PR replaces it with the hardware-measured semantics: UNORM/SNORM/32-bit/16-bit scaled now lowered, and d16 stores write the whole element (missing components 0) with snorm ties rounding away from zero, matching gfx1036. I kept your address-mode cases (imm/soffset/unaligned) as mtbuf_d16_*_addressing against the hardware-matched model.

**@⁠SchmashinPrunes** on GitHub · 2026-11-21 22:38 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/41#issuecomment-7070321738) Thanks! Rebased onto 1159c96. Since main now has your d16 lowering, this PR replaces it with the hardware-measured semantics: UNORM/SNORM/32-bit/16-bit scaled now lowered, and d16 stores write the whole element (missing components 0) with snorm ties rounding away from zero, matching gfx1036. I kept your address-mode cases (imm/soffset/unaligned) as `mtbuf_d16_*_addressing` against the hardware-matched model.
Author
Owner

@⁠QuentinDanblon on GitHub · 2026-11-21 22:55 UTC · original

Your rdna2-hwprobe harness can answer more than MTBUF. Several open questions in other PRs come down to "what does RDNA2 actually return", and nobody else here seems to have the hardware. I wrote a second generator on top of your runner and kernel preamble: branch probe/valu-open-questions on my fork (one commit on top of this PR, tools/rdna2-hwprobe/valu_probe.py + a README section, nothing else touched).

It generates 33 kernels:

Probe Question it settles Where it matters
fma16 Are VOP2 0x36 / 0x37 / 0x38 fused (v_fmac/fmamk/fmaak_f16, LLVM's GFX10 names) or multiply-then-add (v_mac/madmk/madak_f16, what main implements)? Each kernel also runs v_fma_f16 and v_mul_f16 + v_add_f16 on the same inputs, so both references come from the hardware. About 28,000 of the 65,536 inputs per kernel separate the two. #49 vs the ISA sweep on main
sbfe s_bfe_{u,i}{32,64} with a width field of 32 or more: 7-bit width with sign-fill past the top bit (main since 8491769), 7-bit width with the literal ISA formula (zero-fill), or width modulo the operand size (the older test oracle). 152 cases. #38, #70
nan Which NaN v_fma_f32, v_mul_f32, v_add_f32, v_sub_f32, v_fmac_f32, v_min_f32, v_max_f32 return, IEEE mode off and on, over every combination of quiet/signalling NaN, infinity, zero and denormal. tb_fma on main, #61
norm Rounding, NaN and range handling of v_cvt_pknorm_{i,u}16_{f32,f16} and v_cvt_norm_{i,u}16_f16 (f16 forms exhaustive). the tb_nrm helper, #63
python3 tools/rdna2-hwprobe/valu_probe.py gen /tmp/valu
clang-18 -x assembler -target amdgcn-amd-amdhsa -mcpu=gfx1036 -c /tmp/valu/k.s -o /tmp/valu/k.o
ld.lld-18 -shared /tmp/valu/k.o -o /tmp/valu/k.co
/tmp/probe/runner /tmp/valu          # the runner run.sh already built
python3 tools/rdna2-hwprobe/valu_probe.py show /tmp/valu

show prints, per question, how many outputs match each candidate rule.

What I could and could not check: I have no AMD GPU, so none of this has run on hardware. The kernels assemble with LLVM 18 and disassemble identically for gfx1036 and gfx1013. I tested show against simulated outputs for each possible answer and it tells them apart. If a kernel faults or the preamble assumptions are wrong for a non-MTBUF kernel, that is my mistake, tell me and I'll fix it.

If you have ten minutes with the 9600X, the show output pasted here would settle three disagreements with measurements, the same way this PR did for d16. Feel free to pull the commit into this PR if you want it to live with the tool.

**@⁠QuentinDanblon** on GitHub · 2026-11-21 22:55 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/41#issuecomment-7070522883) Your `rdna2-hwprobe` harness can answer more than MTBUF. Several open questions in other PRs come down to "what does RDNA2 actually return", and nobody else here seems to have the hardware. I wrote a second generator on top of your runner and kernel preamble: branch [`probe/valu-open-questions`](https://github.com/QuentinDanblon/xbox-emulator/tree/probe/valu-open-questions) on my fork (one commit on top of this PR, `tools/rdna2-hwprobe/valu_probe.py` + a README section, nothing else touched). It generates 33 kernels: | Probe | Question it settles | Where it matters | |---|---|---| | `fma16` | Are VOP2 0x36 / 0x37 / 0x38 fused (`v_fmac/fmamk/fmaak_f16`, LLVM's GFX10 names) or multiply-then-add (`v_mac/madmk/madak_f16`, what main implements)? Each kernel also runs `v_fma_f16` and `v_mul_f16` + `v_add_f16` on the same inputs, so both references come from the hardware. About 28,000 of the 65,536 inputs per kernel separate the two. | #49 vs the ISA sweep on main | | `sbfe` | `s_bfe_{u,i}{32,64}` with a width field of 32 or more: 7-bit width with sign-fill past the top bit (main since `8491769`), 7-bit width with the literal ISA formula (zero-fill), or width modulo the operand size (the older test oracle). 152 cases. | #38, #70 | | `nan` | Which NaN `v_fma_f32`, `v_mul_f32`, `v_add_f32`, `v_sub_f32`, `v_fmac_f32`, `v_min_f32`, `v_max_f32` return, IEEE mode off and on, over every combination of quiet/signalling NaN, infinity, zero and denormal. | `tb_fma` on main, #61 | | `norm` | Rounding, NaN and range handling of `v_cvt_pknorm_{i,u}16_{f32,f16}` and `v_cvt_norm_{i,u}16_f16` (f16 forms exhaustive). | the `tb_nrm` helper, #63 | ``` python3 tools/rdna2-hwprobe/valu_probe.py gen /tmp/valu clang-18 -x assembler -target amdgcn-amd-amdhsa -mcpu=gfx1036 -c /tmp/valu/k.s -o /tmp/valu/k.o ld.lld-18 -shared /tmp/valu/k.o -o /tmp/valu/k.co /tmp/probe/runner /tmp/valu # the runner run.sh already built python3 tools/rdna2-hwprobe/valu_probe.py show /tmp/valu ``` `show` prints, per question, how many outputs match each candidate rule. What I could and could not check: I have no AMD GPU, so **none of this has run on hardware**. The kernels assemble with LLVM 18 and disassemble identically for gfx1036 and gfx1013. I tested `show` against simulated outputs for each possible answer and it tells them apart. If a kernel faults or the preamble assumptions are wrong for a non-MTBUF kernel, that is my mistake, tell me and I'll fix it. If you have ten minutes with the 9600X, the `show` output pasted here would settle three disagreements with measurements, the same way this PR did for d16. Feel free to pull the commit into this PR if you want it to live with the tool.
Author
Owner

@⁠QuentinDanblon on GitHub · 2026-11-21 23:15 UTC · original

Tested your rebased head 2515839, merged locally onto main 8491769 (no conflict), on two backends you may not have at hand:

--test exec exec_mem::mtbuf passed failed
WARP 8 0
NVIDIA RTX 5090 (TOMBOX_EXEC_HW=1) 8 0

That includes mtbuf_d16_model_matches_rdna2 and both mtbuf_d16_*_addressing tests. I did not run the rest of the suite on that merge.

The probe branch from my previous comment is rebased onto 2515839 as well (probe/valu-open-questions, still one commit on top of this PR, kernels re-assembled with LLVM 18). Still not run on hardware.

**@⁠QuentinDanblon** on GitHub · 2026-11-21 23:15 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/41#issuecomment-7070752902) Tested your rebased head `2515839`, merged locally onto main `8491769` (no conflict), on two backends you may not have at hand: | `--test exec exec_mem::mtbuf` | passed | failed | |---|---|---| | WARP | 8 | 0 | | NVIDIA RTX 5090 (`TOMBOX_EXEC_HW=1`) | 8 | 0 | That includes `mtbuf_d16_model_matches_rdna2` and both `mtbuf_d16_*_addressing` tests. I did not run the rest of the suite on that merge. The probe branch from my previous comment is rebased onto `2515839` as well ([`probe/valu-open-questions`](https://github.com/QuentinDanblon/xbox-emulator/tree/probe/valu-open-questions), still one commit on top of this PR, kernels re-assembled with LLVM 18). Still not run on hardware.
Author
Owner

@⁠SchmashinPrunes on GitHub · 2026-11-21 23:54 UTC · original · edited 2026-11-22 00:01 UTC

Ran valu_probe.py (efffbc0, unmodified) on the gfx1036 iGPU of a Ryzen 5 9600X: Mint, kernel 7.0.0-42, ROCm/HIP 5.7.1, clang/ld.lld 18.1.3. All 33 kernels ran, and no kernel had outputs that differ between threads.

Results

Probe RDNA2 answer
fma16 Fused. VOP2 0x36 / 0x37 / 0x38 match hardware v_fma_f16 on every discriminating input and never match v_mul_f16 + v_add_f16: 254,891 inputs over the three K values, fused on all, unfused on 0, neither on 0. Hardware v_fma_f16 matches the exact single-rounding model, 0 mismatches. The upper half of D is preserved (0x36 keeps D's old upper half, 0x37 / 0x38 keep the preset).
sbfe wide: 152 / 152 (lit 114, mod 100). The 7-bit width is used, and a signed field that reaches the top bit sign-fills. Junk in the unused S1 bits is ignored, and offset bit 5 (32-bit) or bit 6 (64-bit) is ignored. SCC = result != 0 in every case. This matches main since 8491769.
norm Round to nearest, 0 mismatches for all six ops (v_cvt_pknorm_{i,u}16_{f32,f16}, v_cvt_norm_{i,u}16_f16), with NaN → 0. halfup fails on i16 (51 / 2 / 1), so it's not floor(x+0.5). The v_cvt_norm_* upper half is preserved.
nan The single "first NaN, quieted" candidate doesn't fit; see below.

NaN rules (fitted, 0 mismatches)

The show candidate is off in three ways: sNaN isn't quieted in IEEE mode 0, v_sub negates src1, and the default NaN is 0xffc00000. I fitted these rules against the raw outputs. They reproduce every NaN result (fma 65265, mul 43824, add 43886, fmac 65265, sub 43886, min 43736, max 43736 cases, in each IEEE mode). No input outside the rules produced a NaN.

Arithmetic (fma / fmac / mul / add / sub), both IEEE modes:

  1. Operand order is (a, b, c) for fma/fmac and (src0, src1) otherwise. v_sub_f32 negates src1 first, so a NaN src1 comes out with its sign flipped: (0, 0x7fc00001) → 0xffc00001.
  2. fma/fmac only: if neither a nor b is NaN and a·b is invalid (0 · ±inf), the result is the default NaN even if c is NaN: (0, inf, 0x7fc00001) → 0xffc00000.
  3. Otherwise the result is the first NaN operand. IEEE mode 0: returned unchanged, sNaN included ((0x7f800003, 0x7fc00001) → 0x7f800003). IEEE mode 1: quieted (| 0x400000).
  4. Invalid operations with no NaN input (0 · inf, inf − inf, and the fma sum) return 0xffc00000 (negative quiet NaN) in both modes.

v_min_f32 / v_max_f32:

  • IEEE mode 0: a NaN operand is ignored when the other operand isn't NaN. With two NaNs the result is src0, unchanged (an sNaN stays signalling).
  • IEEE mode 1 (minNum-style): an sNaN operand wins and is quieted (src0 checked first). Otherwise a qNaN is ignored when the other operand isn't NaN, and with two qNaNs the result is src0.

Since this seems to be the only RDNA2 hardware the repo has at the moment, I'm happy to run probes or exec tests from other PRs on it too. Just mention me on the PR with what you'd like run.

The full show output and the fitting script are below.

valu_probe.py show (gfx1036)
== fma16: VOP2 0x36 / 0x37 / 0x38 against hardware v_fma_f16 (fused) and v_mul_f16 + v_add_f16 (unfused)
  K=0x3c01: hardware v_fma_f16 vs exact single-rounding model: 0 mismatches (zero-sign cases ignored)
    0x36 D=S0*S1+D: 28753 discriminating inputs -> fused 28753, unfused 0, neither 0; disagreements where both references agree: 0; upper half of D: ['0x5678']
    0x37 D=S0*K+S1: 28288 discriminating inputs -> fused 28288, unfused 0, neither 0; disagreements where both references agree: 0; upper half of D: ['0x5a5a']
    0x38 D=S0*S1+K: 28361 discriminating inputs -> fused 28361, unfused 0, neither 0; disagreements where both references agree: 0; upper half of D: ['0x5a5a']
  K=0x3555: hardware v_fma_f16 vs exact single-rounding model: 0 mismatches (zero-sign cases ignored)
    0x36 D=S0*S1+D: 27834 discriminating inputs -> fused 27834, unfused 0, neither 0; disagreements where both references agree: 0; upper half of D: ['0x5678']
    0x37 D=S0*K+S1: 25820 discriminating inputs -> fused 25820, unfused 0, neither 0; disagreements where both references agree: 0; upper half of D: ['0x5a5a']
    0x38 D=S0*S1+K: 31763 discriminating inputs -> fused 31763, unfused 0, neither 0; disagreements where both references agree: 0; upper half of D: ['0x5a5a']
  K=0xc248: hardware v_fma_f16 vs exact single-rounding model: 0 mismatches (zero-sign cases ignored)
    0x36 D=S0*S1+D: 28126 discriminating inputs -> fused 28126, unfused 0, neither 0; disagreements where both references agree: 0; upper half of D: ['0x5678']
    0x37 D=S0*K+S1: 29771 discriminating inputs -> fused 29771, unfused 0, neither 0; disagreements where both references agree: 0; upper half of D: ['0x5a5a']
    0x38 D=S0*S1+K: 26175 discriminating inputs -> fused 26175, unfused 0, neither 0; disagreements where both references agree: 0; upper half of D: ['0x5a5a']
== s_bfe: 'wide' = 7-bit width, signed fields past the top bit sign-fill; 'lit' = 7-bit width, literal ISA formula (they zero-fill);
          'mod' = width modulo the operand size
  s_bfe_u32 off=0  width=32  junk=0: got 0x89abcdef scc=1  wide=0x89abcdef lit=0x89abcdef mod=0x0  -> wide+lit
  s_bfe_u32 off=0  width=33  junk=0: got 0x89abcdef scc=1  wide=0x89abcdef lit=0x89abcdef mod=0x1  -> wide+lit
  s_bfe_u32 off=0  width=63  junk=0: got 0x89abcdef scc=1  wide=0x89abcdef lit=0x89abcdef mod=0x9abcdef  -> wide+lit
  s_bfe_u32 off=0  width=64  junk=0: got 0x89abcdef scc=1  wide=0x89abcdef lit=0x89abcdef mod=0x0  -> wide+lit
  s_bfe_u32 off=0  width=65  junk=0: got 0x89abcdef scc=1  wide=0x89abcdef lit=0x89abcdef mod=0x1  -> wide+lit
  s_bfe_u32 off=0  width=96  junk=0: got 0x89abcdef scc=1  wide=0x89abcdef lit=0x89abcdef mod=0x0  -> wide+lit
  s_bfe_u32 off=0  width=127 junk=0: got 0x89abcdef scc=1  wide=0x89abcdef lit=0x89abcdef mod=0x9abcdef  -> wide+lit
  s_bfe_u32 off=4  width=32  junk=0: got 0x89abcde scc=1  wide=0x89abcde lit=0x89abcde mod=0x0  -> wide+lit
  s_bfe_u32 off=4  width=33  junk=0: got 0x89abcde scc=1  wide=0x89abcde lit=0x89abcde mod=0x0  -> wide+lit
  s_bfe_u32 off=4  width=64  junk=0: got 0x89abcde scc=1  wide=0x89abcde lit=0x89abcde mod=0x0  -> wide+lit
  s_bfe_u32 off=4  width=65  junk=0: got 0x89abcde scc=1  wide=0x89abcde lit=0x89abcde mod=0x0  -> wide+lit
  s_bfe_u32 off=4  width=96  junk=0: got 0x89abcde scc=1  wide=0x89abcde lit=0x89abcde mod=0x0  -> wide+lit
  s_bfe_u32 off=31 width=32  junk=0: got 0x1 scc=1  wide=0x1 lit=0x1 mod=0x0  -> wide+lit
  s_bfe_u32 off=31 width=64  junk=0: got 0x1 scc=1  wide=0x1 lit=0x1 mod=0x0  -> wide+lit
  s_bfe_u32 off=31 width=96  junk=0: got 0x1 scc=1  wide=0x1 lit=0x1 mod=0x0  -> wide+lit
  s_bfe_u32 off=4  width=40  junk=1: got 0x89abcde scc=1  wide=0x89abcde lit=0x89abcde mod=0xde  -> wide+lit
  s_bfe_u32 off=36 width=40  junk=0: got 0x89abcde scc=1  wide=0x89abcde lit=0x89abcde mod=0xde  -> wide+lit
  s_bfe_u64 off=0  width=64  junk=0: got 0x89abcdef01234567 scc=1  wide=0x89abcdef01234567 lit=0x89abcdef01234567 mod=0x0  -> wide+lit
  s_bfe_u64 off=0  width=65  junk=0: got 0x89abcdef01234567 scc=1  wide=0x89abcdef01234567 lit=0x89abcdef01234567 mod=0x1  -> wide+lit
  s_bfe_u64 off=0  width=127 junk=0: got 0x89abcdef01234567 scc=1  wide=0x89abcdef01234567 lit=0x89abcdef01234567 mod=0x9abcdef01234567  -> wide+lit
  s_bfe_u64 off=4  width=64  junk=0: got 0x89abcdef0123456 scc=1  wide=0x89abcdef0123456 lit=0x89abcdef0123456 mod=0x0  -> wide+lit
  s_bfe_u64 off=4  width=65  junk=0: got 0x89abcdef0123456 scc=1  wide=0x89abcdef0123456 lit=0x89abcdef0123456 mod=0x0  -> wide+lit
  s_bfe_u64 off=40 width=64  junk=0: got 0x89abcd scc=1  wide=0x89abcd lit=0x89abcd mod=0x0  -> wide+lit
  s_bfe_u64 off=40 width=65  junk=0: got 0x89abcd scc=1  wide=0x89abcd lit=0x89abcd mod=0x1  -> wide+lit
  s_bfe_u64 off=63 width=64  junk=0: got 0x1 scc=1  wide=0x1 lit=0x1 mod=0x0  -> wide+lit
  s_bfe_u64 off=4  width=72  junk=1: got 0x89abcdef0123456 scc=1  wide=0x89abcdef0123456 lit=0x89abcdef0123456 mod=0x56  -> wide+lit
  s_bfe_i32 off=0  width=32  junk=0: got 0x89abcdef scc=1  wide=0x89abcdef lit=0x89abcdef mod=0x0  -> wide+lit
  s_bfe_i32 off=0  width=33  junk=0: got 0x89abcdef scc=1  wide=0x89abcdef lit=0x89abcdef mod=0xffffffff  -> wide+lit
  s_bfe_i32 off=0  width=63  junk=0: got 0x89abcdef scc=1  wide=0x89abcdef lit=0x89abcdef mod=0x9abcdef  -> wide+lit
  s_bfe_i32 off=0  width=64  junk=0: got 0x89abcdef scc=1  wide=0x89abcdef lit=0x89abcdef mod=0x0  -> wide+lit
  s_bfe_i32 off=0  width=65  junk=0: got 0x89abcdef scc=1  wide=0x89abcdef lit=0x89abcdef mod=0xffffffff  -> wide+lit
  s_bfe_i32 off=0  width=96  junk=0: got 0x89abcdef scc=1  wide=0x89abcdef lit=0x89abcdef mod=0x0  -> wide+lit
  s_bfe_i32 off=0  width=127 junk=0: got 0x89abcdef scc=1  wide=0x89abcdef lit=0x89abcdef mod=0x9abcdef  -> wide+lit
  s_bfe_i32 off=4  width=31  junk=0: got 0xf89abcde scc=1  wide=0xf89abcde lit=0x89abcde mod=0xf89abcde  -> wide+mod
  s_bfe_i32 off=4  width=32  junk=0: got 0xf89abcde scc=1  wide=0xf89abcde lit=0x89abcde mod=0x0  -> wide
  s_bfe_i32 off=4  width=33  junk=0: got 0xf89abcde scc=1  wide=0xf89abcde lit=0x89abcde mod=0x0  -> wide
  s_bfe_i32 off=4  width=63  junk=0: got 0xf89abcde scc=1  wide=0xf89abcde lit=0x89abcde mod=0xf89abcde  -> wide+mod
  s_bfe_i32 off=4  width=64  junk=0: got 0xf89abcde scc=1  wide=0xf89abcde lit=0x89abcde mod=0x0  -> wide
  s_bfe_i32 off=4  width=65  junk=0: got 0xf89abcde scc=1  wide=0xf89abcde lit=0x89abcde mod=0x0  -> wide
  s_bfe_i32 off=4  width=96  junk=0: got 0xf89abcde scc=1  wide=0xf89abcde lit=0x89abcde mod=0x0  -> wide
  s_bfe_i32 off=4  width=127 junk=0: got 0xf89abcde scc=1  wide=0xf89abcde lit=0x89abcde mod=0xf89abcde  -> wide+mod
  s_bfe_i32 off=31 width=28  junk=0: got 0xffffffff scc=1  wide=0xffffffff lit=0x1 mod=0xffffffff  -> wide+mod
  s_bfe_i32 off=31 width=31  junk=0: got 0xffffffff scc=1  wide=0xffffffff lit=0x1 mod=0xffffffff  -> wide+mod
  s_bfe_i32 off=31 width=32  junk=0: got 0xffffffff scc=1  wide=0xffffffff lit=0x1 mod=0x0  -> wide
  s_bfe_i32 off=31 width=33  junk=0: got 0xffffffff scc=1  wide=0xffffffff lit=0x1 mod=0xffffffff  -> wide+mod
  s_bfe_i32 off=31 width=63  junk=0: got 0xffffffff scc=1  wide=0xffffffff lit=0x1 mod=0xffffffff  -> wide+mod
  s_bfe_i32 off=31 width=64  junk=0: got 0xffffffff scc=1  wide=0xffffffff lit=0x1 mod=0x0  -> wide
  s_bfe_i32 off=31 width=65  junk=0: got 0xffffffff scc=1  wide=0xffffffff lit=0x1 mod=0xffffffff  -> wide+mod
  s_bfe_i32 off=31 width=96  junk=0: got 0xffffffff scc=1  wide=0xffffffff lit=0x1 mod=0x0  -> wide
  s_bfe_i32 off=31 width=127 junk=0: got 0xffffffff scc=1  wide=0xffffffff lit=0x1 mod=0xffffffff  -> wide+mod
  s_bfe_i32 off=4  width=40  junk=1: got 0xf89abcde scc=1  wide=0xf89abcde lit=0x89abcde mod=0xffffffde  -> wide
  s_bfe_i32 off=36 width=40  junk=0: got 0xf89abcde scc=1  wide=0xf89abcde lit=0x89abcde mod=0xffffffde  -> wide
  s_bfe_i64 off=0  width=64  junk=0: got 0x89abcdef01234567 scc=1  wide=0x89abcdef01234567 lit=0x89abcdef01234567 mod=0x0  -> wide+lit
  s_bfe_i64 off=0  width=65  junk=0: got 0x89abcdef01234567 scc=1  wide=0x89abcdef01234567 lit=0x89abcdef01234567 mod=0xffffffffffffffff  -> wide+lit
  s_bfe_i64 off=0  width=127 junk=0: got 0x89abcdef01234567 scc=1  wide=0x89abcdef01234567 lit=0x89abcdef01234567 mod=0x9abcdef01234567  -> wide+lit
  s_bfe_i64 off=4  width=63  junk=0: got 0xf89abcdef0123456 scc=1  wide=0xf89abcdef0123456 lit=0x89abcdef0123456 mod=0xf89abcdef0123456  -> wide+mod
  s_bfe_i64 off=4  width=64  junk=0: got 0xf89abcdef0123456 scc=1  wide=0xf89abcdef0123456 lit=0x89abcdef0123456 mod=0x0  -> wide
  s_bfe_i64 off=4  width=65  junk=0: got 0xf89abcdef0123456 scc=1  wide=0xf89abcdef0123456 lit=0x89abcdef0123456 mod=0x0  -> wide
  s_bfe_i64 off=4  width=127 junk=0: got 0xf89abcdef0123456 scc=1  wide=0xf89abcdef0123456 lit=0x89abcdef0123456 mod=0xf89abcdef0123456  -> wide+mod
  s_bfe_i64 off=40 width=31  junk=0: got 0xffffffffff89abcd scc=1  wide=0xffffffffff89abcd lit=0x89abcd mod=0xffffffffff89abcd  -> wide+mod
  s_bfe_i64 off=40 width=32  junk=0: got 0xffffffffff89abcd scc=1  wide=0xffffffffff89abcd lit=0x89abcd mod=0xffffffffff89abcd  -> wide+mod
  s_bfe_i64 off=40 width=33  junk=0: got 0xffffffffff89abcd scc=1  wide=0xffffffffff89abcd lit=0x89abcd mod=0xffffffffff89abcd  -> wide+mod
  s_bfe_i64 off=40 width=63  junk=0: got 0xffffffffff89abcd scc=1  wide=0xffffffffff89abcd lit=0x89abcd mod=0xffffffffff89abcd  -> wide+mod
  s_bfe_i64 off=40 width=64  junk=0: got 0xffffffffff89abcd scc=1  wide=0xffffffffff89abcd lit=0x89abcd mod=0x0  -> wide
  s_bfe_i64 off=40 width=65  junk=0: got 0xffffffffff89abcd scc=1  wide=0xffffffffff89abcd lit=0x89abcd mod=0xffffffffffffffff  -> wide
  s_bfe_i64 off=40 width=127 junk=0: got 0xffffffffff89abcd scc=1  wide=0xffffffffff89abcd lit=0x89abcd mod=0xffffffffff89abcd  -> wide+mod
  s_bfe_i64 off=63 width=31  junk=0: got 0xffffffffffffffff scc=1  wide=0xffffffffffffffff lit=0x1 mod=0xffffffffffffffff  -> wide+mod
  s_bfe_i64 off=63 width=32  junk=0: got 0xffffffffffffffff scc=1  wide=0xffffffffffffffff lit=0x1 mod=0xffffffffffffffff  -> wide+mod
  s_bfe_i64 off=63 width=33  junk=0: got 0xffffffffffffffff scc=1  wide=0xffffffffffffffff lit=0x1 mod=0xffffffffffffffff  -> wide+mod
  s_bfe_i64 off=63 width=63  junk=0: got 0xffffffffffffffff scc=1  wide=0xffffffffffffffff lit=0x1 mod=0xffffffffffffffff  -> wide+mod
  s_bfe_i64 off=63 width=64  junk=0: got 0xffffffffffffffff scc=1  wide=0xffffffffffffffff lit=0x1 mod=0x0  -> wide
  s_bfe_i64 off=63 width=65  junk=0: got 0xffffffffffffffff scc=1  wide=0xffffffffffffffff lit=0x1 mod=0xffffffffffffffff  -> wide+mod
  s_bfe_i64 off=63 width=127 junk=0: got 0xffffffffffffffff scc=1  wide=0xffffffffffffffff lit=0x1 mod=0xffffffffffffffff  -> wide+mod
  s_bfe_i64 off=4  width=72  junk=1: got 0xf89abcdef0123456 scc=1  wide=0xf89abcdef0123456 lit=0x89abcdef0123456 mod=0x56  -> wide
  totals over 152 cases: wide matches 152, lit matches 114, mod matches 100
== nan, IEEE mode 0: candidate = first NaN operand in source order, quieted; generated NaN = 0x7fc00000
  v_fma_f32 (a,b,c): 65265 NaN cases, 32590 differ from the candidate: (0x7f800003,0x7fc00001,0x7fc00001)->0x7f800003 (0xff800004,0x7fc00001,0x7fc00001)->0xff800004 (0x7f800003,0xffc00002,0x7fc00001)->0x7f800003 (0xff800004,0xffc00002,0x7fc00001)->0xff800004 (0x7f800003,0x7f800003,0x7fc00001)->0x7f800003 (0xff800004,0x7f800003,0x7fc00001)->0xff800004
  v_mul_f32 (a,b): 43824 NaN cases, 21973 differ from the candidate: (0x7f800003,0x7fc00001)->0x7f800003 (0xff800004,0x7fc00001)->0xff800004 (0x7f800003,0xffc00002)->0x7f800003 (0xff800004,0xffc00002)->0xff800004 (0x7f800003,0x7f800003)->0x7f800003 (0xff800004,0x7f800003)->0xff800004
  v_add_f32 (a,c): 43886 NaN cases, 21808 differ from the candidate: (0x7f800003,0x7fc00001)->0x7f800003 (0xff800004,0x7fc00001)->0xff800004 (0x7f800003,0x7fc00001)->0x7f800003 (0xff800004,0x7fc00001)->0xff800004 (0x7f800003,0x7fc00001)->0x7f800003 (0xff800004,0x7fc00001)->0xff800004
  v_fmac_f32 (a,b,D=c): 65265 NaN cases, 32590 differ from the candidate: (0x7f800003,0x7fc00001,0x7fc00001)->0x7f800003 (0xff800004,0x7fc00001,0x7fc00001)->0xff800004 (0x7f800003,0xffc00002,0x7fc00001)->0x7f800003 (0xff800004,0xffc00002,0x7fc00001)->0xff800004 (0x7f800003,0x7f800003,0x7fc00001)->0x7f800003 (0xff800004,0x7f800003,0x7fc00001)->0xff800004
  v_sub_f32 (a,c): 43886 NaN cases, 32795 differ from the candidate: (0x7f800003,0x7fc00001)->0x7f800003 (0xff800004,0x7fc00001)->0xff800004 (0x7f800000,0x7fc00001)->0xffc00001 (0xff800000,0x7fc00001)->0xffc00001 (0x00000000,0x7fc00001)->0xffc00001 (0x80000000,0x7fc00001)->0xffc00001
  v_min_f32(a,b) on the special values with at least one NaN:
    0x7fc00001 0x7fc00001 -> 0x7fc00001
    0xffc00002 0x7fc00001 -> 0xffc00002
    0x7f800003 0x7fc00001 -> 0x7f800003
    0xff800004 0x7fc00001 -> 0xff800004
    0x7f800000 0x7fc00001 -> 0x7f800000
    0xff800000 0x7fc00001 -> 0xff800000
    0x00000000 0x7fc00001 -> 0x00000000
    0x80000000 0x7fc00001 -> 0x80000000
    0x3f800000 0x7fc00001 -> 0x3f800000
    0x00000001 0x7fc00001 -> 0x00000001
    0x807fffff 0x7fc00001 -> 0x807fffff
    0x7fc00001 0xffc00002 -> 0x7fc00001
    0xffc00002 0xffc00002 -> 0xffc00002
    0x7f800003 0xffc00002 -> 0x7f800003
    0xff800004 0xffc00002 -> 0xff800004
    0x7f800000 0xffc00002 -> 0x7f800000
    0xff800000 0xffc00002 -> 0xff800000
    0x00000000 0xffc00002 -> 0x00000000
    0x80000000 0xffc00002 -> 0x80000000
    0x3f800000 0xffc00002 -> 0x3f800000
    0x00000001 0xffc00002 -> 0x00000001
    0x807fffff 0xffc00002 -> 0x807fffff
    0x7fc00001 0x7f800003 -> 0x7fc00001
    0xffc00002 0x7f800003 -> 0xffc00002
    0x7f800003 0x7f800003 -> 0x7f800003
    0xff800004 0x7f800003 -> 0xff800004
    0x7f800000 0x7f800003 -> 0x7f800000
    0xff800000 0x7f800003 -> 0xff800000
    0x00000000 0x7f800003 -> 0x00000000
    0x80000000 0x7f800003 -> 0x80000000
    0x3f800000 0x7f800003 -> 0x3f800000
    0x00000001 0x7f800003 -> 0x00000001
    0x807fffff 0x7f800003 -> 0x807fffff
    0x7fc00001 0xff800004 -> 0x7fc00001
    0xffc00002 0xff800004 -> 0xffc00002
    0x7f800003 0xff800004 -> 0x7f800003
    0xff800004 0xff800004 -> 0xff800004
    0x7f800000 0xff800004 -> 0x7f800000
    0xff800000 0xff800004 -> 0xff800000
    0x00000000 0xff800004 -> 0x00000000
    0x80000000 0xff800004 -> 0x80000000
    0x3f800000 0xff800004 -> 0x3f800000
    0x00000001 0xff800004 -> 0x00000001
    0x807fffff 0xff800004 -> 0x807fffff
    0x7fc00001 0x7f800000 -> 0x7f800000
    0xffc00002 0x7f800000 -> 0x7f800000
    0x7f800003 0x7f800000 -> 0x7f800000
    0xff800004 0x7f800000 -> 0x7f800000
    0x7fc00001 0xff800000 -> 0xff800000
    0xffc00002 0xff800000 -> 0xff800000
    0x7f800003 0xff800000 -> 0xff800000
    0xff800004 0xff800000 -> 0xff800000
    0x7fc00001 0x00000000 -> 0x00000000
    0xffc00002 0x00000000 -> 0x00000000
    0x7f800003 0x00000000 -> 0x00000000
    0xff800004 0x00000000 -> 0x00000000
    0x7fc00001 0x80000000 -> 0x80000000
    0xffc00002 0x80000000 -> 0x80000000
    0x7f800003 0x80000000 -> 0x80000000
    0xff800004 0x80000000 -> 0x80000000
    0x7fc00001 0x3f800000 -> 0x3f800000
    0xffc00002 0x3f800000 -> 0x3f800000
    0x7f800003 0x3f800000 -> 0x3f800000
    0xff800004 0x3f800000 -> 0x3f800000
    0x7fc00001 0x00000001 -> 0x00000001
    0xffc00002 0x00000001 -> 0x00000001
    0x7f800003 0x00000001 -> 0x00000001
    0xff800004 0x00000001 -> 0x00000001
    0x7fc00001 0x807fffff -> 0x807fffff
    0xffc00002 0x807fffff -> 0x807fffff
    0x7f800003 0x807fffff -> 0x807fffff
    0xff800004 0x807fffff -> 0x807fffff
  v_max_f32(a,b) on the special values with at least one NaN:
    0x7fc00001 0x7fc00001 -> 0x7fc00001
    0xffc00002 0x7fc00001 -> 0xffc00002
    0x7f800003 0x7fc00001 -> 0x7f800003
    0xff800004 0x7fc00001 -> 0xff800004
    0x7f800000 0x7fc00001 -> 0x7f800000
    0xff800000 0x7fc00001 -> 0xff800000
    0x00000000 0x7fc00001 -> 0x00000000
    0x80000000 0x7fc00001 -> 0x80000000
    0x3f800000 0x7fc00001 -> 0x3f800000
    0x00000001 0x7fc00001 -> 0x00000001
    0x807fffff 0x7fc00001 -> 0x807fffff
    0x7fc00001 0xffc00002 -> 0x7fc00001
    0xffc00002 0xffc00002 -> 0xffc00002
    0x7f800003 0xffc00002 -> 0x7f800003
    0xff800004 0xffc00002 -> 0xff800004
    0x7f800000 0xffc00002 -> 0x7f800000
    0xff800000 0xffc00002 -> 0xff800000
    0x00000000 0xffc00002 -> 0x00000000
    0x80000000 0xffc00002 -> 0x80000000
    0x3f800000 0xffc00002 -> 0x3f800000
    0x00000001 0xffc00002 -> 0x00000001
    0x807fffff 0xffc00002 -> 0x807fffff
    0x7fc00001 0x7f800003 -> 0x7fc00001
    0xffc00002 0x7f800003 -> 0xffc00002
    0x7f800003 0x7f800003 -> 0x7f800003
    0xff800004 0x7f800003 -> 0xff800004
    0x7f800000 0x7f800003 -> 0x7f800000
    0xff800000 0x7f800003 -> 0xff800000
    0x00000000 0x7f800003 -> 0x00000000
    0x80000000 0x7f800003 -> 0x80000000
    0x3f800000 0x7f800003 -> 0x3f800000
    0x00000001 0x7f800003 -> 0x00000001
    0x807fffff 0x7f800003 -> 0x807fffff
    0x7fc00001 0xff800004 -> 0x7fc00001
    0xffc00002 0xff800004 -> 0xffc00002
    0x7f800003 0xff800004 -> 0x7f800003
    0xff800004 0xff800004 -> 0xff800004
    0x7f800000 0xff800004 -> 0x7f800000
    0xff800000 0xff800004 -> 0xff800000
    0x00000000 0xff800004 -> 0x00000000
    0x80000000 0xff800004 -> 0x80000000
    0x3f800000 0xff800004 -> 0x3f800000
    0x00000001 0xff800004 -> 0x00000001
    0x807fffff 0xff800004 -> 0x807fffff
    0x7fc00001 0x7f800000 -> 0x7f800000
    0xffc00002 0x7f800000 -> 0x7f800000
    0x7f800003 0x7f800000 -> 0x7f800000
    0xff800004 0x7f800000 -> 0x7f800000
    0x7fc00001 0xff800000 -> 0xff800000
    0xffc00002 0xff800000 -> 0xff800000
    0x7f800003 0xff800000 -> 0xff800000
    0xff800004 0xff800000 -> 0xff800000
    0x7fc00001 0x00000000 -> 0x00000000
    0xffc00002 0x00000000 -> 0x00000000
    0x7f800003 0x00000000 -> 0x00000000
    0xff800004 0x00000000 -> 0x00000000
    0x7fc00001 0x80000000 -> 0x80000000
    0xffc00002 0x80000000 -> 0x80000000
    0x7f800003 0x80000000 -> 0x80000000
    0xff800004 0x80000000 -> 0x80000000
    0x7fc00001 0x3f800000 -> 0x3f800000
    0xffc00002 0x3f800000 -> 0x3f800000
    0x7f800003 0x3f800000 -> 0x3f800000
    0xff800004 0x3f800000 -> 0x3f800000
    0x7fc00001 0x00000001 -> 0x00000001
    0xffc00002 0x00000001 -> 0x00000001
    0x7f800003 0x00000001 -> 0x00000001
    0xff800004 0x00000001 -> 0x00000001
    0x7fc00001 0x807fffff -> 0x807fffff
    0xffc00002 0x807fffff -> 0x807fffff
    0x7f800003 0x807fffff -> 0x807fffff
    0xff800004 0x807fffff -> 0x807fffff
== nan, IEEE mode 1: candidate = first NaN operand in source order, quieted; generated NaN = 0x7fc00000
  v_fma_f32 (a,b,c): 65265 NaN cases, 104 differ from the candidate: (0x00000000,0x7f800000,0x7fc00001)->0xffc00000 (0x80000000,0x7f800000,0x7fc00001)->0xffc00000 (0x00000000,0xff800000,0x7fc00001)->0xffc00000 (0x80000000,0xff800000,0x7fc00001)->0xffc00000 (0x7f800000,0x00000000,0x7fc00001)->0xffc00000 (0xff800000,0x00000000,0x7fc00001)->0xffc00000
  v_mul_f32 (a,b): 43824 NaN cases, 88 differ from the candidate: (0x00000000,0x7f800000)->0xffc00000 (0x80000000,0x7f800000)->0xffc00000 (0x00000000,0xff800000)->0xffc00000 (0x80000000,0xff800000)->0xffc00000 (0x7f800000,0x00000000)->0xffc00000 (0xff800000,0x00000000)->0xffc00000
  v_add_f32 (a,c): 43886 NaN cases, 22 differ from the candidate: (0xff800000,0x7f800000)->0xffc00000 (0xff800000,0x7f800000)->0xffc00000 (0xff800000,0x7f800000)->0xffc00000 (0xff800000,0x7f800000)->0xffc00000 (0xff800000,0x7f800000)->0xffc00000 (0xff800000,0x7f800000)->0xffc00000
  v_fmac_f32 (a,b,D=c): 65265 NaN cases, 104 differ from the candidate: (0x00000000,0x7f800000,0x7fc00001)->0xffc00000 (0x80000000,0x7f800000,0x7fc00001)->0xffc00000 (0x00000000,0xff800000,0x7fc00001)->0xffc00000 (0x80000000,0xff800000,0x7fc00001)->0xffc00000 (0x7f800000,0x00000000,0x7fc00001)->0xffc00000 (0xff800000,0x00000000,0x7fc00001)->0xffc00000
  v_sub_f32 (a,c): 43886 NaN cases, 21774 differ from the candidate: (0x7f800000,0x7fc00001)->0xffc00001 (0xff800000,0x7fc00001)->0xffc00001 (0x00000000,0x7fc00001)->0xffc00001 (0x80000000,0x7fc00001)->0xffc00001 (0x3f800000,0x7fc00001)->0xffc00001 (0x00000001,0x7fc00001)->0xffc00001
  v_min_f32(a,b) on the special values with at least one NaN:
    0x7fc00001 0x7fc00001 -> 0x7fc00001
    0xffc00002 0x7fc00001 -> 0xffc00002
    0x7f800003 0x7fc00001 -> 0x7fc00003
    0xff800004 0x7fc00001 -> 0xffc00004
    0x7f800000 0x7fc00001 -> 0x7f800000
    0xff800000 0x7fc00001 -> 0xff800000
    0x00000000 0x7fc00001 -> 0x00000000
    0x80000000 0x7fc00001 -> 0x80000000
    0x3f800000 0x7fc00001 -> 0x3f800000
    0x00000001 0x7fc00001 -> 0x00000001
    0x807fffff 0x7fc00001 -> 0x807fffff
    0x7fc00001 0xffc00002 -> 0x7fc00001
    0xffc00002 0xffc00002 -> 0xffc00002
    0x7f800003 0xffc00002 -> 0x7fc00003
    0xff800004 0xffc00002 -> 0xffc00004
    0x7f800000 0xffc00002 -> 0x7f800000
    0xff800000 0xffc00002 -> 0xff800000
    0x00000000 0xffc00002 -> 0x00000000
    0x80000000 0xffc00002 -> 0x80000000
    0x3f800000 0xffc00002 -> 0x3f800000
    0x00000001 0xffc00002 -> 0x00000001
    0x807fffff 0xffc00002 -> 0x807fffff
    0x7fc00001 0x7f800003 -> 0x7fc00003
    0xffc00002 0x7f800003 -> 0x7fc00003
    0x7f800003 0x7f800003 -> 0x7fc00003
    0xff800004 0x7f800003 -> 0xffc00004
    0x7f800000 0x7f800003 -> 0x7fc00003
    0xff800000 0x7f800003 -> 0x7fc00003
    0x00000000 0x7f800003 -> 0x7fc00003
    0x80000000 0x7f800003 -> 0x7fc00003
    0x3f800000 0x7f800003 -> 0x7fc00003
    0x00000001 0x7f800003 -> 0x7fc00003
    0x807fffff 0x7f800003 -> 0x7fc00003
    0x7fc00001 0xff800004 -> 0xffc00004
    0xffc00002 0xff800004 -> 0xffc00004
    0x7f800003 0xff800004 -> 0x7fc00003
    0xff800004 0xff800004 -> 0xffc00004
    0x7f800000 0xff800004 -> 0xffc00004
    0xff800000 0xff800004 -> 0xffc00004
    0x00000000 0xff800004 -> 0xffc00004
    0x80000000 0xff800004 -> 0xffc00004
    0x3f800000 0xff800004 -> 0xffc00004
    0x00000001 0xff800004 -> 0xffc00004
    0x807fffff 0xff800004 -> 0xffc00004
    0x7fc00001 0x7f800000 -> 0x7f800000
    0xffc00002 0x7f800000 -> 0x7f800000
    0x7f800003 0x7f800000 -> 0x7fc00003
    0xff800004 0x7f800000 -> 0xffc00004
    0x7fc00001 0xff800000 -> 0xff800000
    0xffc00002 0xff800000 -> 0xff800000
    0x7f800003 0xff800000 -> 0x7fc00003
    0xff800004 0xff800000 -> 0xffc00004
    0x7fc00001 0x00000000 -> 0x00000000
    0xffc00002 0x00000000 -> 0x00000000
    0x7f800003 0x00000000 -> 0x7fc00003
    0xff800004 0x00000000 -> 0xffc00004
    0x7fc00001 0x80000000 -> 0x80000000
    0xffc00002 0x80000000 -> 0x80000000
    0x7f800003 0x80000000 -> 0x7fc00003
    0xff800004 0x80000000 -> 0xffc00004
    0x7fc00001 0x3f800000 -> 0x3f800000
    0xffc00002 0x3f800000 -> 0x3f800000
    0x7f800003 0x3f800000 -> 0x7fc00003
    0xff800004 0x3f800000 -> 0xffc00004
    0x7fc00001 0x00000001 -> 0x00000001
    0xffc00002 0x00000001 -> 0x00000001
    0x7f800003 0x00000001 -> 0x7fc00003
    0xff800004 0x00000001 -> 0xffc00004
    0x7fc00001 0x807fffff -> 0x807fffff
    0xffc00002 0x807fffff -> 0x807fffff
    0x7f800003 0x807fffff -> 0x7fc00003
    0xff800004 0x807fffff -> 0xffc00004
  v_max_f32(a,b) on the special values with at least one NaN:
    0x7fc00001 0x7fc00001 -> 0x7fc00001
    0xffc00002 0x7fc00001 -> 0xffc00002
    0x7f800003 0x7fc00001 -> 0x7fc00003
    0xff800004 0x7fc00001 -> 0xffc00004
    0x7f800000 0x7fc00001 -> 0x7f800000
    0xff800000 0x7fc00001 -> 0xff800000
    0x00000000 0x7fc00001 -> 0x00000000
    0x80000000 0x7fc00001 -> 0x80000000
    0x3f800000 0x7fc00001 -> 0x3f800000
    0x00000001 0x7fc00001 -> 0x00000001
    0x807fffff 0x7fc00001 -> 0x807fffff
    0x7fc00001 0xffc00002 -> 0x7fc00001
    0xffc00002 0xffc00002 -> 0xffc00002
    0x7f800003 0xffc00002 -> 0x7fc00003
    0xff800004 0xffc00002 -> 0xffc00004
    0x7f800000 0xffc00002 -> 0x7f800000
    0xff800000 0xffc00002 -> 0xff800000
    0x00000000 0xffc00002 -> 0x00000000
    0x80000000 0xffc00002 -> 0x80000000
    0x3f800000 0xffc00002 -> 0x3f800000
    0x00000001 0xffc00002 -> 0x00000001
    0x807fffff 0xffc00002 -> 0x807fffff
    0x7fc00001 0x7f800003 -> 0x7fc00003
    0xffc00002 0x7f800003 -> 0x7fc00003
    0x7f800003 0x7f800003 -> 0x7fc00003
    0xff800004 0x7f800003 -> 0xffc00004
    0x7f800000 0x7f800003 -> 0x7fc00003
    0xff800000 0x7f800003 -> 0x7fc00003
    0x00000000 0x7f800003 -> 0x7fc00003
    0x80000000 0x7f800003 -> 0x7fc00003
    0x3f800000 0x7f800003 -> 0x7fc00003
    0x00000001 0x7f800003 -> 0x7fc00003
    0x807fffff 0x7f800003 -> 0x7fc00003
    0x7fc00001 0xff800004 -> 0xffc00004
    0xffc00002 0xff800004 -> 0xffc00004
    0x7f800003 0xff800004 -> 0x7fc00003
    0xff800004 0xff800004 -> 0xffc00004
    0x7f800000 0xff800004 -> 0xffc00004
    0xff800000 0xff800004 -> 0xffc00004
    0x00000000 0xff800004 -> 0xffc00004
    0x80000000 0xff800004 -> 0xffc00004
    0x3f800000 0xff800004 -> 0xffc00004
    0x00000001 0xff800004 -> 0xffc00004
    0x807fffff 0xff800004 -> 0xffc00004
    0x7fc00001 0x7f800000 -> 0x7f800000
    0xffc00002 0x7f800000 -> 0x7f800000
    0x7f800003 0x7f800000 -> 0x7fc00003
    0xff800004 0x7f800000 -> 0xffc00004
    0x7fc00001 0xff800000 -> 0xff800000
    0xffc00002 0xff800000 -> 0xff800000
    0x7f800003 0xff800000 -> 0x7fc00003
    0xff800004 0xff800000 -> 0xffc00004
    0x7fc00001 0x00000000 -> 0x00000000
    0xffc00002 0x00000000 -> 0x00000000
    0x7f800003 0x00000000 -> 0x7fc00003
    0xff800004 0x00000000 -> 0xffc00004
    0x7fc00001 0x80000000 -> 0x80000000
    0xffc00002 0x80000000 -> 0x80000000
    0x7f800003 0x80000000 -> 0x7fc00003
    0xff800004 0x80000000 -> 0xffc00004
    0x7fc00001 0x3f800000 -> 0x3f800000
    0xffc00002 0x3f800000 -> 0x3f800000
    0x7f800003 0x3f800000 -> 0x7fc00003
    0xff800004 0x3f800000 -> 0xffc00004
    0x7fc00001 0x00000001 -> 0x00000001
    0xffc00002 0x00000001 -> 0x00000001
    0x7f800003 0x00000001 -> 0x7fc00003
    0xff800004 0x00000001 -> 0xffc00004
    0x7fc00001 0x807fffff -> 0x807fffff
    0xffc00002 0x807fffff -> 0x807fffff
    0x7f800003 0x807fffff -> 0x7fc00003
    0xff800004 0x807fffff -> 0xffc00004
== normalized conversions: mismatches per rounding rule (nearest, halfup = floor(x + 0.5), trunc)
  v_cvt_pknorm_i16_f32: nearest 0, halfup 51, trunc 41597  best=nearest
  v_cvt_pknorm_u16_f32: nearest 0, halfup 0, trunc 23544  best=nearest
  v_cvt_pknorm_i16_f16: nearest 0, halfup 2, trunc 31546  best=nearest
  v_cvt_pknorm_u16_f16: nearest 0, halfup 0, trunc 18067  best=nearest
  v_cvt_norm_i16_f16: nearest 0, halfup 1, trunc 18432  best=nearest
    upper half of the destination: ['0x5a5a'] (preset 0x5a5a)
  v_cvt_norm_u16_f16: nearest 0, halfup 0, trunc 9728  best=nearest
    upper half of the destination: ['0x5a5a'] (preset 0x5a5a)
nanfit.py (reads nan.in / nan_ieee{0,1}.out from the gen dir)
import struct, sys, collections
D = sys.argv[1]
N = 65536
ins = [struct.unpack_from('<4I', open(f"{D}/nan.in","rb").read(), 16*i) for i in range(N)]
isnan = lambda b: b & 0x7fffffff > 0x7f800000
isinf = lambda b: b & 0x7fffffff == 0x7f800000
iszero = lambda b: b & 0x7fffffff == 0
issnan = lambda b: isnan(b) and not b & 0x400000
f = lambda b: struct.unpack('<f', struct.pack('<I', b))[0]
def fit(m, DEF, prod_invalid_first, sub_neg):
    Q = (lambda x: x | 0x400000) if m else (lambda x: x)
    def arith(ops, kind):
        # kind: 'fma','mul','add','sub'
        if kind == 'sub' and sub_neg:
            ops = [ops[0], ops[1] ^ 0x80000000]
        if kind == 'fma':
            a, b, c = ops
            inv = (isinf(a) and iszero(b)) or (iszero(a) and isinf(b))
            if not isnan(a) and not isnan(b) and inv and prod_invalid_first:
                return DEF
            for x in ops:
                if isnan(x): return Q(x)
            if inv: return DEF
            p = f(a) * f(b)
            if p == p and abs(p) == float('inf') and isinf(c) and (p > 0) != (not c >> 31):
                return DEF
            return None
        for x in ops:
            if isnan(x): return Q(x)
        a, b = ops
        if kind == 'mul' and ((isinf(a) and iszero(b)) or (iszero(a) and isinf(b))): return DEF
        if kind in ('add', 'sub') and isinf(a) and isinf(b) and (a >> 31) != (b >> 31): return DEF
        return None
    def minmax(a, b):
        if m == 0:
            if isnan(a) and isnan(b): return a
            if isnan(a): return b
            if isnan(b): return a
            return None
        # IEEE mode: sNaN wins (quieted), else qNaN ignored
        if issnan(a): return Q(a)
        if issnan(b): return Q(b)
        if isnan(a) and isnan(b): return a
        if isnan(a): return b
        if isnan(b): return a
        return None
    raw = open(f"{D}/nan_ieee{m}.out","rb").read()
    cols = (("v_fma_f32", 0, (0,1,2), 'fma'), ("v_mul_f32", 1, (0,1), 'mul'), ("v_add_f32", 2, (0,2), 'add'),
            ("v_fmac_f32", 5, (0,1,2), 'fma'), ("v_sub_f32", 6, (0,2), 'sub'), ("v_min_f32", 3, (0,1), 'min'), ("v_max_f32", 4, (0,1), 'max'))
    res = {}
    for name, col, sel, kind in cols:
        n = bad = 0; ex = []
        for i in range(N):
            t = ins[i]; o = struct.unpack_from('<I', raw, 64*i + 4*col)[0]
            ops = [t[j] for j in sel]
            want = minmax(*ops) if kind in ('min','max') else arith(ops, kind)
            if want is None:
                if isnan(o): bad += 1; ex.append((ops, o, 'unexpected NaN'))
                continue
            n += 1
            if o != want:
                bad += 1
                if len(ex) < 4: ex.append(([hex(x) for x in ops], hex(o), hex(want)))
        res[name] = (n, bad, ex)
    return res
for m in (0, 1):
    for DEF in (0xffc00000, 0x7fc00000):
        for pif in (True, False):
            r = fit(m, DEF, pif, True)
            tot = sum(v[1] for v in r.values())
            print(f"mode {m} DEF {DEF:#x} prod_invalid_first {pif}: total mismatches {tot}")
            if tot < 200:
                for k, (n, bad, ex) in r.items():
                    print(f"   {k}: {n} NaN results checked, {bad} mismatches {ex[:3]}")
**@⁠SchmashinPrunes** on GitHub · 2026-11-21 23:54 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/41#issuecomment-7071178837) · edited 2026-11-22 00:01 UTC Ran `valu_probe.py` (efffbc0, unmodified) on the gfx1036 iGPU of a Ryzen 5 9600X: Mint, kernel 7.0.0-42, ROCm/HIP 5.7.1, clang/ld.lld 18.1.3. All 33 kernels ran, and no kernel had outputs that differ between threads. ### Results | Probe | RDNA2 answer | |---|---| | `fma16` | **Fused.** VOP2 0x36 / 0x37 / 0x38 match hardware `v_fma_f16` on every discriminating input and never match `v_mul_f16` + `v_add_f16`: 254,891 inputs over the three K values, fused on all, unfused on 0, neither on 0. Hardware `v_fma_f16` matches the exact single-rounding model, 0 mismatches. The upper half of D is preserved (0x36 keeps D's old upper half, 0x37 / 0x38 keep the preset). | | `sbfe` | **`wide`: 152 / 152** (lit 114, mod 100). The 7-bit width is used, and a signed field that reaches the top bit sign-fills. Junk in the unused S1 bits is ignored, and offset bit 5 (32-bit) or bit 6 (64-bit) is ignored. SCC = result != 0 in every case. This matches main since 8491769. | | `norm` | **Round to nearest**, 0 mismatches for all six ops (`v_cvt_pknorm_{i,u}16_{f32,f16}`, `v_cvt_norm_{i,u}16_f16`), with NaN → 0. `halfup` fails on i16 (51 / 2 / 1), so it's not floor(x+0.5). The `v_cvt_norm_*` upper half is preserved. | | `nan` | The single "first NaN, quieted" candidate doesn't fit; see below. | ### NaN rules (fitted, 0 mismatches) The `show` candidate is off in three ways: sNaN isn't quieted in IEEE mode 0, `v_sub` negates src1, and the default NaN is `0xffc00000`. I fitted these rules against the raw outputs. They reproduce **every** NaN result (fma 65265, mul 43824, add 43886, fmac 65265, sub 43886, min 43736, max 43736 cases, in each IEEE mode). No input outside the rules produced a NaN. **Arithmetic (fma / fmac / mul / add / sub), both IEEE modes:** 1. Operand order is (a, b, c) for fma/fmac and (src0, src1) otherwise. **`v_sub_f32` negates src1 first**, so a NaN src1 comes out with its sign flipped: `(0, 0x7fc00001)` → `0xffc00001`. 2. fma/fmac only: if neither a nor b is NaN and a·b is invalid (0 · ±inf), the result is the default NaN **even if c is NaN**: `(0, inf, 0x7fc00001)` → `0xffc00000`. 3. Otherwise the result is the first NaN operand. **IEEE mode 0: returned unchanged, sNaN included** (`(0x7f800003, 0x7fc00001)` → `0x7f800003`). IEEE mode 1: quieted (`| 0x400000`). 4. Invalid operations with no NaN input (0 · inf, inf − inf, and the fma sum) return **`0xffc00000`** (negative quiet NaN) in both modes. **`v_min_f32` / `v_max_f32`:** - IEEE mode 0: a NaN operand is ignored when the other operand isn't NaN. With two NaNs the result is src0, unchanged (an sNaN stays signalling). - IEEE mode 1 (minNum-style): an sNaN operand wins and is quieted (src0 checked first). Otherwise a qNaN is ignored when the other operand isn't NaN, and with two qNaNs the result is src0. Since this seems to be the only RDNA2 hardware the repo has at the moment, I'm happy to run probes or exec tests from other PRs on it too. Just mention me on the PR with what you'd like run. The full `show` output and the fitting script are below. <details><summary>valu_probe.py show (gfx1036)</summary> ``` == fma16: VOP2 0x36 / 0x37 / 0x38 against hardware v_fma_f16 (fused) and v_mul_f16 + v_add_f16 (unfused) K=0x3c01: hardware v_fma_f16 vs exact single-rounding model: 0 mismatches (zero-sign cases ignored) 0x36 D=S0*S1+D: 28753 discriminating inputs -> fused 28753, unfused 0, neither 0; disagreements where both references agree: 0; upper half of D: ['0x5678'] 0x37 D=S0*K+S1: 28288 discriminating inputs -> fused 28288, unfused 0, neither 0; disagreements where both references agree: 0; upper half of D: ['0x5a5a'] 0x38 D=S0*S1+K: 28361 discriminating inputs -> fused 28361, unfused 0, neither 0; disagreements where both references agree: 0; upper half of D: ['0x5a5a'] K=0x3555: hardware v_fma_f16 vs exact single-rounding model: 0 mismatches (zero-sign cases ignored) 0x36 D=S0*S1+D: 27834 discriminating inputs -> fused 27834, unfused 0, neither 0; disagreements where both references agree: 0; upper half of D: ['0x5678'] 0x37 D=S0*K+S1: 25820 discriminating inputs -> fused 25820, unfused 0, neither 0; disagreements where both references agree: 0; upper half of D: ['0x5a5a'] 0x38 D=S0*S1+K: 31763 discriminating inputs -> fused 31763, unfused 0, neither 0; disagreements where both references agree: 0; upper half of D: ['0x5a5a'] K=0xc248: hardware v_fma_f16 vs exact single-rounding model: 0 mismatches (zero-sign cases ignored) 0x36 D=S0*S1+D: 28126 discriminating inputs -> fused 28126, unfused 0, neither 0; disagreements where both references agree: 0; upper half of D: ['0x5678'] 0x37 D=S0*K+S1: 29771 discriminating inputs -> fused 29771, unfused 0, neither 0; disagreements where both references agree: 0; upper half of D: ['0x5a5a'] 0x38 D=S0*S1+K: 26175 discriminating inputs -> fused 26175, unfused 0, neither 0; disagreements where both references agree: 0; upper half of D: ['0x5a5a'] == s_bfe: 'wide' = 7-bit width, signed fields past the top bit sign-fill; 'lit' = 7-bit width, literal ISA formula (they zero-fill); 'mod' = width modulo the operand size s_bfe_u32 off=0 width=32 junk=0: got 0x89abcdef scc=1 wide=0x89abcdef lit=0x89abcdef mod=0x0 -> wide+lit s_bfe_u32 off=0 width=33 junk=0: got 0x89abcdef scc=1 wide=0x89abcdef lit=0x89abcdef mod=0x1 -> wide+lit s_bfe_u32 off=0 width=63 junk=0: got 0x89abcdef scc=1 wide=0x89abcdef lit=0x89abcdef mod=0x9abcdef -> wide+lit s_bfe_u32 off=0 width=64 junk=0: got 0x89abcdef scc=1 wide=0x89abcdef lit=0x89abcdef mod=0x0 -> wide+lit s_bfe_u32 off=0 width=65 junk=0: got 0x89abcdef scc=1 wide=0x89abcdef lit=0x89abcdef mod=0x1 -> wide+lit s_bfe_u32 off=0 width=96 junk=0: got 0x89abcdef scc=1 wide=0x89abcdef lit=0x89abcdef mod=0x0 -> wide+lit s_bfe_u32 off=0 width=127 junk=0: got 0x89abcdef scc=1 wide=0x89abcdef lit=0x89abcdef mod=0x9abcdef -> wide+lit s_bfe_u32 off=4 width=32 junk=0: got 0x89abcde scc=1 wide=0x89abcde lit=0x89abcde mod=0x0 -> wide+lit s_bfe_u32 off=4 width=33 junk=0: got 0x89abcde scc=1 wide=0x89abcde lit=0x89abcde mod=0x0 -> wide+lit s_bfe_u32 off=4 width=64 junk=0: got 0x89abcde scc=1 wide=0x89abcde lit=0x89abcde mod=0x0 -> wide+lit s_bfe_u32 off=4 width=65 junk=0: got 0x89abcde scc=1 wide=0x89abcde lit=0x89abcde mod=0x0 -> wide+lit s_bfe_u32 off=4 width=96 junk=0: got 0x89abcde scc=1 wide=0x89abcde lit=0x89abcde mod=0x0 -> wide+lit s_bfe_u32 off=31 width=32 junk=0: got 0x1 scc=1 wide=0x1 lit=0x1 mod=0x0 -> wide+lit s_bfe_u32 off=31 width=64 junk=0: got 0x1 scc=1 wide=0x1 lit=0x1 mod=0x0 -> wide+lit s_bfe_u32 off=31 width=96 junk=0: got 0x1 scc=1 wide=0x1 lit=0x1 mod=0x0 -> wide+lit s_bfe_u32 off=4 width=40 junk=1: got 0x89abcde scc=1 wide=0x89abcde lit=0x89abcde mod=0xde -> wide+lit s_bfe_u32 off=36 width=40 junk=0: got 0x89abcde scc=1 wide=0x89abcde lit=0x89abcde mod=0xde -> wide+lit s_bfe_u64 off=0 width=64 junk=0: got 0x89abcdef01234567 scc=1 wide=0x89abcdef01234567 lit=0x89abcdef01234567 mod=0x0 -> wide+lit s_bfe_u64 off=0 width=65 junk=0: got 0x89abcdef01234567 scc=1 wide=0x89abcdef01234567 lit=0x89abcdef01234567 mod=0x1 -> wide+lit s_bfe_u64 off=0 width=127 junk=0: got 0x89abcdef01234567 scc=1 wide=0x89abcdef01234567 lit=0x89abcdef01234567 mod=0x9abcdef01234567 -> wide+lit s_bfe_u64 off=4 width=64 junk=0: got 0x89abcdef0123456 scc=1 wide=0x89abcdef0123456 lit=0x89abcdef0123456 mod=0x0 -> wide+lit s_bfe_u64 off=4 width=65 junk=0: got 0x89abcdef0123456 scc=1 wide=0x89abcdef0123456 lit=0x89abcdef0123456 mod=0x0 -> wide+lit s_bfe_u64 off=40 width=64 junk=0: got 0x89abcd scc=1 wide=0x89abcd lit=0x89abcd mod=0x0 -> wide+lit s_bfe_u64 off=40 width=65 junk=0: got 0x89abcd scc=1 wide=0x89abcd lit=0x89abcd mod=0x1 -> wide+lit s_bfe_u64 off=63 width=64 junk=0: got 0x1 scc=1 wide=0x1 lit=0x1 mod=0x0 -> wide+lit s_bfe_u64 off=4 width=72 junk=1: got 0x89abcdef0123456 scc=1 wide=0x89abcdef0123456 lit=0x89abcdef0123456 mod=0x56 -> wide+lit s_bfe_i32 off=0 width=32 junk=0: got 0x89abcdef scc=1 wide=0x89abcdef lit=0x89abcdef mod=0x0 -> wide+lit s_bfe_i32 off=0 width=33 junk=0: got 0x89abcdef scc=1 wide=0x89abcdef lit=0x89abcdef mod=0xffffffff -> wide+lit s_bfe_i32 off=0 width=63 junk=0: got 0x89abcdef scc=1 wide=0x89abcdef lit=0x89abcdef mod=0x9abcdef -> wide+lit s_bfe_i32 off=0 width=64 junk=0: got 0x89abcdef scc=1 wide=0x89abcdef lit=0x89abcdef mod=0x0 -> wide+lit s_bfe_i32 off=0 width=65 junk=0: got 0x89abcdef scc=1 wide=0x89abcdef lit=0x89abcdef mod=0xffffffff -> wide+lit s_bfe_i32 off=0 width=96 junk=0: got 0x89abcdef scc=1 wide=0x89abcdef lit=0x89abcdef mod=0x0 -> wide+lit s_bfe_i32 off=0 width=127 junk=0: got 0x89abcdef scc=1 wide=0x89abcdef lit=0x89abcdef mod=0x9abcdef -> wide+lit s_bfe_i32 off=4 width=31 junk=0: got 0xf89abcde scc=1 wide=0xf89abcde lit=0x89abcde mod=0xf89abcde -> wide+mod s_bfe_i32 off=4 width=32 junk=0: got 0xf89abcde scc=1 wide=0xf89abcde lit=0x89abcde mod=0x0 -> wide s_bfe_i32 off=4 width=33 junk=0: got 0xf89abcde scc=1 wide=0xf89abcde lit=0x89abcde mod=0x0 -> wide s_bfe_i32 off=4 width=63 junk=0: got 0xf89abcde scc=1 wide=0xf89abcde lit=0x89abcde mod=0xf89abcde -> wide+mod s_bfe_i32 off=4 width=64 junk=0: got 0xf89abcde scc=1 wide=0xf89abcde lit=0x89abcde mod=0x0 -> wide s_bfe_i32 off=4 width=65 junk=0: got 0xf89abcde scc=1 wide=0xf89abcde lit=0x89abcde mod=0x0 -> wide s_bfe_i32 off=4 width=96 junk=0: got 0xf89abcde scc=1 wide=0xf89abcde lit=0x89abcde mod=0x0 -> wide s_bfe_i32 off=4 width=127 junk=0: got 0xf89abcde scc=1 wide=0xf89abcde lit=0x89abcde mod=0xf89abcde -> wide+mod s_bfe_i32 off=31 width=28 junk=0: got 0xffffffff scc=1 wide=0xffffffff lit=0x1 mod=0xffffffff -> wide+mod s_bfe_i32 off=31 width=31 junk=0: got 0xffffffff scc=1 wide=0xffffffff lit=0x1 mod=0xffffffff -> wide+mod s_bfe_i32 off=31 width=32 junk=0: got 0xffffffff scc=1 wide=0xffffffff lit=0x1 mod=0x0 -> wide s_bfe_i32 off=31 width=33 junk=0: got 0xffffffff scc=1 wide=0xffffffff lit=0x1 mod=0xffffffff -> wide+mod s_bfe_i32 off=31 width=63 junk=0: got 0xffffffff scc=1 wide=0xffffffff lit=0x1 mod=0xffffffff -> wide+mod s_bfe_i32 off=31 width=64 junk=0: got 0xffffffff scc=1 wide=0xffffffff lit=0x1 mod=0x0 -> wide s_bfe_i32 off=31 width=65 junk=0: got 0xffffffff scc=1 wide=0xffffffff lit=0x1 mod=0xffffffff -> wide+mod s_bfe_i32 off=31 width=96 junk=0: got 0xffffffff scc=1 wide=0xffffffff lit=0x1 mod=0x0 -> wide s_bfe_i32 off=31 width=127 junk=0: got 0xffffffff scc=1 wide=0xffffffff lit=0x1 mod=0xffffffff -> wide+mod s_bfe_i32 off=4 width=40 junk=1: got 0xf89abcde scc=1 wide=0xf89abcde lit=0x89abcde mod=0xffffffde -> wide s_bfe_i32 off=36 width=40 junk=0: got 0xf89abcde scc=1 wide=0xf89abcde lit=0x89abcde mod=0xffffffde -> wide s_bfe_i64 off=0 width=64 junk=0: got 0x89abcdef01234567 scc=1 wide=0x89abcdef01234567 lit=0x89abcdef01234567 mod=0x0 -> wide+lit s_bfe_i64 off=0 width=65 junk=0: got 0x89abcdef01234567 scc=1 wide=0x89abcdef01234567 lit=0x89abcdef01234567 mod=0xffffffffffffffff -> wide+lit s_bfe_i64 off=0 width=127 junk=0: got 0x89abcdef01234567 scc=1 wide=0x89abcdef01234567 lit=0x89abcdef01234567 mod=0x9abcdef01234567 -> wide+lit s_bfe_i64 off=4 width=63 junk=0: got 0xf89abcdef0123456 scc=1 wide=0xf89abcdef0123456 lit=0x89abcdef0123456 mod=0xf89abcdef0123456 -> wide+mod s_bfe_i64 off=4 width=64 junk=0: got 0xf89abcdef0123456 scc=1 wide=0xf89abcdef0123456 lit=0x89abcdef0123456 mod=0x0 -> wide s_bfe_i64 off=4 width=65 junk=0: got 0xf89abcdef0123456 scc=1 wide=0xf89abcdef0123456 lit=0x89abcdef0123456 mod=0x0 -> wide s_bfe_i64 off=4 width=127 junk=0: got 0xf89abcdef0123456 scc=1 wide=0xf89abcdef0123456 lit=0x89abcdef0123456 mod=0xf89abcdef0123456 -> wide+mod s_bfe_i64 off=40 width=31 junk=0: got 0xffffffffff89abcd scc=1 wide=0xffffffffff89abcd lit=0x89abcd mod=0xffffffffff89abcd -> wide+mod s_bfe_i64 off=40 width=32 junk=0: got 0xffffffffff89abcd scc=1 wide=0xffffffffff89abcd lit=0x89abcd mod=0xffffffffff89abcd -> wide+mod s_bfe_i64 off=40 width=33 junk=0: got 0xffffffffff89abcd scc=1 wide=0xffffffffff89abcd lit=0x89abcd mod=0xffffffffff89abcd -> wide+mod s_bfe_i64 off=40 width=63 junk=0: got 0xffffffffff89abcd scc=1 wide=0xffffffffff89abcd lit=0x89abcd mod=0xffffffffff89abcd -> wide+mod s_bfe_i64 off=40 width=64 junk=0: got 0xffffffffff89abcd scc=1 wide=0xffffffffff89abcd lit=0x89abcd mod=0x0 -> wide s_bfe_i64 off=40 width=65 junk=0: got 0xffffffffff89abcd scc=1 wide=0xffffffffff89abcd lit=0x89abcd mod=0xffffffffffffffff -> wide s_bfe_i64 off=40 width=127 junk=0: got 0xffffffffff89abcd scc=1 wide=0xffffffffff89abcd lit=0x89abcd mod=0xffffffffff89abcd -> wide+mod s_bfe_i64 off=63 width=31 junk=0: got 0xffffffffffffffff scc=1 wide=0xffffffffffffffff lit=0x1 mod=0xffffffffffffffff -> wide+mod s_bfe_i64 off=63 width=32 junk=0: got 0xffffffffffffffff scc=1 wide=0xffffffffffffffff lit=0x1 mod=0xffffffffffffffff -> wide+mod s_bfe_i64 off=63 width=33 junk=0: got 0xffffffffffffffff scc=1 wide=0xffffffffffffffff lit=0x1 mod=0xffffffffffffffff -> wide+mod s_bfe_i64 off=63 width=63 junk=0: got 0xffffffffffffffff scc=1 wide=0xffffffffffffffff lit=0x1 mod=0xffffffffffffffff -> wide+mod s_bfe_i64 off=63 width=64 junk=0: got 0xffffffffffffffff scc=1 wide=0xffffffffffffffff lit=0x1 mod=0x0 -> wide s_bfe_i64 off=63 width=65 junk=0: got 0xffffffffffffffff scc=1 wide=0xffffffffffffffff lit=0x1 mod=0xffffffffffffffff -> wide+mod s_bfe_i64 off=63 width=127 junk=0: got 0xffffffffffffffff scc=1 wide=0xffffffffffffffff lit=0x1 mod=0xffffffffffffffff -> wide+mod s_bfe_i64 off=4 width=72 junk=1: got 0xf89abcdef0123456 scc=1 wide=0xf89abcdef0123456 lit=0x89abcdef0123456 mod=0x56 -> wide totals over 152 cases: wide matches 152, lit matches 114, mod matches 100 == nan, IEEE mode 0: candidate = first NaN operand in source order, quieted; generated NaN = 0x7fc00000 v_fma_f32 (a,b,c): 65265 NaN cases, 32590 differ from the candidate: (0x7f800003,0x7fc00001,0x7fc00001)->0x7f800003 (0xff800004,0x7fc00001,0x7fc00001)->0xff800004 (0x7f800003,0xffc00002,0x7fc00001)->0x7f800003 (0xff800004,0xffc00002,0x7fc00001)->0xff800004 (0x7f800003,0x7f800003,0x7fc00001)->0x7f800003 (0xff800004,0x7f800003,0x7fc00001)->0xff800004 v_mul_f32 (a,b): 43824 NaN cases, 21973 differ from the candidate: (0x7f800003,0x7fc00001)->0x7f800003 (0xff800004,0x7fc00001)->0xff800004 (0x7f800003,0xffc00002)->0x7f800003 (0xff800004,0xffc00002)->0xff800004 (0x7f800003,0x7f800003)->0x7f800003 (0xff800004,0x7f800003)->0xff800004 v_add_f32 (a,c): 43886 NaN cases, 21808 differ from the candidate: (0x7f800003,0x7fc00001)->0x7f800003 (0xff800004,0x7fc00001)->0xff800004 (0x7f800003,0x7fc00001)->0x7f800003 (0xff800004,0x7fc00001)->0xff800004 (0x7f800003,0x7fc00001)->0x7f800003 (0xff800004,0x7fc00001)->0xff800004 v_fmac_f32 (a,b,D=c): 65265 NaN cases, 32590 differ from the candidate: (0x7f800003,0x7fc00001,0x7fc00001)->0x7f800003 (0xff800004,0x7fc00001,0x7fc00001)->0xff800004 (0x7f800003,0xffc00002,0x7fc00001)->0x7f800003 (0xff800004,0xffc00002,0x7fc00001)->0xff800004 (0x7f800003,0x7f800003,0x7fc00001)->0x7f800003 (0xff800004,0x7f800003,0x7fc00001)->0xff800004 v_sub_f32 (a,c): 43886 NaN cases, 32795 differ from the candidate: (0x7f800003,0x7fc00001)->0x7f800003 (0xff800004,0x7fc00001)->0xff800004 (0x7f800000,0x7fc00001)->0xffc00001 (0xff800000,0x7fc00001)->0xffc00001 (0x00000000,0x7fc00001)->0xffc00001 (0x80000000,0x7fc00001)->0xffc00001 v_min_f32(a,b) on the special values with at least one NaN: 0x7fc00001 0x7fc00001 -> 0x7fc00001 0xffc00002 0x7fc00001 -> 0xffc00002 0x7f800003 0x7fc00001 -> 0x7f800003 0xff800004 0x7fc00001 -> 0xff800004 0x7f800000 0x7fc00001 -> 0x7f800000 0xff800000 0x7fc00001 -> 0xff800000 0x00000000 0x7fc00001 -> 0x00000000 0x80000000 0x7fc00001 -> 0x80000000 0x3f800000 0x7fc00001 -> 0x3f800000 0x00000001 0x7fc00001 -> 0x00000001 0x807fffff 0x7fc00001 -> 0x807fffff 0x7fc00001 0xffc00002 -> 0x7fc00001 0xffc00002 0xffc00002 -> 0xffc00002 0x7f800003 0xffc00002 -> 0x7f800003 0xff800004 0xffc00002 -> 0xff800004 0x7f800000 0xffc00002 -> 0x7f800000 0xff800000 0xffc00002 -> 0xff800000 0x00000000 0xffc00002 -> 0x00000000 0x80000000 0xffc00002 -> 0x80000000 0x3f800000 0xffc00002 -> 0x3f800000 0x00000001 0xffc00002 -> 0x00000001 0x807fffff 0xffc00002 -> 0x807fffff 0x7fc00001 0x7f800003 -> 0x7fc00001 0xffc00002 0x7f800003 -> 0xffc00002 0x7f800003 0x7f800003 -> 0x7f800003 0xff800004 0x7f800003 -> 0xff800004 0x7f800000 0x7f800003 -> 0x7f800000 0xff800000 0x7f800003 -> 0xff800000 0x00000000 0x7f800003 -> 0x00000000 0x80000000 0x7f800003 -> 0x80000000 0x3f800000 0x7f800003 -> 0x3f800000 0x00000001 0x7f800003 -> 0x00000001 0x807fffff 0x7f800003 -> 0x807fffff 0x7fc00001 0xff800004 -> 0x7fc00001 0xffc00002 0xff800004 -> 0xffc00002 0x7f800003 0xff800004 -> 0x7f800003 0xff800004 0xff800004 -> 0xff800004 0x7f800000 0xff800004 -> 0x7f800000 0xff800000 0xff800004 -> 0xff800000 0x00000000 0xff800004 -> 0x00000000 0x80000000 0xff800004 -> 0x80000000 0x3f800000 0xff800004 -> 0x3f800000 0x00000001 0xff800004 -> 0x00000001 0x807fffff 0xff800004 -> 0x807fffff 0x7fc00001 0x7f800000 -> 0x7f800000 0xffc00002 0x7f800000 -> 0x7f800000 0x7f800003 0x7f800000 -> 0x7f800000 0xff800004 0x7f800000 -> 0x7f800000 0x7fc00001 0xff800000 -> 0xff800000 0xffc00002 0xff800000 -> 0xff800000 0x7f800003 0xff800000 -> 0xff800000 0xff800004 0xff800000 -> 0xff800000 0x7fc00001 0x00000000 -> 0x00000000 0xffc00002 0x00000000 -> 0x00000000 0x7f800003 0x00000000 -> 0x00000000 0xff800004 0x00000000 -> 0x00000000 0x7fc00001 0x80000000 -> 0x80000000 0xffc00002 0x80000000 -> 0x80000000 0x7f800003 0x80000000 -> 0x80000000 0xff800004 0x80000000 -> 0x80000000 0x7fc00001 0x3f800000 -> 0x3f800000 0xffc00002 0x3f800000 -> 0x3f800000 0x7f800003 0x3f800000 -> 0x3f800000 0xff800004 0x3f800000 -> 0x3f800000 0x7fc00001 0x00000001 -> 0x00000001 0xffc00002 0x00000001 -> 0x00000001 0x7f800003 0x00000001 -> 0x00000001 0xff800004 0x00000001 -> 0x00000001 0x7fc00001 0x807fffff -> 0x807fffff 0xffc00002 0x807fffff -> 0x807fffff 0x7f800003 0x807fffff -> 0x807fffff 0xff800004 0x807fffff -> 0x807fffff v_max_f32(a,b) on the special values with at least one NaN: 0x7fc00001 0x7fc00001 -> 0x7fc00001 0xffc00002 0x7fc00001 -> 0xffc00002 0x7f800003 0x7fc00001 -> 0x7f800003 0xff800004 0x7fc00001 -> 0xff800004 0x7f800000 0x7fc00001 -> 0x7f800000 0xff800000 0x7fc00001 -> 0xff800000 0x00000000 0x7fc00001 -> 0x00000000 0x80000000 0x7fc00001 -> 0x80000000 0x3f800000 0x7fc00001 -> 0x3f800000 0x00000001 0x7fc00001 -> 0x00000001 0x807fffff 0x7fc00001 -> 0x807fffff 0x7fc00001 0xffc00002 -> 0x7fc00001 0xffc00002 0xffc00002 -> 0xffc00002 0x7f800003 0xffc00002 -> 0x7f800003 0xff800004 0xffc00002 -> 0xff800004 0x7f800000 0xffc00002 -> 0x7f800000 0xff800000 0xffc00002 -> 0xff800000 0x00000000 0xffc00002 -> 0x00000000 0x80000000 0xffc00002 -> 0x80000000 0x3f800000 0xffc00002 -> 0x3f800000 0x00000001 0xffc00002 -> 0x00000001 0x807fffff 0xffc00002 -> 0x807fffff 0x7fc00001 0x7f800003 -> 0x7fc00001 0xffc00002 0x7f800003 -> 0xffc00002 0x7f800003 0x7f800003 -> 0x7f800003 0xff800004 0x7f800003 -> 0xff800004 0x7f800000 0x7f800003 -> 0x7f800000 0xff800000 0x7f800003 -> 0xff800000 0x00000000 0x7f800003 -> 0x00000000 0x80000000 0x7f800003 -> 0x80000000 0x3f800000 0x7f800003 -> 0x3f800000 0x00000001 0x7f800003 -> 0x00000001 0x807fffff 0x7f800003 -> 0x807fffff 0x7fc00001 0xff800004 -> 0x7fc00001 0xffc00002 0xff800004 -> 0xffc00002 0x7f800003 0xff800004 -> 0x7f800003 0xff800004 0xff800004 -> 0xff800004 0x7f800000 0xff800004 -> 0x7f800000 0xff800000 0xff800004 -> 0xff800000 0x00000000 0xff800004 -> 0x00000000 0x80000000 0xff800004 -> 0x80000000 0x3f800000 0xff800004 -> 0x3f800000 0x00000001 0xff800004 -> 0x00000001 0x807fffff 0xff800004 -> 0x807fffff 0x7fc00001 0x7f800000 -> 0x7f800000 0xffc00002 0x7f800000 -> 0x7f800000 0x7f800003 0x7f800000 -> 0x7f800000 0xff800004 0x7f800000 -> 0x7f800000 0x7fc00001 0xff800000 -> 0xff800000 0xffc00002 0xff800000 -> 0xff800000 0x7f800003 0xff800000 -> 0xff800000 0xff800004 0xff800000 -> 0xff800000 0x7fc00001 0x00000000 -> 0x00000000 0xffc00002 0x00000000 -> 0x00000000 0x7f800003 0x00000000 -> 0x00000000 0xff800004 0x00000000 -> 0x00000000 0x7fc00001 0x80000000 -> 0x80000000 0xffc00002 0x80000000 -> 0x80000000 0x7f800003 0x80000000 -> 0x80000000 0xff800004 0x80000000 -> 0x80000000 0x7fc00001 0x3f800000 -> 0x3f800000 0xffc00002 0x3f800000 -> 0x3f800000 0x7f800003 0x3f800000 -> 0x3f800000 0xff800004 0x3f800000 -> 0x3f800000 0x7fc00001 0x00000001 -> 0x00000001 0xffc00002 0x00000001 -> 0x00000001 0x7f800003 0x00000001 -> 0x00000001 0xff800004 0x00000001 -> 0x00000001 0x7fc00001 0x807fffff -> 0x807fffff 0xffc00002 0x807fffff -> 0x807fffff 0x7f800003 0x807fffff -> 0x807fffff 0xff800004 0x807fffff -> 0x807fffff == nan, IEEE mode 1: candidate = first NaN operand in source order, quieted; generated NaN = 0x7fc00000 v_fma_f32 (a,b,c): 65265 NaN cases, 104 differ from the candidate: (0x00000000,0x7f800000,0x7fc00001)->0xffc00000 (0x80000000,0x7f800000,0x7fc00001)->0xffc00000 (0x00000000,0xff800000,0x7fc00001)->0xffc00000 (0x80000000,0xff800000,0x7fc00001)->0xffc00000 (0x7f800000,0x00000000,0x7fc00001)->0xffc00000 (0xff800000,0x00000000,0x7fc00001)->0xffc00000 v_mul_f32 (a,b): 43824 NaN cases, 88 differ from the candidate: (0x00000000,0x7f800000)->0xffc00000 (0x80000000,0x7f800000)->0xffc00000 (0x00000000,0xff800000)->0xffc00000 (0x80000000,0xff800000)->0xffc00000 (0x7f800000,0x00000000)->0xffc00000 (0xff800000,0x00000000)->0xffc00000 v_add_f32 (a,c): 43886 NaN cases, 22 differ from the candidate: (0xff800000,0x7f800000)->0xffc00000 (0xff800000,0x7f800000)->0xffc00000 (0xff800000,0x7f800000)->0xffc00000 (0xff800000,0x7f800000)->0xffc00000 (0xff800000,0x7f800000)->0xffc00000 (0xff800000,0x7f800000)->0xffc00000 v_fmac_f32 (a,b,D=c): 65265 NaN cases, 104 differ from the candidate: (0x00000000,0x7f800000,0x7fc00001)->0xffc00000 (0x80000000,0x7f800000,0x7fc00001)->0xffc00000 (0x00000000,0xff800000,0x7fc00001)->0xffc00000 (0x80000000,0xff800000,0x7fc00001)->0xffc00000 (0x7f800000,0x00000000,0x7fc00001)->0xffc00000 (0xff800000,0x00000000,0x7fc00001)->0xffc00000 v_sub_f32 (a,c): 43886 NaN cases, 21774 differ from the candidate: (0x7f800000,0x7fc00001)->0xffc00001 (0xff800000,0x7fc00001)->0xffc00001 (0x00000000,0x7fc00001)->0xffc00001 (0x80000000,0x7fc00001)->0xffc00001 (0x3f800000,0x7fc00001)->0xffc00001 (0x00000001,0x7fc00001)->0xffc00001 v_min_f32(a,b) on the special values with at least one NaN: 0x7fc00001 0x7fc00001 -> 0x7fc00001 0xffc00002 0x7fc00001 -> 0xffc00002 0x7f800003 0x7fc00001 -> 0x7fc00003 0xff800004 0x7fc00001 -> 0xffc00004 0x7f800000 0x7fc00001 -> 0x7f800000 0xff800000 0x7fc00001 -> 0xff800000 0x00000000 0x7fc00001 -> 0x00000000 0x80000000 0x7fc00001 -> 0x80000000 0x3f800000 0x7fc00001 -> 0x3f800000 0x00000001 0x7fc00001 -> 0x00000001 0x807fffff 0x7fc00001 -> 0x807fffff 0x7fc00001 0xffc00002 -> 0x7fc00001 0xffc00002 0xffc00002 -> 0xffc00002 0x7f800003 0xffc00002 -> 0x7fc00003 0xff800004 0xffc00002 -> 0xffc00004 0x7f800000 0xffc00002 -> 0x7f800000 0xff800000 0xffc00002 -> 0xff800000 0x00000000 0xffc00002 -> 0x00000000 0x80000000 0xffc00002 -> 0x80000000 0x3f800000 0xffc00002 -> 0x3f800000 0x00000001 0xffc00002 -> 0x00000001 0x807fffff 0xffc00002 -> 0x807fffff 0x7fc00001 0x7f800003 -> 0x7fc00003 0xffc00002 0x7f800003 -> 0x7fc00003 0x7f800003 0x7f800003 -> 0x7fc00003 0xff800004 0x7f800003 -> 0xffc00004 0x7f800000 0x7f800003 -> 0x7fc00003 0xff800000 0x7f800003 -> 0x7fc00003 0x00000000 0x7f800003 -> 0x7fc00003 0x80000000 0x7f800003 -> 0x7fc00003 0x3f800000 0x7f800003 -> 0x7fc00003 0x00000001 0x7f800003 -> 0x7fc00003 0x807fffff 0x7f800003 -> 0x7fc00003 0x7fc00001 0xff800004 -> 0xffc00004 0xffc00002 0xff800004 -> 0xffc00004 0x7f800003 0xff800004 -> 0x7fc00003 0xff800004 0xff800004 -> 0xffc00004 0x7f800000 0xff800004 -> 0xffc00004 0xff800000 0xff800004 -> 0xffc00004 0x00000000 0xff800004 -> 0xffc00004 0x80000000 0xff800004 -> 0xffc00004 0x3f800000 0xff800004 -> 0xffc00004 0x00000001 0xff800004 -> 0xffc00004 0x807fffff 0xff800004 -> 0xffc00004 0x7fc00001 0x7f800000 -> 0x7f800000 0xffc00002 0x7f800000 -> 0x7f800000 0x7f800003 0x7f800000 -> 0x7fc00003 0xff800004 0x7f800000 -> 0xffc00004 0x7fc00001 0xff800000 -> 0xff800000 0xffc00002 0xff800000 -> 0xff800000 0x7f800003 0xff800000 -> 0x7fc00003 0xff800004 0xff800000 -> 0xffc00004 0x7fc00001 0x00000000 -> 0x00000000 0xffc00002 0x00000000 -> 0x00000000 0x7f800003 0x00000000 -> 0x7fc00003 0xff800004 0x00000000 -> 0xffc00004 0x7fc00001 0x80000000 -> 0x80000000 0xffc00002 0x80000000 -> 0x80000000 0x7f800003 0x80000000 -> 0x7fc00003 0xff800004 0x80000000 -> 0xffc00004 0x7fc00001 0x3f800000 -> 0x3f800000 0xffc00002 0x3f800000 -> 0x3f800000 0x7f800003 0x3f800000 -> 0x7fc00003 0xff800004 0x3f800000 -> 0xffc00004 0x7fc00001 0x00000001 -> 0x00000001 0xffc00002 0x00000001 -> 0x00000001 0x7f800003 0x00000001 -> 0x7fc00003 0xff800004 0x00000001 -> 0xffc00004 0x7fc00001 0x807fffff -> 0x807fffff 0xffc00002 0x807fffff -> 0x807fffff 0x7f800003 0x807fffff -> 0x7fc00003 0xff800004 0x807fffff -> 0xffc00004 v_max_f32(a,b) on the special values with at least one NaN: 0x7fc00001 0x7fc00001 -> 0x7fc00001 0xffc00002 0x7fc00001 -> 0xffc00002 0x7f800003 0x7fc00001 -> 0x7fc00003 0xff800004 0x7fc00001 -> 0xffc00004 0x7f800000 0x7fc00001 -> 0x7f800000 0xff800000 0x7fc00001 -> 0xff800000 0x00000000 0x7fc00001 -> 0x00000000 0x80000000 0x7fc00001 -> 0x80000000 0x3f800000 0x7fc00001 -> 0x3f800000 0x00000001 0x7fc00001 -> 0x00000001 0x807fffff 0x7fc00001 -> 0x807fffff 0x7fc00001 0xffc00002 -> 0x7fc00001 0xffc00002 0xffc00002 -> 0xffc00002 0x7f800003 0xffc00002 -> 0x7fc00003 0xff800004 0xffc00002 -> 0xffc00004 0x7f800000 0xffc00002 -> 0x7f800000 0xff800000 0xffc00002 -> 0xff800000 0x00000000 0xffc00002 -> 0x00000000 0x80000000 0xffc00002 -> 0x80000000 0x3f800000 0xffc00002 -> 0x3f800000 0x00000001 0xffc00002 -> 0x00000001 0x807fffff 0xffc00002 -> 0x807fffff 0x7fc00001 0x7f800003 -> 0x7fc00003 0xffc00002 0x7f800003 -> 0x7fc00003 0x7f800003 0x7f800003 -> 0x7fc00003 0xff800004 0x7f800003 -> 0xffc00004 0x7f800000 0x7f800003 -> 0x7fc00003 0xff800000 0x7f800003 -> 0x7fc00003 0x00000000 0x7f800003 -> 0x7fc00003 0x80000000 0x7f800003 -> 0x7fc00003 0x3f800000 0x7f800003 -> 0x7fc00003 0x00000001 0x7f800003 -> 0x7fc00003 0x807fffff 0x7f800003 -> 0x7fc00003 0x7fc00001 0xff800004 -> 0xffc00004 0xffc00002 0xff800004 -> 0xffc00004 0x7f800003 0xff800004 -> 0x7fc00003 0xff800004 0xff800004 -> 0xffc00004 0x7f800000 0xff800004 -> 0xffc00004 0xff800000 0xff800004 -> 0xffc00004 0x00000000 0xff800004 -> 0xffc00004 0x80000000 0xff800004 -> 0xffc00004 0x3f800000 0xff800004 -> 0xffc00004 0x00000001 0xff800004 -> 0xffc00004 0x807fffff 0xff800004 -> 0xffc00004 0x7fc00001 0x7f800000 -> 0x7f800000 0xffc00002 0x7f800000 -> 0x7f800000 0x7f800003 0x7f800000 -> 0x7fc00003 0xff800004 0x7f800000 -> 0xffc00004 0x7fc00001 0xff800000 -> 0xff800000 0xffc00002 0xff800000 -> 0xff800000 0x7f800003 0xff800000 -> 0x7fc00003 0xff800004 0xff800000 -> 0xffc00004 0x7fc00001 0x00000000 -> 0x00000000 0xffc00002 0x00000000 -> 0x00000000 0x7f800003 0x00000000 -> 0x7fc00003 0xff800004 0x00000000 -> 0xffc00004 0x7fc00001 0x80000000 -> 0x80000000 0xffc00002 0x80000000 -> 0x80000000 0x7f800003 0x80000000 -> 0x7fc00003 0xff800004 0x80000000 -> 0xffc00004 0x7fc00001 0x3f800000 -> 0x3f800000 0xffc00002 0x3f800000 -> 0x3f800000 0x7f800003 0x3f800000 -> 0x7fc00003 0xff800004 0x3f800000 -> 0xffc00004 0x7fc00001 0x00000001 -> 0x00000001 0xffc00002 0x00000001 -> 0x00000001 0x7f800003 0x00000001 -> 0x7fc00003 0xff800004 0x00000001 -> 0xffc00004 0x7fc00001 0x807fffff -> 0x807fffff 0xffc00002 0x807fffff -> 0x807fffff 0x7f800003 0x807fffff -> 0x7fc00003 0xff800004 0x807fffff -> 0xffc00004 == normalized conversions: mismatches per rounding rule (nearest, halfup = floor(x + 0.5), trunc) v_cvt_pknorm_i16_f32: nearest 0, halfup 51, trunc 41597 best=nearest v_cvt_pknorm_u16_f32: nearest 0, halfup 0, trunc 23544 best=nearest v_cvt_pknorm_i16_f16: nearest 0, halfup 2, trunc 31546 best=nearest v_cvt_pknorm_u16_f16: nearest 0, halfup 0, trunc 18067 best=nearest v_cvt_norm_i16_f16: nearest 0, halfup 1, trunc 18432 best=nearest upper half of the destination: ['0x5a5a'] (preset 0x5a5a) v_cvt_norm_u16_f16: nearest 0, halfup 0, trunc 9728 best=nearest upper half of the destination: ['0x5a5a'] (preset 0x5a5a) ``` </details> <details><summary>nanfit.py (reads nan.in / nan_ieee{0,1}.out from the gen dir)</summary> ```python import struct, sys, collections D = sys.argv[1] N = 65536 ins = [struct.unpack_from('<4I', open(f"{D}/nan.in","rb").read(), 16*i) for i in range(N)] isnan = lambda b: b & 0x7fffffff > 0x7f800000 isinf = lambda b: b & 0x7fffffff == 0x7f800000 iszero = lambda b: b & 0x7fffffff == 0 issnan = lambda b: isnan(b) and not b & 0x400000 f = lambda b: struct.unpack('<f', struct.pack('<I', b))[0] def fit(m, DEF, prod_invalid_first, sub_neg): Q = (lambda x: x | 0x400000) if m else (lambda x: x) def arith(ops, kind): # kind: 'fma','mul','add','sub' if kind == 'sub' and sub_neg: ops = [ops[0], ops[1] ^ 0x80000000] if kind == 'fma': a, b, c = ops inv = (isinf(a) and iszero(b)) or (iszero(a) and isinf(b)) if not isnan(a) and not isnan(b) and inv and prod_invalid_first: return DEF for x in ops: if isnan(x): return Q(x) if inv: return DEF p = f(a) * f(b) if p == p and abs(p) == float('inf') and isinf(c) and (p > 0) != (not c >> 31): return DEF return None for x in ops: if isnan(x): return Q(x) a, b = ops if kind == 'mul' and ((isinf(a) and iszero(b)) or (iszero(a) and isinf(b))): return DEF if kind in ('add', 'sub') and isinf(a) and isinf(b) and (a >> 31) != (b >> 31): return DEF return None def minmax(a, b): if m == 0: if isnan(a) and isnan(b): return a if isnan(a): return b if isnan(b): return a return None # IEEE mode: sNaN wins (quieted), else qNaN ignored if issnan(a): return Q(a) if issnan(b): return Q(b) if isnan(a) and isnan(b): return a if isnan(a): return b if isnan(b): return a return None raw = open(f"{D}/nan_ieee{m}.out","rb").read() cols = (("v_fma_f32", 0, (0,1,2), 'fma'), ("v_mul_f32", 1, (0,1), 'mul'), ("v_add_f32", 2, (0,2), 'add'), ("v_fmac_f32", 5, (0,1,2), 'fma'), ("v_sub_f32", 6, (0,2), 'sub'), ("v_min_f32", 3, (0,1), 'min'), ("v_max_f32", 4, (0,1), 'max')) res = {} for name, col, sel, kind in cols: n = bad = 0; ex = [] for i in range(N): t = ins[i]; o = struct.unpack_from('<I', raw, 64*i + 4*col)[0] ops = [t[j] for j in sel] want = minmax(*ops) if kind in ('min','max') else arith(ops, kind) if want is None: if isnan(o): bad += 1; ex.append((ops, o, 'unexpected NaN')) continue n += 1 if o != want: bad += 1 if len(ex) < 4: ex.append(([hex(x) for x in ops], hex(o), hex(want))) res[name] = (n, bad, ex) return res for m in (0, 1): for DEF in (0xffc00000, 0x7fc00000): for pif in (True, False): r = fit(m, DEF, pif, True) tot = sum(v[1] for v in r.values()) print(f"mode {m} DEF {DEF:#x} prod_invalid_first {pif}: total mismatches {tot}") if tot < 200: for k, (n, bad, ex) in r.items(): print(f" {k}: {n} NaN results checked, {bad} mismatches {ex[:3]}") ``` </details>
Author
Owner

@⁠QuentinDanblon on GitHub · 2026-11-22 00:07 UTC · original

Thank you, that settles three questions with measurements. I recorded your results in the tool's README on #72 (commit ae3a658, credited to you, with a link to your comment), and reported them where they apply:

  • f16 FMA at VOP2 0x36 / 0x37 / 0x38: fused. That is what #49 implements (v_fmac/fmamk/fmaak_f16); main still decodes them as v_mac/madmk/madak_f16 and multiplies then adds.
  • s_bfe: 7-bit width, sign-fill. Main since 8491769 is right, and the oracles in #70 now have a hardware source.
  • Normalized conversions: round to nearest, NaN gives 0.

For @⁠omonkeyz, the NaN part is the one that does not match the translator. tb_fma on main (and the CPU reference in #73) returns the first NaN operand quieted, and 0x7fc00000 for an invalid operation. On gfx1036:

  1. an invalid operation returns 0xffc00000, in both IEEE modes;
  2. 0 * inf + NaN returns that default NaN, not the NaN in c;
  3. in IEEE mode 0 a signalling NaN comes back unchanged, it is quieted only in IEEE mode 1.

I have not changed anything for this. Which IEEE mode the console's shaders run in is something I can't establish from here, and the measurement is gfx1036, not gfx1013.

I did not update show to check your fitted rules, since I can't run it against real outputs. If you want your fitting script in the tool, it is yours to add; I'll rebase #72 on whatever #41 becomes.

**@⁠QuentinDanblon** on GitHub · 2026-11-22 00:07 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/41#issuecomment-7071325419) Thank you, that settles three questions with measurements. I recorded your results in the tool's README on #72 (commit `ae3a658`, credited to you, with a link to your comment), and reported them where they apply: - **f16 FMA at VOP2 0x36 / 0x37 / 0x38: fused.** That is what #49 implements (`v_fmac/fmamk/fmaak_f16`); main still decodes them as `v_mac/madmk/madak_f16` and multiplies then adds. - **`s_bfe`: 7-bit width, sign-fill.** Main since `8491769` is right, and the oracles in #70 now have a hardware source. - **Normalized conversions: round to nearest, NaN gives 0.** For @⁠omonkeyz, the NaN part is the one that does not match the translator. `tb_fma` on main (and the CPU reference in #73) returns the first NaN operand quieted, and `0x7fc00000` for an invalid operation. On gfx1036: 1. an invalid operation returns `0xffc00000`, in both IEEE modes; 2. `0 * inf + NaN` returns that default NaN, not the NaN in c; 3. in IEEE mode 0 a signalling NaN comes back unchanged, it is quieted only in IEEE mode 1. I have not changed anything for this. Which IEEE mode the console's shaders run in is something I can't establish from here, and the measurement is gfx1036, not gfx1013. I did not update `show` to check your fitted rules, since I can't run it against real outputs. If you want your fitting script in the tool, it is yours to add; I'll rebase #72 on whatever #41 becomes.
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-22 13:12 UTC · original

Main's history was rewritten, which auto-closed this PR (sorry for the noise). Please rebase on main's current mtbuf code and strip comment lines. The probe README is .md under tools/, which is not published, so put that text in the PR description or a .txt. To resubmit: git fetch this repo, branch from the current main, cherry-pick only your own commits (the old branch is based on the previous history and cannot be merged), and open a new PR.

**@⁠omonkeyz** on GitHub · 2026-11-22 13:12 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/41#issuecomment-7079647129) Main's history was rewritten, which auto-closed this PR (sorry for the noise). Please rebase on main's current mtbuf code and strip comment lines. The probe README is .md under tools/, which is not published, so put that text in the PR description or a .txt. To resubmit: `git fetch` this repo, branch from the current `main`, cherry-pick only your own commits (the old branch is based on the previous history and cannot be merged), and open a new PR.

Pull request closed

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