shader: omit unused ordinary integer temporaries after validation #2471
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2479"
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 chadhyatt on 2026-11-25T18:00:02Z.
AI-assisted backport patch from x2w-microlift.
Omit unused fresh temporaries emitted by four ordinary integer operations (
s_xor_b32,s_lshl_b32,v_xor_b32,v_add_nc_u32) after the existing validation gates. Backward liveness retains predicates, masked joins, addresses, exports and their dependencies. The source-built controls distinguish dead and live results and preserve invalid modifier, unbound operand and early wait refusals.Tested revision:
677927084bcf2091c86d4fc510a716b460d5fcedon upstream1a0e506d30d.python -B tests/pixel_aot_check.py(Apple Silicon macOS, Python 3.15): exit 0, all portable controls passed.git diff --check 1a0e506d30d HEAD: exit 0.binarylane with LLVM 23 stopped at the unchangedcheck_f16_round_binaryexact encoding assertion forv_ceil_f16_e64 v1, v2(actual0100dcd502010102). The documented LLVM15 toolchain is unavailable locally; the supported LLVM15 binary lane and Windows GPU/CI validation remain pending. No fixture or coverage was weakened and no new rendering/benchmark claims are made.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T18:58:06Z.
Review: COMMENTED
Review of head
677927084(comment only, no merge yet).What I checked (Linux, worktree on this exact head):
python3 -B tests/pixel_aot_check.py: exit 0.python3 tests/docs_links_check.py,python3 tests/bidi_controls_check.py,git diff --check origin/main...HEAD: all clean.if False and dead_integer_candidates): the new check fails. Good.live.update(...)replaced bypass): fails with theasuint(alu20)assertion. Good.retained.reverse()indiscard_dead_integer_temporaries: the whole suite still exits 0. This is a real gap.Finding (blocks merge until fixed):
tests/pixel_aot_check.pycheck_dead_integer_temporariesuses only presence checks (exists,in source). Nothing checks the order of the kept lines. Withoutreverse(), the output has uses before declarations, which is an invalid shader. Please assert that each keptsalu/aludeclaration appears before the first line that uses it (for example comparesource.index(decl)withsource.index(use)for both live chains). This agrees with the earlier mutation review in this thread.first = next(iter(candidates))depends on dict insertion order.min(candidates)gives the same value today and is safe if an emitter ever marks out of order.Also open: the branch is 22 commits behind main (limit is 20), and there is no Win2025 WARP receipt for this head yet. After the test fix I can run update-branch, CI and Win2025 dev+release. The change itself (dead-code removal after validation, liveness rooted at all unmarked lines) looks correct to me.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T18:18:27Z.
Five mutations: four caught, and the survivor is a real gap the fixture's assertion style cannot see
Baseline:
check_dead_integer_temporariespasses, and it is wired into_CONTROL_SUBCHECKS(line 18822), which the controls runner executes — worth saying because I checked rather than assumed; a new subcheck that is defined but never listed would pass by never running.discard_dead_integer_temporarieslive.update(...)→pass, so every marked line is dropped)name not in live→name in live)INTEGER_TEMPORARYstops matchingsalu(onlyalu)retained.reverse()removedThe survivor is not equivalent — I checked before saying so
Calling the helper directly on five lines with two dead candidates:
So the mutation changes the emitted order —
usenow precedes nothing it depends on. That is a genuine behavioural change, and the fixture cannot see it because every assertion in the new case is a presence test:exists,in source, andsource.count(".Sample(") == 1are all order-insensitive. A one-line fix closes it: aftertranslate_int(live), assert that each retained declaration precedes the first line that mentions it — e.g. comparesource.index(name)againstsource.index(use)for the two retained chains, or assert the emittedsalu…/alu…indices are strictly increasing.This matters more than a typical unasserted detail: the helper rewrites a whole statement list after validation, so a reversed result is not a wrong value but a structurally invalid program — the pure-Python control is the only place that can catch it before a renderer does, and right now it cannot.
What the four caught rows establish
They are the four ways this helper can go wrong in principle: drop too much (liveness never grows), drop exactly the wrong half (skip inverted), miss one naming scheme (
saluvsalu— the two emitters atpixel_aot.py:4347and:5240), and start scanning before the marked region. Each is caught, so the fixture is testing the algorithm and not just the happy path. The two-emitter case is the one I would have expected to slip, sincesaluandalucome from different call sites.One note on the docstring
"Remove only emitter-marked, single-assignment locals after validation" is the right contract, but
first = next(iter(candidates))relies on dict insertion order matching emission order — a fact stated only in a comment ("Emit sites mark candidates in line order"). If a future emitter marks out of order,firstsilently becomes the later index and earlier dead lines are kept. Cheap hardening:first = min(candidates), which is the same value today and no longer depends on insertion order.AI-assisted; the five mutations and the order probe were run locally on Windows 11 build 26300.9974.