Repository navigation
perf(shader): drop flushes of f32 results that cannot be denormal - #4278
Friesmaniac wants to merge 1 commit into
Conversation
The denormal flush eliminator now treats these values as denormal-free: - floor, ceil, trunc and round-to-even results, which are integral, zero, infinite or NaN; - square roots and reciprocal square roots, whose inputs the backend flushes first and whose results stay out of the denormal range; - min, max, min3, max3 and med3 of denormal-free operands, which the backend lowers to a selection of operand bits; - a value masked to its sign bit, and a value ORed with a constant that has an exponent bit set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thank you for your contribution! Authors with no pull requests merged into |
|
Thanks for reopening this. It no longer merges cleanly into current main. Could you rebase onto current main? Note that main already skips the denormal flush for floor/ceil/min/max, so after the rebase this PR only needs the cases main doesn't cover yet. We'll review and run full CI on the new head. |
|
Rebase of this PR onto current As the review noted, Windows 10 19045, WinLibs GCC 15.2.0, Release,
AI-assisted (Claude Code). |
|
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.
|
|
Fresh numbers on this PR (head
So this needs an explicit maintainer pick between the two open branches — rebase this one (superset + third test) and close #8958, or merge clean-merging #8958 now and close this one. Last branch commit here is dated 2026-10-11 with nothing pushed since, which keeps this the stale side of the pair. Pull any updated version forward if you intend to keep this route. |
|
@Friesmaniac This PR now conflicts with main in |
Rounding to an integral value, a square root, a reciprocal square root and an OR with an exponent bit cannot produce a denormal, so the flush after them is redundant. Rebased onto current main from #4278, keeping only the cases main does not cover yet. Co-Authored-By: Friesmaniac <181011464+Friesmaniac@users.noreply.github.com> Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
What
DenormalFlushEliminatorremoves the f32 denormal flush (and,iequal,and,select, 4 IR instructions) on values it can prove are not denormal. It now also recognises:FPFloor32,FPCeil32,FPTrunc32,FPRoundEven32: the result is integral, ±0, ±inf or NaN.FPSqrt,FPRecipSqrt32: the backend flushes the input first (EmitFlushF32DenormToSignedZero), and the result of a non-zero normal input stays at or above 2^-75 (rsq of the largest finite value is about 2^-64).FPMin32,FPMax32,FPMinTri32,FPMaxTri32,FPMedTri32of denormal-free operands:EmitMinMaxF32ValueandEmitFPMedTri32select operand bits, or the AND/OR of two zeros.BitwiseAnd32with0x80000000(always ±0), andBitwiseOr32with a constant that has an exponent bit set (the exponent stays non-zero). This covers the sign and signed-infinity arms thatunaryFloatSpecialsbuilds, so the flushes afterv_sqrt_f32,v_rsq_f32andv_floor_f32go away as well.FPFract32,FPRecip32and an OR with a mantissa-only constant (the IEEE-mode NaN quieting,| 0x00400000) are not treated as denormal-free; the tests pin that.Part of the compile-cost side of #2682: the issue lists the denormal-flush selects as one of the remaining large costs in float-heavy pixel shaders.
Tested
Windows 11 Pro, WinLibs GCC 16.1.0 (
x86_64-ucrt-posix-sehr4; not the supported 15.2.0 r7), Release withBUILD_TESTING=ON, NVIDIA GeForce RTX 4070 SUPER (driver 32.0.16.1714).agc_denormal_flush_eliminationhas three new cases. All three fail againstmain'sDenormalFlushEliminator.cppand pass with this change.ctest: 918 of 923 passed. The 5 failures are the Python tool tests (pr_overlap_encoding,progress_encoding,conventions_function_bodies,conventions_wrapped_declarations,check_skips), which failed to launch subprocesses with the interpreter available here (LibreOffice's bundled Python 3.12); no C++ code is involved.agc|shader|vector|recompil|scalar|pixel|interp, run on the RTX 4070 SUPER, all pass, includingagc_driver_f32_denormal_flush.python3 tools/check_conventions.py --base origin/mainandgit diff --checkpass.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code