Repository navigation
shader: lower uniform VCC branches and shared-target nested SAVEEXEC in mesh SAVEEXEC then arms (Part of #3703) - #3797
Conversation
lukaslw-lab
left a comment
There was a problem hiding this comment.
Reviewed 5655b237 by reading the diff; not built or run.
Verdict: comment. The uniform VCC branch is sound: inside a then arm EXEC is nonempty, so on a proven uniform mask (exec & sN) != 0 equals the lane's own bit, and the shared-exit child is limited to a parent that restores with s_mov_b64 at its alternate. No MUST, but the VCC path skips one of the arm's existing guards.
- SHOULD A VCC test never sets
scalar_branch. The scancontinues past thes_cbranch_vcc*(gfx1013_direct_mesh.inl:583-586) before theop.branch()bookkeeping at:609-612, somesh scalar branch crosses a nested SAVEEXEC region(:622) no longer applies to it. An arm with a VCC branch over a whole nesteds_and_saveexec_b64, a CMPX region or a shared-exit child now passes the scan. The SAVEEXEC lowering'sforward.upper_boundcheck only refuses an edge that lands inside the child, not one that jumps over it. No case covers that combination. Either record the jump inscalar_branch, or add a case where a VCC branch jumps over a nested SAVEEXEC and check its joins. - SHOULD
masked_vccalso lifts theallocatedandlane_elserefusals (:1410). No case has a VCC branch after the GS_ALLOC_REQ send or in an arm with a lane-split else. A positive case for each, or keeping those two refused, would pin it. - NIT The PR body lost its backticks, and
\t/\rescapes ate letters: "then" shows as a tab plus "hen", "release" as "elease". It also says it doesn't overlap #3782, which edits the same then-arm scan and conflicts textually with this head. Both add a second visit of the join address, hereshared_exitand therechain_closed, so whichever lands second can merge the two. - NIT
saveexec-nested-shared-inverseis refused asthen arm lacks an EXECZ skip. A message naming the inverse would say why. - Checked, no finding:
joins_skip_endchanged from!shape.resettoshape.join==exec_skip->end. For existing shapes this is the same value: a reset sits before its boundary, and a reset-less top-level join is the skip end.- The new VCC word clobbers at the join close a stale
vcc_wordsthatsaveexec-vcc-stale-branch-after-joinpins. - A branch into the test pair, its own
s_cbranchreached first, and a lane-varying mask are each refused.
Tests: checked_vcc_skip (vccnz, vccz, reverse operands, scalar compare, wave32), the local diamond and the then-exit case check the edge phis and the final select. saveexec-nested-shared-exit reuses checked_nested, and the refusals cover each match condition. CI ran native_direct_mesh in the pr preset at this head, green.
|
#3782 is now on main. Please rebase the shared SAVEEXEC scan and join handling on it and cover the reviewer's VCC-jumps-over-nested-SAVEEXEC case on the rebased head, or keep that combination refused. |
5655b23 to
7585f6b
Compare
|
@lukaslw-lab Thanks for the thorough review! Rebased onto
Re-verified on Windows 11 (
|
…in mesh SAVEEXEC then arms (Part of R0Y00#3703)
7585f6b to
a358540
Compare
lukaslw-lab
left a comment
There was a problem hiding this comment.
Re-reviewed a358540e (rebased on main 7069dfea, with #3782) by reading the diff; not built or run.
Verdict: approve. Both SHOULDs are closed, and the rebase merges the two join paths cleanly. No MUST, no open points.
- The VCC test now sets
scalar_branch(gfx1013_direct_mesh.inl:659), socrosses a nested SAVEEXEC regioncovers it again.saveexec-vcc-crosses-nestedand-crosses-shared-nestedpin both child forms. - I was partly wrong on the second SHOULD.
saveexec_skipalready runs after GS_ALLOC_REQ, andlane_elseis the paired arm'selse_begin, sosaveexec-vccnz-then-exitalready covered both.-paired-elseand-pre-allocnow name them explicitly. The newsaveexec_shapes.count(branch->start)term also keepsmasked_vccoff non-SAVEEXEC diamonds. - Checked, no finding:
shared_exit(:967) replaces #3782'schain_closed. It is!reset && !else_begin, which only the two shared-exit forms produce: a CMPX chain, and a nested SAVEEXEC whose EXECZ lands on the parent restore. Paired, if-only and top-level skip-end shapes all carry a reset or an else arm, so they do not revisit the join. The refusal message still names the form.- The split shared-exit refusals (
:500-503) are reached only when the target is the boundary. Top-level skips at the boundary keep the oldlacks an EXECZ skip. - The PR body is fixed.
Tests: the new crossing, gap, escaping-past-inverse, paired-else and pre-alloc cases each reach the changed lines. CI ran native_direct_mesh in the pr preset. At the time of this review the Windows job was still running at this head, and the gfx1013 job was green.
Part of #3703.
Lowers the unclaimed SAVEEXEC
then-arm patterns opened on #3703 insrc/gfx1013_direct_mesh.inl:Summary
thenarm:s_and_b64 vcc, exec, sN/s_and_b64 vcc, sN, exec(and wave32s_and_b32 vcc_lo, exec_lo, sN) immediately followed by a forwards_cbranch_vccnzors_cbranch_vccztargeting within thethenarm or its exit.Symbol::Type::uniform_maskormask_uniformcoveringlane_active) so per-lane branching agrees with hardware's wave-widevcc != 0test; lane-varyingv_cmp_*masks remain refused.(s_and, s_cbranch_vcc*)pair, records the jump inscalar_branchso VCC branches over nestedSAVEEXECregions remain refused (mesh scalar branch crosses a nested SAVEEXEC region), updatesSCCto match(exec & sN) != 0, clearsvcc(106,107),vcc_words, andvcc_nonempty(both at the test and inscalar_clobbersat the join) so stale whole-wave VCC state can never leak across theSAVEEXEC, and merges register state through the existing PHI machinery.masked_vccstrictly to activeSAVEEXECdiamonds (saveexec_shapes.count(branch->start)).s_and_saveexec_b64+s_cbranch_execzinside athenarm to target the enclosing arm's exit only when the enclosing arm restores its savedEXECdirectly (s_mov_b64 exec, sOuter).elseinverses (s_andn2_b64/s_xor_b64) and non-direct parent restores remain refused with explicit diagnostics (nested mesh SAVEEXEC cannot share exit with an enclosing inverse/nested mesh SAVEEXEC cannot share exit without a direct parent restore) because skipping the inner restore would route inactive inner lanes into the outerelsearm.#3782:SAVEEXECregions, saved-mask clobbers, and arbitraryEXECwrites remain strictly refused.#3782edit thethen-arm scan and add a second visit of the join address (shared_exithere vschain_closedin#3782), so whichever lands second will merge those two checks cleanly.Verification (source-built fixtures only)
Environment: Windows 11 (
26200.9974), MSVC19.44, Ninja, Windows SDK10.0.26100.0DXC, rebased ontoorigin/main(b7d61632, C++20 //W4).dev):ctest --preset dev --no-tests=error -R 'native_direct_mesh|native_direct_container' -V— 2/2 passed (native_direct_container14.20 s,native_direct_meshpassed; zero new/W4warnings).release):ctest --preset release --no-tests=error -R 'native_direct_mesh|native_direct_container' -V— 2/2 passed (native_direct_container11.55 s,native_direct_mesh11.72 s; total 23.48 s).git diff --check origin/main..HEADclean.AI-assisted.