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

Open
opened 2026-11-24 14:22:11 +00:00 by pickles976 · 1 comment
pickles976 commented 2026-11-24 14:22:11 +00:00 (Migrated from github.com)
Contributor

Imported from ivall/xcl. Originally posted by pickles976 on 2026-11-24T14:22:11Z.


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).

<!-- greyfinch-sync:ivall/xcl:issue:6583924035 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/issues/1293). Originally posted by [pickles976](https://github.com/pickles976) on 2026-11-24T14:22:11Z. --- **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).
tiagonogueiraa-bit commented 2026-11-24 15:05:52 +00:00 (Migrated from github.com)
Author
Contributor

Imported from ivall/xcl. Originally posted by tiagonogueiraa-bit on 2026-11-24T14:25:12Z.


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).

<!-- greyfinch-sync:ivall/xcl:comment:7134343467 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/issues/1293#issuecomment-7134343467). Originally posted by [tiagonogueiraa-bit](https://github.com/tiagonogueiraa-bit) on 2026-11-24T14:25:12Z. --- 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).
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl#1283
No description provided.