Repository navigation
perf(shader): drop the result flush of a product behind its tiny-product check - #7212
Merged
oneandonlydean merged 1 commit intoOct 18, 2026
Conversation
…uct check A v_mul_f32 in a FLOAT_MODE that flushes f32 denormals emits the nearest-even tininess check, the NaN result selection and then a result flush. The check already turns every product that rounds below 2^-126 into a zero of its sign, so the flush can't change what it keeps. DenormalFlushEliminator now proves that: a select arm guarded by the tiny-product check of the same denormal-free factors, an arm a select takes only when its own bits are NaN, and an and with a mask that has no significand bits are denormal-free. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
11 tasks done
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
TheBlenDed
pushed a commit
to TheBlenDed/AnyPS5
that referenced
this pull request
Oct 25, 2026
…oykopovar#7218, BDA range index) AI-assisted: yes
Pipodi
pushed a commit
to Pipodi/AnyPS5
that referenced
this pull request
Nov 14, 2026
…oykopovar#7218, BDA range index) AI-assisted: yes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
In a
FLOAT_MODEthat flushes f32 denormals (0xc0, which most titles use), eachv_mul_f32andv_mul_legacy_f32is translated as:flushTinyProduct(one factor times 2^64, the product compared with 2^-62);nanResultF32;writeOperand.The check already turns every product that rounds below 2^-126 into a zero of its sign. So when both factors are denormal-free, a product it keeps is zero, infinite, NaN or at least 2^-126 in magnitude. That holds as long as the driver rounds the product the same way as the check's own multiply, which the check already relies on (see the f32 denormals debt entry). The result flush can't change such a value, but
DenormalFlushEliminator(#2103) couldn't prove it and kept it. Every suchv_mul_f32result therefore carried a flush.DenormalFlushEliminatornow also treats these as denormal-free:(x & 0x7fffffff) > 0x7f800000orFPIsNan32, with or without the IEEE-mode quieting| 0x00400000), which covers the arms of the NaN result chain, including perf(shader): pick the f32 NaN result with one quiet and one fallback select #4287's form;andwith a mask that has no significand bits (the sign-of-zero arm).The comparison and subtraction matchers take the immediate only on the right, so
0x7f800000 > |x|is not read as a NaN test. A short debt entry records the rounding assumption next to the existing one.Tested
Linux (Ubuntu 24.04, GCC 13.3, Release), RTX 4070 Ti, NVIDIA 595.99.02;
main66702f1.agc_denormal_flush_elimination, 4 new cases:FPIsNan32) loses its flush; one under another value's test, or under the reversed comparison, keeps it;v_mul_f32recompiled end to end (wave32) keep one f32 exponent mask, the first source's input flush.With
main'sDenormalFlushEliminator.cppall four fail (the end-to-end case finds 3 masks). With this change they pass 3 of 3.ctest
^agc_(662 tests, NVIDIA): all pass.On an Intel Arrow Lake iGPU (Mesa 26.1.6 ANV), the 104
^agc_tests whose names cover f32, f16, NaN, denormal, mul, fma, mad, div, clamp and rounding: 103 pass.agc_driver_sample_multisample_targetfails the same way onmainthere; test(agc): skip the multisampled target test without storage image multisampling #7191 addresses it.SPIR-V words with
agc_shader_replay,mainagainst this change, over every draw request dumped in a cold run:mainwordsNone got larger.
NVIDIA build time of Afterglow's largest fragment shader as a pipeline library part (2,167,462 words on
main, 2,011,453 with this change). The timer is local, around thatvkCreateGraphicsPipelinescall. Cold cache, alternating builds:main: 24.9 s and 24.9 s;The title still exits on a cold cache: its own watchdog stops waiting for that submission after about 2 s.
Frame summary on Afterglow, warm caches. Each build ran once, then again with
APS5_TRACE_SECONDS=20:15, same pad script. Both builds carry the local part timer, hencedirty. The title presents at 60 Hz, so frame time doesn't move. GPU time per present went from 6.88 to 6.66 ms, one capture each, which is within what I'd expect from noise. MXGP 26 and Super Meat Boy 3D gave no capture on either build. MXGP's warm runs abort on the computeds_swappc_b64of AGC: MXGP 26 (PPSA30839) aborts on a compute shader that calls a function pointer read through a V# at the fixed address 0xF_E0040000 #6117, and Super Meat Boy 3D doesn't present within 90 s here. The two traces can be attached on request.check_conventions.pypasses.pr_overlap.pylists onlydocs/dev/debt/shader.md; the new entry is its own line and merges without conflict with each listed PR wherevermaindoes.Not checked on Windows, on AMD, or on a console.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code