Repository navigation
gfx2hlsl: compute exec-write clear shapes and join writes once - #2535
Conversation
The exec-write pass parsed the same instruction text once per visit and join_writes rescanned every instruction for every branch. Cache the parse and the clear shape per text, and compute the written registers once. Three large compute requests: 19.1 s -> 8.4 s, same refusals. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
tedin7
left a comment
There was a problem hiding this comment.
Review of head d064cf7 against current main (comment only).
Checked, by reading the diff against the old code:
clear_shape: same decisions as the old inline code (v_cmpx, no-match or saveexec-mov -> no fact, wrong word count or unparsable operand -> no fact). Only the facts that depend on the currentclearset (halves) stay inclear_after. The cache key (name, asm) is a pure function of the text.join_writes: written registers are computed once per instruction (including thes_movreldall-registers case andm0). Thebisectranges match the old conditions: backwardtarget <= off <= branch, forwardbranch < off < target. This relies onself.insbeing in ascending offset order, whichdecodegives. The target key is still created for an empty range, as before.- Scope is one file, no behaviour change intended; no game or startup-progress claim.
Commands run (Linux):
python3 -B tests/startup_translator_check.py0 failedstartup_gfx2hlsl_loop_constants_check,startup_gfx2hlsl_join_symbols_check,startup_ngg_slice_checkpasspython3 tests/docs_links_check.py,python3 tests/bidi_controls_check.py,git diff --check origin/main...HEADclean
Gap (not a blocker, this is a speed-only refactor): two mutations of join_writes (range start moved by one; all written registers dropped) were NOT caught by startup_translator_check, startup_gfx2hlsl_join_symbols_check, startup_gfx2hlsl_loop_constants_check or startup_gfx2hlsl_compute_check. The existing checks do not pin the exact join sets, so the byte-identical refusal comparison in the PR body is the main evidence. A small direct test (join set for one forward and one backward branch) would be a good follow-up.
AI-assisted; commands listed were executed locally.
|
Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
AI-assisted; commands listed were executed locally. |
|
Self-review follow-up, pushed as 4251ccd: Run at 4251ccd, Windows 10.0.26300, Python from python -B tests/startup_translator_check.py # startup translator checks: 0 failed
python -B tests/startup_gfx2hlsl_<each>_check.py # every no-argument check exits 0
git diff --check # cleanThe three large requests from the description still take 5.83 s with the assert (5.65 s / 5.76 s before it). Not checked: equality with |
What changes
tools/startup/gfx2hlsl.pyonly, no behaviour change. The exec-write dataflow that #2509 added is slow on large compute programs:clear_afterre-derived the same facts from the instruction text on every visit. The per-instruction shape is now computed once per text (clear_shape, cached).join_writesrescanned every instruction for every branch. The written registers are now computed once per instruction and each branch takes its range withbisect.Measured
Commit under test: the head of this branch, against
mainat its merge base. Windows 10.0.26300, Python 3 fromout/pe-env. Input: three large locally captured compute requests (counts only), each translated once after a warm-up request, two runs per side.mainThe refusal files written by both sides are byte-identical.
Tests
Not checked
llvm-mcor a D3D12 device were not run: the change does not touch what they cover beyond the translator output, which the no-argument checks compare.🤖 Generated with Claude Code