Repository navigation
startup: lower NEG on an immediate source of v_cndmask_b32_e64 from its encoding - #1932
Conversation
…ts encoding AI-assisted.
Ran it, broke it four ways, and checked the duplicated table separatelyWindows 11 build 26300.9974, device-free: out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_cndmask_neg_check.py
PASS exit 0Mutations to
The third is the one I wanted to know about: the new table duplicates nine words that already exist in Independent check of the table itselfBecause a duplicated constant table is exactly the kind of thing that drifts, I checked it against the encoding rather than Nine of nine, including the One observation on the wordingThe description says the float entries are "duplicated from VerdictReviewed. The refusal lift is narrow, the bit-flip path is pinned, and the copied table is correct on all nine entries. Notes
|
tedin7
left a comment
There was a problem hiding this comment.
Review of head 3ef8e9b
Result: 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.- All
tests/startup_gfx2hlsl*_check.py: pass. - No C++ or CMake files are touched, so the Windows node was not used.
Read of the change:
- Inline integer mapping is right: 128 is 0, 129..192 is 1..64, 193..208 is -1..-16.
- The float table matches the RDNA 2 order for 240..248, including 1/(2*pi).
- The literal dword is read from offset 8 only when the instruction is 12 bytes. A missing dword is refused.
- ABS on an immediate is refused, with or without NEG. Register operands are unaffected.
- Only the two data operands are rewritten. The mask operand and any trailing modifiers are kept.
- The tests assert exact words at every integer edge and for every inline float. They also cover NEG on two immediates at once and the next instruction offset after a literal.
Mutation: in tools/startup/gfx2hlsl.py I changed if source <= 192: to if source < 192:. The test failed with NEG on src0 encoding 192: MISMATCH. I then ran git 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.
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.