shader: skip selection constructs whose condition is constant true #1566
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!1566
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1566/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?
@Nawid3333 on GitHub · 2026-10-16 18:46 UTC · original
Nawid3333:shader/skip-constant-true-selections→main· +14 −0 · 2 files · 3 commits · closed without mergingAnother one for nmzik's idea in #1534.
EmitIfConditionandEmitValueOrDefaultIfConditionemitted a selection (OpSelectionMerge,OpBranchConditional, two labels,OpBranch, andOpPhifor a value) also when the condition is the constant true, as it is for memory accesses whose EXEC condition folds to true. With this change the body is emitted in the current block instead.Size (compute suite at
3ff6606f, 680 modules)AMD's compiler already removes these branches: compiled with the driver (26.8.1), the ISA of 8 suite modules on an RX 9070 XT and 7 on a Ryzen 7600X iGPU is identical instruction for instruction (other vendors not tested). So this makes the SPIR-V smaller (e.g. 59,480 -> 46,940 bytes for
DsIncReturnGdsBoundaries), not the GPU code faster.Same results
3ff6606fon both GPUs: all 698 compute-suite entries, also with the harness forced to 32-wide subgroups (a local switch), and the 26 graphics cases plus 16 production raster checks give the same status and first mismatch as before.If you'd like this done differently, tell me and I'll change it.
Written with Claude Code (AI): it wrote the change and ran the tests and measurements on my PC (driver 26.8.1, Windows 11). I reviewed the diff and this description before opening the PR.
🤖 Generated with Claude Code
@coderabbitai[bot] on GitHub · 2026-10-16 18:51 UTC · original · edited 2026-10-17 12:51 UTC
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
f6eac878-ac71-4255-b60d-74b0fc1072f0📥 Commits
Reviewing files that changed from the base of the PR and between
d785298dd6andb6491be831.📒 Files selected for processing: 1
tests/shaderCfgTests.cpp🚧 Files skipped from review as they are similar to previous changes: 1
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.
📝 Walkthrough
EmitIfConditionandEmitValueOrDefaultIfConditioninvoke their callbacks directly when the condition equals constanttrue. Other conditions retain their existing conditional branch paths. The shader test sets a lane-dependent EXEC mask before a buffer load and checks that the emitted guard condition is neither constanttruenor constantfalse.Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Refactor
Merge Risk: ⚪ Minimal · up to
b6491The condition-handling change and its guarded-load test have no identified issue that needs resolution before merge.
Pre-merge checks:
5
Full details: Docstring Coverage
Explanation
No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files. (1 skipped: 1 too large.)
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.@coderabbitai[bot] on GitHub · 2026-10-17 12:40 UTC · original · edited 2026-10-17 12:52 UTC
On
tests/shaderCfgTests.cppline 10450 (outdated):🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 11253
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 9595
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 10700
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 7026
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 937
Use a runtime-dependent VGPR comparison.
v3andv2are untouched beforev_cmpx_gt_u32 v3, v2. The SSA pass initializes an untouchedVectorRegto zero, so this comparison is constant false. The test does not exercise a runtime-dependent EXEC mask.Use a runtime-dependent VGPR value and assert that the EXEC branch condition is nonconstant.
✅ Addressed in commit
b6491be@coderabbitai[bot] on GitHub · 2026-10-17 12:40 UTC · original · reviewed
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
4a24e7e5-14be-4e82-aa8b-1906c28402d6📥 Commits
Reviewing files that changed from the base of the PR and between
c92b067e66andd785298dd6.📒 Files selected for processing: 1
tests/shaderCfgTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
@Nawid3333 on GitHub · 2026-10-17 12:43 UTC · original
On
tests/shaderCfgTests.cppline 10450 (outdated):Right, both start as 0, so EXEC was a constant false. Fixed in
b6491be8: v3 is now the lane index (v_mbcnt_lo_u32_b32 v3, -1, v2), and the test checks that the guard condition is not a constant. That check fails without thev_mbcnt.@coderabbitai[bot] on GitHub · 2026-10-17 12:52 UTC · original
On
tests/shaderCfgTests.cppline 10450 (outdated):@Nawid3333 Thanks for the fix. The supplied code now makes the EXEC condition lane-dependent and checks that the guard condition is nonconstant. This addresses the finding.
If you found this review helpful, would you consider giving us a shout-out on X?
Thank you for using CodeRabbit!
✅ Review thread resolved.
You are interacting with an AI system.
@Nawid3333 on GitHub · 2026-10-24 18:36 UTC · original
Closing:
mainhas this since0f7d1125("emit constant-true guarded blocks inline and fold immediate constant-buffer indices"), which adds the same constant-true early returns.Pull request closed