shader: track both VCC halves for unsigned MAD64 carry #2979
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2979"
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-27T01:52:35Z.
The decoded
v_mad_u64_u32VOP3B carry-out uses the same wave64 lane mask convention as unsigned add/subtract. Include it in the high-half may-write classification so a stale clearvcc_hifact cannot survive the skipped-block proof. Preserve discarded/signed admission and rotate the paired graphics/compute cache keys.Verification on Apple Silicon macOS, tested commit
3286a2630932007d67f906f5f6b7febbf1d2f7edagainst6ee878d8: all passed withpython3 -B tests/startup_gfx2hlsl_mad64_check.py,tests/startup_shader_cache_key_check.py,tests/startup_compute_request_offline_check.py,tests/startup_gfx2hlsl_buffer_store_check.py,tests/startup_packed_position_provenance_check.py,tests/startup_gfx2hlsl_fract_check.py, andtests/startup_shader_cache_rekey_check.py. The MAD64 controls cover 1,400 arithmetic rows and stale-fact/adjacent/null controls; new graphics key vectors were independently computed with C++. No Windows or GPU execution claimed in this run.AI-assisted backport patch from x2w-microlift.
Imported from R0Y00/Xbox2Windows. Originally posted by thepatrickworld on 2026-11-27T02:31:19Z.
Portable check of
3286a263on Linux: the new control bites, and one link stays unpinnedEnvironment
No GPU on this host (my Windows machine is unreachable this cycle), so this is the portable half only: no draw, no DXC, no adaptor, no debug layer. Linux x86-64, Python 3.11.16, a fresh clone, worktrees at
3286a263(head) and6ee878d8(base).git status --porcelain --untracked-files=nois empty at head; the base worktree is that commit untouched, and the only file it carries is the fixture copied in for the negative control below.sha256(tools/startup/gfx2hlsl.py)at head:3d793b4ae08b6c3dacae643aed4211d9cd7af7a8f9ce9b686846bc9013d96f1f.Commands and observed
The six Python fixtures the diff touches, plus
startup_shader_cache_rekey_check.pywhich the body names, in their no-argument mode at head. All exit 0.The new control bites
With the head fixture copied onto the base translator and nothing else changed, the may-write table fails on its first row and the run stops there:
That assert ends the run, so the join case is never reached in that pass. Measured directly against the base helpers, with
start = {('exec', 0), ('exec_hi', 1), ('vcc_hi', 0)}:Mutants of the fix
One line at a time, each edit applied once,
sha256of the file recorded before and after,git status --porcelain --untracked-files=noempty aftergit checkout --:'vcc' in writesguard for the mad64 is killed by thenullrow:... null ... may-writes no VCC half: MISMATCH;vcc_hiinwritesinstead ofmayis killed by thevcc_lorow:... vcc_lo ... may-writes vcc and vcc_hi: MISMATCH;v_mad_i64_i32to the tuple survives, and no accepted form changes behaviour:scalar_effectsthen reportsmay = {'vcc', 'vcc_hi'}for a signed mad64 with avcc_lodestination, butmad64()refuses that form (only null is lowered), so it never reaches the analysis.Scope of the prefix list:
v_addc_co_u32andv_subb_co_u32have noop_handler and are refused;v_mad_i64_i32is accepted only withnull, so its real carry destination is refused. Within the forms this translator accepts, the prefixed set is the one that can reachmay.add('vcc_hi').One link the fixtures do not pin
execz_refusalsfeedsclear_afterthe third element ofscalar_effects(gfx2hlsl.py:2941,clear_after(*self.ins[i][2:], effects[i][2], before[i])). Passing the second one,writeswithoutmay, is not equivalent: for the same('vcc_hi', 0)fact,clear_afterthen keeps it acrossv_cmp_gt_u32 vcc_lo, acrossv_add_co_u32 vcc_loand across this mad64.The new control cannot see that, because it calls
clear_afterdirectly withscalar_effects(...)[2]and never goes through the call site; that mutant survivesstartup_gfx2hlsl_mad64_check(rc=0) andstartup_gfx2hlsl_vcc_hi_check(PASS). Separately, no exit code changes across the 277tests/startup_*.pyrun in no-argument mode (0 rc changes; 76 were already non-zero at baseline), so no existing fixture's status pins it either. That last measurement compares status only, not failure text.The shape where a
('vcc_hi', 0)fact can exist is not out of the model's reach:wave32_vcc_hikeepsvcc_hispelled asvcc_hion two of the four two-instruction texts I fed it,s_mov_b32 vcc_hi, 0followed byv_cmp_gt_u32 vcc_loor by this mad64, and does not raise there, where it renames the same write tos_mov_b32 s105, 0when nothing else names VCC. I did not assemble a program where such a block is skipped bys_cbranch_execz, nor run the translation end to end, so this does not show that a real shader produces the fact, only that the text reaches the model.Where the checks run
startup_gfx2hlsl_mad64_check.pyis in thepython-linuxjob's script list (windows.yml:358, ubuntu-24.04, noif:and nopaths:on that job), so these controls run on every pull request. The ctest entry is not in theprpreset's include regex, so the ctest path does not reach it before merge; the Python job does.Limits
One host, no GPU, no draw, no DXC, no debug layer; nothing here says the translated mad64 is right on an adaptor, and the draw evidence stays where the body left it. The two C++ tests the diff touches carry the cache revision only and were neither built nor run here.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by chadhyatt on 2026-11-27T02:32:39Z.
Thanks, the independently reproduced negative control confirms the intended table change. The missing call-site coverage is a useful distinction; I will add a source-built end-to-end execz control if the actual supported pipeline can express the fact, without changing the lowering or overstating adapter verification.
Imported from R0Y00/Xbox2Windows. Originally posted by KelboLive on 2026-11-27T04:17:15Z.
Review: COMMENTED
Important nuance — the wave64 skipped-block liveness proof needs both VCC halves tracked for unsigned VOP3B carry-out. A discarded carry doesn't invalidate either half, but the proof must not let a stale clear
vcc_hifact survive a skipped-block join.Findings
✅ What works well
v_mad_u64_u32carry-out withvcc_lomay also writevcc_hiin the wave64 convention. The discarded carry doesn't invalidate either half — the high-half clear fact from the previous block can survive through the join without being invalidated by a discarded carry.docs/experiments.mdupdate: Adds one clear sentence in the mad64 section documenting the VCC half tracking nuance. Consistent with the existing documentation style.startup_gfx2hlsl_mad64_check.py), shader cache key check, compute request offline check, and rekey check — all pure-Python, runnable on Apple Silicon. Good regression prevention.⚠️ Minor observations
startup_gfx2hlsl_mad64_check.py: The PR says this "verifies these effects and the clear-fact transfer at a skipped-block join." If this test is new or changed, consider whether it was run against a baseline where both VCC halves were NOT tracked (to show the before/after difference). A note in the PR body about what the test specifically validates (e.g., "the test creates a skipped block after a mad64 with discarded carry and checks that vcc_hi remains clear") would help reviewers who aren't deep in the skipped-block proofs.Scope: The PR mentions "preserve discarded/signed admission" — the signed form's
nulldestination behavior is unchanged. This is correctly documented in thedocs/experiments.mdentry which notes "The signed form's admitted null destination is unchanged."Recommendation
Looks ready. Clean doc update with the necessary behavior change for the skipped-block proof.
🏷 If the skipped-block proof framework gains more VOP3B carry-out instructions in future PRs, consider whether these VCC-half tracking rules should be centralized in a shared data structure rather than scattered across individual instruction handlers.
Imported from R0Y00/Xbox2Windows. Originally posted by chadhyatt on 2026-11-27T04:18:39Z.
Thanks. The independent baseline result in thepatrickworld’s earlier comment confirms the new VCC-half control fails on the pre-change translator and passes at this head, including discarded-carry preservation. The helper-level transfer is pinned; no claim of additional end-to-end skipped-block coverage or GPU execution. Ready from my side.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T05:00:52Z.
Review: APPROVED
Reviewed
3286a2630932007d67f906f5f6b7febbf1d2f7ed. The may-write proof now covers both VCC halves for unsigned VOP3B carry, and both C++ and Python request seeds were bumped together. In a Release merge trial with main57f9e07f, the MAD64 controls and WARP/hardware readbacks, shader cache key, offline compute request, stream draw and compute dispatch passed. The new helper-level control covers the stale-high-half proof; the draw fixtures cover the existing lowering. Independent Windows 11 26200.9974 testing used WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656 where applicable. Required Windows CI passed.Imported from R0Y00/Xbox2Windows. Originally posted by chadhyatt on 2026-11-27T05:02:00Z.
Thanks for the exact-head merge trial and Windows controls. Recorded the approval, including both request seed updates and the stale-high-half proof; no further changes from my side.