shader: fold constant lane-mask bit tests #637
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!637
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/637/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?
@carbonimax on GitHub · 2026-09-16 13:15 UTC · original
carbonimax:fix/constant-lane-mask→main· +216 −44 · 2 files · 2 commits · closed without mergingConstant lane-mask tests such as
((0xffffffff >> (lane & 31)) & 1) != 0retained theirLaneIddependency after constant propagation. This caused a vertex shader to requireSubgroupLocalInvocationId, which MoltenVK cannot translate for a vertex function, even though these predicates were independent of the lane.Fold the low-bit test to 0 or 1 when the source word is uniformly zero or one and the shift count is proven to be within 0–31. Existing dead-code elimination then removes the unused lane query. Mixed or dynamic masks, other output bits, and unbounded shifts remain unchanged; other consumers of the shifted value are preserved.
Validation on Apple M4 Pro with the x86_64 build under Rosetta:
spirv-val --target-env vulkan1.3, and its graphics pipeline was created successfully by MoltenVK.0xe6. This change does not establish playability.This PR contains only the constant-propagation change and its tests; the startup fixes from #633 and #635 are separate.
AI assistance: DeepSeek generated the implementation and tests; Codex reviewed them, requested test corrections, and performed build, regression, SPIR-V, and game validation. An independent Codex review reported no correctness findings.
@coderabbitai[bot] on GitHub · 2026-09-16 13:15 UTC · original · edited 2026-10-10 22:51 UTC
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
df74cc72-06ff-43ab-a352-d34dd25859bf📥 Commits
Reviewing files that changed from the base of the PR and between d0d4787e3a4ed1b2cb6c53430290001c3532bc0c and c3ed65636f11d2f49e4d925a69c13f3074c53890.
📒 Files selected for processing (2)
src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpptests/ScalarProvenanceTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 3 remain after this review.
📝 Walkthrough
Walkthrough
The constant propagation pass now folds bounded shifted-bit tests for zero and all-ones words. New scalar provenance tests cover foldable cases and cases that remain lane-dependent.
Changes
Constant shifted-bit folding
src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cppBitwiseAnd32folding path detects bounded shifts below 32. It replaces qualifying tests with0or1for zero or all-ones words. Formatting-only changes are also included.tests/ScalarProvenanceTests.cppmain.Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Bug fix
Merge Risk: ⚪ Minimal · up to
c3ed6This change folds constant lane-mask bit tests so unused lane queries can be removed. The supplied evidence shows no actionable merge risk.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.@carbonimax on GitHub · 2026-10-14 07:36 UTC · original
Closing: main now covers this.
fa68e10(fold full wave64 masks before register predication) folds the uniform zero / all-ones lane-mask bit test in LaneMaskProjection, and the worklist pass (df08b83) removes the dead lane query. Applied on main without this PR's code, the zero and all-ones regression cases already pass; the only remaining difference is the commuted-operand form, which Translator::ThreadBit never emits.Pull request closed