Recompiler: skip unused scalar-load analysis for direct compact emission #2746
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl#2746
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@KOLESNiii on GitHub · 2026-11-26 09:47 UTC · original
Part of #2088 and #2508. Reviewed on
mainatb49be18.After deciding to produce compact direct DXIL,
translate_on_this_threadstill callsreload::analyze(&cfg)for compute and kernel entries. Only the ordinary block loop readsreloads, and that loop runs only whenplan.is_none(). Compact emission lowers its representative blocks separately. The discarded analysis scans the original CFG and runs a fixed-point pass. Call and compact emitter · Only consumer · Fixed-point analysisA standalone optimized Rust probe on Linux, AMD Ryzen AI 7 350, used XCL's decoder, CFG construction and reload analysis, and extracted the compact-planner code. Three synthetic scalar programs each had 32,769 decoded instructions and 8,193 reachable blocks. The automatic planner selected compact in each case. Median analysis time over five passes per program was 91 ms, 689 ms and 1,370 ms for 16, 128 and 256 distinct load addresses. These timings are for the analysis alone on synthetic input. Whole-translation, Windows and retail effects remain unmeasured.
Move reload analysis inside the ordinary-emission branch or guard it with
plan.is_none(). Keep plain-code reload reuse and compact code generation byte-for-byte equivalent on synthetic fixtures. A compact translation timing with the translated cache disabled can quantify the benefit on a workload that uses the path. Related scalar-load work in #2464/#2479 changes the analysis itself.AI use was OpenAI Codex (GPT-6, exact serving variant unavailable) for static analysis, the standalone Linux probe and drafting.
@KOLESNiii on GitHub · 2026-11-26 10:45 UTC · original
Windows probe on
mainatb49be183: confirmed, and on these inputs the discarded analysis is most of the whole compact translation.Setup
--release(optimized + debuginfo). Run alone on the machine, nothing else on the GPU or CPU.#[cfg(test)]probe inside the crate, not committed. It builds synthetic wave32 kernels of 4,096 units[s_load_dwordx4 (offset k), s_add, s_add, s_cmp, s_cbranch_scc1 +2] [s_add, s_add]pluss_endpgm: 28,673 decoded instructions and 8,193 reachable blocks, with 16, 128 or 256 distinct load offsets.translate_full,XCL_DIRECT_COMPACTunset) gives the same bytes as forced compact (translate_full_as(.., true)). It does for all three, and the log showsdirect DXIL compact form: 8193 blocks of 18 / 130 / 258 kinds.reload::analyze(&cfg)on its own and the wholetranslate_full_as(code, o, true)call (which, onmain, includes that analysis). Medians of 5 passes.reload::analyzeThe cost scales with distinct addresses × register-writing instructions: for every scalar write,
stepchecks every slot against all 128 registers.Caveats
reloadsis the plain block loop (kernel.rs:372), which runs only whenplan.is_none().compact.rsnever refers toreload, andlw.reloadstaysNoneoutside that loop. So guarding the call withplan.is_none()can't change compact output. I'll check that the bytes stay identical with the same probe.I'm preparing a PR that guards the call.
AI use: Claude Code, Claude Opus 5.5. It wrote the probe, ran it on the hardware above and drafted this comment.