shader: skip the f32 compare flush against a normal immediate #1565
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!1565
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1565"
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/fcmp-flush-bits→main· +49 −1 · 2 files · 6 commits · openSecond change for nmzik's idea in #1534 (after #1554). I merged main into this branch: since your
3a842e1athe denorm flush is a float compare and multiply, so I dropped this PR's bit-mask flush. What is left is the skip.Change (
EmitFloatCompare32,spirvEmitterInstructions.h): in a compute shader whose MODE flushes f32 input denormals (float_mode & 0x10clear, e.g. 0xC0), a V_CMP_F32 / V_CMPX_F32 whose other operand is an immediate that stays non-zero after the flush (normal, infinity or NaN) no longer flushes its register operand. Every denormal lies strictly between -2^-126 and 2^-126, so against such a constant it compares exactly like a zero, for every predicate. Compares against 0 and between registers are unchanged, and immediates are still flushed at compile time.Size
v_cmp_lt_f32 vcc, 0.5, v0with both values loaded from a buffer and float_mode 0xC0: 357 -> 321 SPIR-V words; the flush's four instructions (FAbs, FOrdLessThan, FMul, Select) are gone. Against 0 or a register the module does not change.So the gain is small. If you'd rather not take it, tell me and I'll close it.
Same results
TestNewShaderRecompilerF32CompareFlushSkipsNormalImmediate(shader_cfg_tests, not run by CI): no flush against 0.5, one against 0, two against a register. It fails on main (the 0.5 compare flushes v0) and passes with this change; the whole binary passes.12d411d4.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 (drivers 26.8.1 and 26.10.1, Windows 11).
🤖 Generated with Claude Code
@coderabbitai[bot] on GitHub · 2026-10-16 18:50 UTC · original · edited 2026-11-03 20:52 UTC
No actionable comments were generated in the recent review.
Walkthrough
EmitFloatCompare32now checks immediate operands for absolute bit patterns at or above0x00800000. It flushes non-immediate operands only when flushing is enabled and neither immediate meets that threshold. A regression test validates emitted SPIR-V for inline-zero, zero, VGPR, and literal operands, and checks their expectedFAbsinstruction counts.Suggested reviewers:
nmzikChange: Refactor
Merge Risk:
Low · up to
e3c19The change is otherwise supported, but the edge-case test should be added as follow-up to protect denormal flushing behavior.
Pre-merge checks:
4 ·
1
Full details: Docstring Coverage
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 1 files. (1 skipped: 1 too large.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
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
CodeRabbit Verify
9bb7b8d6-18bc-440d-95e5-242076c15c9fReviewing files that changed from the base of the PR and between
01c4522e1fande3c199e090.tests/shaderCfgTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
@coderabbitai[bot] on GitHub · 2026-11-03 19:54 UTC · original · reviewed
75990d97-b9d7-4218-8254-c225576bdbf2Reviewing files that changed from the base of the PR and between
12d411d427and01c4522e1f.src/graphics/shader/recompiler/backend/spirv/spirvEmitterInstructions.htests/shaderCfgTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.