startup: lower NEG on an immediate source of v_cndmask_b32_e64 from its encoding #1925
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1932"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-24T21:39:58Z.
Refs #1723 (row "
v_cndmaskwith NEG on an immediate", new refusal since #1710).Change
v_cndmask_b32is a bitwise select, so the-modifier on a source flips that source's bit 31 (#1710). For immediate sources the printed operand is ambiguous:-1can be the inline constant -1 (0xffffffff) or inline 1 with NEG (0x80000001).decode()intools/startup/gfx2hlsl.pytherefore refused NEG on an immediate, as kept in #1710 (dfc73a1b).This lifts that refusal by resolving the value from the encoding. For
v_cndmask_b32_e64, when a source field with its NEG bit set holds an immediate,decode()takes the source word and rewrites that operand as an unambiguous hex literal with bit 31 flipped. The source word is:INLINE_FLOAT_LITERALSintools/disasm_rdna2.py);The handler then sees a plain literal. For example, inline 1 with NEG becomes
0x80000001uwhile plain inline -1 stays0xffffffffu, and NEG of 0.5 becomes0xbf000000u.Unchanged:
mul:2, ABS on register sources and negated masks.ABS on an immediate, with or without NEG, is refused in the decoder. A literal form without its dword is also refused, but that case is not exercised by the test.
The existing
docs/experiments.mdparagraph of #1710 is updated; CTeststartup_gfx2hlsl_cndmask_negis unchanged and there is no new registration.Verification
On
3ef8e9bd(based onmainatb96960b7), Windows 11 build 26300, Python 3.14.10:38 checks,
PASS. The test encodes and decodes the select and checks:An in-process control restores the old refusal and requires both the inline and the literal case to be refused again. On
main(b96960b7) the script stops at its first NEG-on-immediate case with an uncaughtUnsupported: v_cndmask_b32_e64 NEG on an immediate.Also run on this branch, each
python -B tests/<name>exiting 0:startup_uniform_lane_check.py,startup_gfx2hlsl_op_refusals_check.py,startup_gfx2hlsl_cvt_alu_check.py,startup_gfx2hlsl_operand_count_check.py,startup_gfx2hlsl_bit_alu_check.py;startup_gfx2hlsl_mad_check.py,startup_gfx2hlsl_smem_offset_check.py,startup_gfx2hlsl_scalar_m0_check.py,startup_gfx2hlsl_vopc_sdwa_check.py,startup_translator_check.py,startup_flat_param_check.py,startup_inline_sampler_check.py;startup_buffer_address_check.py,startup_sampler_heap_check.py,startup_stream_fetch_check.py,startup_image_2d_array_check.py,startup_image_load_mip_check.py;docs_links_check.py,bidi_controls_check.py.CTest was not run for this change.
Evidence and follow-up
Checklist
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T21:49:56Z.
Review: COMMENTED
Review of head
3ef8e9bdfdResult: no P1, no P2, one P3.
Commands run locally, with results:
git merge-tree --write-tree --name-only origin/main HEAD: clean, no conflicts.gh pr checks 1932: Linux Python checks, gfx1013 fixtures and Windows build all pass. The /O2 job and the chart job were skipped.git diff --check origin/main...HEAD: clean.python3 tests/bidi_controls_check.py: pass.python3 tests/docs_links_check.py: pass.python3 tests/startup_gfx2hlsl_cndmask_neg_check.py: PASS.tests/startup_gfx2hlsl*_check.py: pass.Read of the change:
Mutation: in
tools/startup/gfx2hlsl.pyI changedif source <= 192:toif source < 192:. The test failed withNEG on src0 encoding 192: MISMATCH. I then rangit checkout -- ., so the tree is clean.P1: none.
P2: none.
P3:
tests/startup_gfx2hlsl_cndmask_neg_check.py, section 9 (the "restore the old refusal" block): it re-creates removed behavior and asserts that the old code would reject the new inputs. That guards the past, not the current behavior, and the exact-word checks above already cover it. I suggest deleting it.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T21:49:03Z.
Ran it, broke it four ways, and checked the duplicated table separately
Windows 11 build 26300.9974, device-free:
Mutations to
tools/startup/gfx2hlsl.py, each reverted and re-run:bits ^ 0x80000000→bits(NEG stops flipping bit 31)bits = source - 128→source - 127(integer inline constant off by one)CNDMASK_INLINE_FLOAT_BITS[source - 240]→[source - 241](table shifted)raise Unsupported('… ABS on an immediate')→passThe third is the one I wanted to know about: the new table duplicates nine words that already exist in
tools/disasm_rdna2.py, so an off-by-one there would silently produce wrong literals for eight of the nine encodingswhile every "did it stop refusing" case still passed. Your fixture notices.
Independent check of the table itself
Because a duplicated constant table is exactly the kind of thing that drifts, I checked it against the encoding rather than
against your expectations: for each encoding 240–248 with NEG set on source 0, translate and require
literal == CNDMASK_INLINE_FLOAT_BITS[enc - 240] ^ 0x80000000:Nine of nine, including the
1/(2*pi)entry at 248 that is easy to leave out. Note what this does not prove: my probereuses your
encode_vop2_e64, so it confirms the table agrees with the flip arithmetic, not that the encoder sets NEG at bit29+i. Your ABS/NEG refusal cases and thev30, -v30path cover that separately.One observation on the wording
The description says the float entries are "duplicated from
INLINE_FLOAT_LITERALSintools/disasm_rdna2.py". That dict iskeyed by bits with string values, so the copy is not mechanical — the encoding order has to be reconstructed by hand. Worth
a comment at
CNDMASK_INLINE_FLOAT_BITSsaying the order is 240…248 rather than "the same as that dict", which a reader maytry to diff and fail. (If the decoder ever grows a
240 + indextable, this copy should read from it.)Verdict
Reviewed. The refusal lift is narrow, the bit-flip path is pinned, and the copied table is correct on all nine entries.
Notes