mesh: accept the whole-register scratch-base setup in the bounded lowerers (Part of #1998) #2500
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2508"
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-25T19:00:03Z.
Part of #1998: the flat-scratch setup found by the mesh loop census (census comment, claim).
The two
s_setreg_imm32_b32writes toHW_REG_FLAT_SCR_LO/HIwere the first refusal for 4,274 of 4,458 programs in the census. This lowers a whole-register immediate write to either half to nothing in the bounded mesh lowerers. It uses the same rule ascompute_store_aot.py, with the immediate spelling pattern copied from there.Soundness
scratch_*andflat_*memory instructions ands_getreg_b32of these registers read the scratch base.run_groupscans the whole decoded program first. If the program holds an accepted write and anyscratch_*,flat_*ors_getreg_*instruction, on any path, it is refused. The mesh lowerers lower none of these for any register.hwreg(HW_REG_FLAT_SCR_LO, 0, 16));s_setreg_b32SGPR form;tools/mesh_dynamic_aot.pyuses the sameWave/run_group, so it gets the same rule.mesh_loop_census.pyplaces it "after execution". The docs note this.Tests
tests/mesh_entry_check.py flat-scratchis a new CPU mode, registered asmesh_entry_flat_scratch_cpuand listed in AGENTS.md. It checks:scratch_load_dword,flat_load_dwordands_getreg_b32 ..., hwreg(HW_REG_FLAT_SCR_LO)are each refused with "may be observed by " while sitting on a branch arm that no wave executes. Each arm also lowers unchanged without the writes.tests/mesh_dynamic_aot_check.pyrepeats the equivalence and the skipped scratch load, with the same control, for the run-time lowerer.tests/mesh_loop_census_check.pynow expects the setup fixture to reach its latch in both census runs (as decoded, and with the writes replaced bys_nop).Mutation checks, run by hand. Each one fails at least one of the tests above:
s_getreg_,flat_orscratch_from the scan;Run locally (Windows, Python 3.14): all pass.
mesh_entry_check.pyin theflat-scratch,skippedandexec-restoremodes;mesh_dynamic_aot,mesh_loop_census,mesh_entry_aot_cli,mesh_dynamic_geometry,mesh_heap_sampler,mesh_clip_cull,mesh_lane_spill,mesh_scc_any_lane,mesh_amplification_refusalandmesh_join_descriptorchecks.No GPU or draw tests were run. Programs without the writes are not affected: both the scan and the skip only act on a matching write.
docs/experiments.md: a short section after the loop census, and the census paragraph updated.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T19:07:14Z.
Review: COMMENTED
Review of head
a879d63f(comment only).No blocking findings. What I checked:
flat_scratch_writeaccepts only the whole-register immediate write of FLAT_SCR_LO/HI with the same immediate spellings ascompute_store_aot.py. Field writes, the SGPR form and other hardware registers still fall through to the unsupported-instruction path.run_groupscans the whole decoded program before running, so a reader on a skipped arm is still caught. BothWave.runandtools/mesh_dynamic_aot.pygo throughrun_group, so the rule covers both.flat-scratchmode.Commands run (Linux, clean worktree of the exact head):
python3 tests/mesh_entry_check.py flat-scratch: passpython3 tests/mesh_dynamic_aot_check.py,python3 tests/mesh_loop_census_check.py: passpython3 tests/docs_links_check.py,python3 tests/bidi_controls_check.py,git diff --check origin/main...HEAD: passflat-scratchfail: removing therun_grouppre-scan; droppingflat_from the observer list; matching only theLOhalf.Not run here: Win2025 (CPU-only Python change, no shader lowering).
AI-assisted; commands listed were executed locally.