Repository navigation
audit_shader4_regs: non-returning DS ops read every operand and write nothing - #3905
Conversation
… nothing ds_add_u32 v1, v2 and the other non-_rtn LDS atomics (cmpst, mskor, the f32/f64/u64/b64 forms, src2 forms) and ds_gws_init/ds_gws_barrier treated args[0] as a written destination, so a later read of the LDS address register was not reported as read-before-write. A ds_ op now has no destination unless it has _rtn or is ds_read*, ds_swizzle, ds_permute, ds_bpermute, ds_append, ds_consume or ds_ordered_count, the rule tools/lane_masks.py already uses.
|
Tested at the head on Windows 11 / Python 3.13.0: 8 tests OK (7 on
Nit: this is now the third copy of the lane-mask rule; a shared constant would stop it drifting. Approve. AI-assisted review, no game files, no GPU. |
|
Tested 72f5d2f merged with main 3faac55 on Linux (WSL2), Python 3.12.16: pass. |
|
The two red checks on this run don't come from this PR, which only changes
The branch still merges cleanly. A rerun on current AI-assisted (Claude Code). |
New item (claimed in #3796).
What
scripts/audit_shader4_regs.pyrbw_registers()treatedargs[0]of non-returning DS ops as a written destination, the case left after #3214.ds_add_u32 v1, v2thenv_mov_b32 v3, v1gave([], [2], []): v1 is the LDS address and is only read. The same applied to every non-_rtnDS atomic (ds_sub/rsub/inc/dec/min/max/and/or/xor/mskor/cmpst, the_f32/_f64/_u64/_b64forms,ds_*_src2_*) and tods_gws_init/ds_gws_barrier, whose data VGPR was counted as written.A
ds_op now has no destination unless its name has_rtnor it isds_read*,ds_swizzle*,ds_permute*,ds_bpermute*,ds_append,ds_consumeords_ordered_count(newDS_HAS_DST, same rule astools/lane_masks.py:143). Already correct on main and unchanged:ds_write*(inNO_DEST_OPS), all_rtnforms includingds_wrxchg*_rtnandds_cmpst_rtn,ds_append/ds_consume,ds_swizzle,ds_permute/ds_bpermute,ds_read*,ds_ordered_count.tests/test_audit_shader4_regs.pyaddstest_non_returning_ds_ops_read_every_operand, built withshader_ir.parse_line: theds_add_u32case above, 22 non-returning forms, and 12 returning forms that must keepargs[0]written and not read.Tested
Windows 11, Python 3.14 and 3.13, CPU only.
python -I tests/test_audit_shader4_regs.py: 8 tests OK (3.14 and 3.13). On main the new test fails:[2] != [1, 2]fords_add_u32 v1, v2._rtnguard fails 4 subtests (the_rtnforms); dropping theDS_HAS_DSTguard fails 8 subtests (read/swizzle/permute/append/consume/ordered_count).tests/test_text_write_line_endings.py,tests/test_tool_stdout_encoding.py: OK.python -m compileall -qon both files: OK.No game files. AI-assisted (Claude Code).