Recompiler: 16-bit compares honor op_sel; RDNA2 hardware ignores it (measured on gfx1036, see VIctory#833/#926) #1293

Open
opened 2026-11-26 04:49:48 +00:00 by github-bot · 1 comment
Owner

@⁠pickles976 on GitHub · 2026-11-24 14:22 UTC · original

What this is: a latent, hardware-measured divergence between our VOPC emitter and console hardware, discovered by cross-project exchange. Dormant for the title today; cheap to close before it isn't.

The hardware fact (measured, not inferred). The sibling runtime measured 146 rows on real gfx1036 (Marvisak/VIctory#833): on RDNA2, op_sel bits are ignored by 16-bit compares — v_cmp_*/v_cmpx_* over f16/u16/i16 take both sources from the low 16 bits regardless — while v_add_nc_u16 under the same bits honors them (control). Their fix + GPU/WARP-run tests: Marvisak/VIctory#926. (v_cmp_class* was not measured; unknown side.)

Our side. crates/xcl/src/gpu/recomp/emit.rs, vopc: let half = |i, s| if m.opsel >> i & 1 == 1 { (s >> 16) } else { (s & 0xFFFF) } — we honor op_sel for every 16-bit compare type. With op_sel:[1,0] on v0 = 0x4000_3C00, v1 = 0x3C00_3E00, console computes 1.0 < 1.5 = true; we compute 2.0 < 1.5 = false — a silently inverted VCC bit, i.e., wrong coverage, no crash.

Why nobody has seen it. Their corpus count of the shared title: 166 16-bit VOPC compares, none with op_sel set — so this only bites shaders the title does not (yet) ship, or a future patch. It belongs in the model now because a wrong-but-quiet VCC bit is the class of bug that costs a week when it finally shows up as "wrong shadow mask on RDNA3 hosts".

Fix sketch: in vopc, force the low half for ty in {f16, u16, i16} unless class (leave class as-is pending measurement, like the sibling did); a host-GPU test mirroring their three op_sel rows with halves chosen so low/high give opposite answers. Attribution: measurement and reference values from VIctory#833/#926 (GPL-3.0 repo — behavior, not code).

**@⁠pickles976** on GitHub · 2026-11-24 14:22 UTC · [original](https://github.com/xcl-dev/xcl/issues/1293) **What this is:** a latent, hardware-measured divergence between our VOPC emitter and console hardware, discovered by cross-project exchange. Dormant for the title today; cheap to close before it isn't. **The hardware fact (measured, not inferred).** The sibling runtime measured 146 rows on real gfx1036 (Marvisak/VIctory#833): on RDNA2, **`op_sel` bits are ignored by 16-bit compares** — `v_cmp_*`/`v_cmpx_*` over `f16`/`u16`/`i16` take **both sources from the low 16 bits regardless** — while `v_add_nc_u16` under the same bits honors them (control). Their fix + GPU/WARP-run tests: Marvisak/VIctory#926. (`v_cmp_class*` was not measured; unknown side.) **Our side.** `crates/xcl/src/gpu/recomp/emit.rs`, `vopc`: `let half = |i, s| if m.opsel >> i & 1 == 1 { (s >> 16) } else { (s & 0xFFFF) }` — we honor `op_sel` for every 16-bit compare type. With `op_sel:[1,0]` on `v0 = 0x4000_3C00`, `v1 = 0x3C00_3E00`, console computes `1.0 < 1.5` = true; we compute `2.0 < 1.5` = false — a silently inverted VCC bit, i.e., wrong coverage, no crash. **Why nobody has seen it.** Their corpus count of the shared title: 166 16-bit VOPC compares, **none with `op_sel` set** — so this only bites shaders the title does not (yet) ship, or a future patch. It belongs in the model now because a wrong-but-quiet VCC bit is the class of bug that costs a week when it finally shows up as "wrong shadow mask on RDNA3 hosts". **Fix sketch:** in `vopc`, force the low half for `ty` in {f16, u16, i16} unless `class` (leave `class` as-is pending measurement, like the sibling did); a host-GPU test mirroring their three op_sel rows with halves chosen so low/high give opposite answers. Attribution: measurement and reference values from VIctory#833/#926 (GPL-3.0 repo — behavior, not code).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:49:48 +00:00
Author
Owner

@⁠tiagonogueiraa-bit on GitHub · 2026-11-24 14:25 UTC · original

claiming: vopc takes both sources of the f16 / u16 / i16 compares (v_cmp_*, v_cmpx_*) from the low halves whatever op_sel says, leaving class as it is. It comes with a test that fails on main. PR within the hour.

Written with Claude Code (Claude Opus 5.5).

**@⁠tiagonogueiraa-bit** on GitHub · 2026-11-24 14:25 UTC · [original](https://github.com/xcl-dev/xcl/issues/1293#issuecomment-7134343467) claiming: `vopc` takes both sources of the f16 / u16 / i16 compares (`v_cmp_*`, `v_cmpx_*`) from the low halves whatever `op_sel` says, leaving `class` as it is. It comes with a test that fails on main. PR within the hour. Written with Claude Code (Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.