Shaders: a lane-mask operation's SCC read as data is whether some lane is set #1334
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1334
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1334/head"
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?
@KainanP on GitHub · 2026-11-24 17:31 UTC · original
KainanP:shaders/mask-scc-any-lane→main· +541 −1 · 3 files · 1 commits · closed without mergingWhat
A scalar lane-mask operation (
s_and_b64of a compare with EXEC,s_xor_b64 …, exec,s_and_saveexec_b64, …) sets SCC when its result is not zero (RDNA 2 ISA, S_AND_B64:SCC = (D != 0); S_AND_SAVEEXEC_B64:SCC = (EXEC != 0)). Branches on it already lowered, per lane. Every other read stopped witha lane mask read as data, for examples_cselect_b32 s6, 1.0, 0, or the uniform-branch idioms_cselect_b64 vcc, exec, 0+s_cbranch_vccnz, whose select becomes a uniform atom.structurerecords such SCC values inStructured::any_lane, with the result's per-lane bit. It does so only when the result is set in no lane except those running there: it implies EXEC at that point, and it is clear in the lanes outside EXEC on entry. A newLanes::cleartracks the second condition (compare and carry results;and,andn2/andn1,or/xorwith EXEC keep it).s_not,s_orn2and XOR with -1 set bits for lanes that never ran, so they stay refused, and so dos_wqmresults.lowerreads such an SCC asdx.op.waveAnyTrueof the bit, taken where the operation runs.s_cmp_lg_u64 m, 0already does there.Relation to other PRs
#309 contains a compute-only version of this (its
mask_scc), as one hunk of the spill-forwarding change. This PR does not depend on spills and also covers pixel and vertex programs, which #309 leaves refused. It also checks the lanes outside EXEC on entry, so a complement of a compare (s_not_b64 s, vcc) at the top of a program is refused rather than counted wrongly, and it declares the wave size in compute. Whichever lands first, the other drops or rebases its version. It does not overlap #878 (s_bcnt1's SCC for branches), #1073 (mask/number joins), #298/#1074 (spilled masks), #1084/#585/#1221 (selects on untracked masks), #269 (mask set operations as numbers) or #434/#145 (ballot halves on 64-lane hosts).Tests
All words are assembled with llvm-mc (gfx1030); no game data.
valu_tests::the_scc_of_a_mask_operation_is_whether_some_lane_is_set(GPU): one wave32, with 32 and with 24 threads (8 lanes outside EXEC from the start), 10 (k, j) cases. It coverss_and+s_cselect, the uniform-branch idiom,s_and_saveexec's SCC, ands_and/s_xorwith EXEC inside a branch only some lanes take. It fails onmainwitha lane mask read as data. It is skipped on devices without 32-lane waves.lower::tests::the_scc_of_a_mask_operation_is_whether_some_lane_is_set: wave64 and wave32 pixel programs (s_and/s_xor/s_andn2with EXEC, both readers) lower and passdxil.dllvalidation. They fail onmain.lower::tests::the_scc_of_a_mask_holding_lanes_elsewhere_stays_refused:s_not_b64,s_xor_b64 …, -1,s_orn2_b64still refuse.Results:
cargo test --workspace --lockedon Windows 11 with an RTX 4060 Laptop as the default adapter: 345 passed, 0 failed, 6 ignored (victory-shader: 123 passed, 1 ignored).cargo clippy --workspace --all-targets [--all-features] --locked -- -D warnings: clean.cargo xtask policy: 154 files ok.Not measured
I did not run this on the title's shaders, so I can't say how many of the
a lane mask read as dataprograms it unblocks. Avictory translate --validatebefore/after would show it.Known limits
AI use: Claude Code (Claude Opus 5.5) chose the target after reading the open PRs, wrote the change and the tests, and ran everything above. Reviewed and re-tested locally before opening.
🤖 Generated with Claude Code
@rezioliver-collab on GitHub · 2026-11-24 18:11 UTC · original
I ran an offline A/B comparison of
ffe310eand0f2c09bon Windows 11 with Rust 1.98.1 (MSVC) anddxil.dll1.8.2502.11. I reused two baseline runs after verifying that the archive and validator matched by SHA-256, then ranvictory translate --validate --list --jobs 1twice on the PR with the same localshaders.rpf.Each run processed 26,503 containers and built IR for 26,084 native programs. All 25,889 listed outcomes matched by archive offset and shader stage. Both revisions validated 21,724 shaders, with zero validation gains or losses.
The same 250 shaders still reported
a lane mask read as data.The related
a lane mask holding lanes elsewhere read as datacount also stayed at 272.For the synthetic check, I copied only the PR's two SCC test fixtures into a separate baseline checkout. The positive test reproduced
a lane mask read as dataon the first Wave64 AND followed by a scalar select. On the PR, all 12 combinations passed, covering Wave32 and Wave64, AND/XOR/ANDN2, and SCC consumed by a scalar select or uniform branch. The test that checks rejection of masks with bits outside entry EXEC passed on both revisions.cargo xtask policypassed on both.AI use : Assisted by GPT 6.2 Sol.
@KainanP on GitHub · 2026-11-24 18:15 UTC · original
Thanks @rezioliver-collab, this is exactly the measurement the PR was missing ("Not measured" above).
So the title never reads the SCC of a lane-mask operation as data: all 250
a lane mask read as dataprograms stop somewhere else. Inlower.rsthat refusal has three sources:mask_dwordon a value that isn't a tracked mask, a scalar op writing EXEC or a tracked mask thatsopdoesn't handle, and the VOPC/carry results left asVal::Missing. This PR only touches a fourth path that the shaders don't use.A change that unblocks nothing in the title isn't worth review time here, so I'm closing it. The parts that might matter later (
Lanes::clear, the pixel/vertex any-true) are in the branch if someone needs them.Written with the help of an AI (Claude Code).
Pull request closed