Repository navigation
Shaders: walk a predecessor's live-out registers once instead of searching it per register - #2520
liandraraiane wants to merge 1 commit into
Conversation
…ching it per register The IR's renaming looked up every live register in its predecessor's sorted live-out list by binary search, and again for every phi argument. Both sides are in register order, so one walk along the list serves them all; the live-out lists are also sized before they are filled. New ir_build benchmark (synthetic, no title files or GPU), median: 128 registers, 500 divergent ifs: 10.5 ms -> 7.6 ms 128 registers, 2000 divergent ifs: 47.2 ms -> 36.0 ms The built IR hashes the same as on main for the benchmark's programs. Tested on Ubuntu only (cargo test -p victory-shader --lib: 144 passed). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Verification (Windows 11, WARP/CPU only) — head Tested: the PR head, which is
The 2 failures are the WARP baseline: Bench (single run each on this machine, so only indicative; the PR's bench file copied onto
Diff read: AI use: Claude Code (Claude Sonnet 5.5). |
|
Automated triage for the maintainers. In The speed-up is measured on synthetic programs only (about 25 % with 128 live registers). The gain on real translations is not measured. CI: Generated by Claude Code |
|
On an Apple M1, the full IR dump matched byte for byte between
I built each commit separately on macOS 14.7 with native Rust 1.98.1 (dev profile). I passed the same synthetic instruction words to Both fixtures carry |
… once instead of searching it per register
fuzeofficlal
left a comment
There was a problem hiding this comment.
Reviewed and verified against main (63bcca43) on Windows 11 — clean optimization and ready to merge (note: overlaps with #2957 which replaces ir.rs's SSA builder):
Reg's derivedOrd(S(0..127) < Scc < V(0..255)) matchesindex(reg)andmembers()enumeration order, soouts[p]andblock.phisare strictly ascending and the two-pointerlookup_from(&outs[p], &mut walk, reg)walk cannot miss any live-out entry.
Local verification:
cargo test --locked -p victory-shader --lib -- ir::: 9/9 passedcargo bench --locked -p victory-shader --bench ir_build: ran cleanly (2.38ms–29.22msacross 8..128 regs / 500..2000 ifs)cargo clippy --all-targets -- -D warnings+cargo xtask policy(192 files ok): 0 warnings
… once instead of searching it per register
…ut registers once instead of searching it per register
The IR's renaming looked up every live register in its predecessor's sorted live-out list by binary search, and again for every phi argument. Both sides are in register order, so one walk along the list
serves them all. The live-out lists are also sized before they are filled.
Change:
crates/victory-shader/src/ir.rs(build_bounded), plus a newir_buildbenchmark.Measurement
cargo bench -p victory-shader --bench ir_build(synthetic programs, no title files or GPU), median of 9, release build:With 8 registers the change is within noise.
Tests
cargo test -p victory-shader --lib: 144 passed, 2 ignored (Ubuntu 24.04).mainfor the benchmark's programs.Not tested
clippy -D warnings, GPU tests).AI use
Claude Code (Claude Sonnet 5.5) profiled, wrote the change and the benchmark, and drafted this description. A person reviewed it and opened the PR.