Repository navigation
tests/semantic: the folded SMEM loads read the word at the folded offset - #4047
slint6614-dev wants to merge 1 commit into
Conversation
Nine tests in test_salu_chained_const_prop.py fold a SALU chain into an s_buffer_load_dword offset and asserted only that no branch diamond is emitted. A wrong fold that stays inside the buffer still gives a straight-line load, just from the wrong address, so a broken sgpr_imm fold for s_add_u32, s_sub_u32, s_lshl2_add_u32, s_andn2_b32, s_min_u32 or s_bfm_b32 passed this file and every other test that uses those ops. Run each translated shader through spirv_mini_interp with a buffer whose words encode their own byte offset, and assert the loaded word. The existing no-branch checks stay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013nWg6BssUf8MjNaKuMSkfc
|
Independent Windows CPU check of 9f9681f against aa2988c. All 11 tests in test_salu_chained_const_prop.py passed. For a separate control I kept translation and interpretation unchanged and shifted the synthetic memory markers by four. The real interpreter then returned 41032 for the folded 69-byte offset and the new assertion rejected it, expecting 41028 for aligned offset 68. The existing structural checks still ran before that assertion. This verifies the output assertion can distinguish adjacent word markers. No GPU or native build ran. AI-assisted. |
Flyander
left a comment
There was a problem hiding this comment.
Reviewed at 9f9681f. The added interpreter-backed assertions exercise the loaded word, including aligned SMEM addressing, rather than only checking the translated control flow. I independently ran the focused unittest file on Windows: 11/11 passed.
Claimed in the coordination issue as: new TEST item, #3918 (comment)
What and why
Nine tests in
tests/semantic/test_salu_chained_const_prop.pyfold a SALU chain into ans_buffer_load_dwordoffset and assert only that no branch diamond is emitted. A wrong fold that stays inside the buffer still gives a straight-line load, just from the wrong address, so these tests could not catch a brokensgpr_immvalue.This adds
assert_loads_offset(): it runs the translated shader throughspirv_mini_interp(viasupport.mrt0_words) with a buffer whose words encode their own byte offset (0xA000 + offset), and checks the loaded word. SMEM ignores the low two offset bits, sos_lshl2_add_u32's offset 69 reads the word at 68. The existing no-branch checks stay. Test-only change; the translator is untouched.Tested
Linux (WSL2), CPython 3.14.4, CPU only, no GPU, no game files, at
aa2988cc:python -m unittest discover -s tests/semantic -p test_salu_chained_const_prop.py: 11/11 pass.python -I tests/test_text_write_line_endings.py: pass.git diff --check: clean.Mutation check: I changed one
sgpr_immfold at a time intools/rdna2spirv.py, then reran this file. Before this change, I also ran the 26 other test files that use these ops, run as CI runs them and all green onmainfirst.main: this file + 26 otherss_add_u32(+4)s_sub_u32(+4)s_lshl2_add_u32(+4)s_andn2_b32(NOT dropped)s_min_u32(returns max)s_bfm_b32(- 1dropped)s_absdiff_i32(+4)(
s_add_u32was checked against this file only onmain.tests/test_cf_diff.pyneeds pytest and was not run.tests/semantic/test_loop_ballot_barrier.pywas left out because it is already red onmain; #3995 fixes it.)Checklist
docs/design.md, with how it was confirmed. (No new rule: test-only.)AI-assisted (Claude Code).
🤖 Generated with Claude Code
https://claude.ai/code/session_013nWg6BssUf8MjNaKuMSkfc