This repository was archived by the owner on Oct 28, 2026. It is now read-only.
Repository navigation
Conversation
With f32 denormals flushed, a product was checked for tininess on its exact value, from the factor exponents and a UMulHi of the significands. RDNA2 detects tininess after rounding to 24 bits with an unbounded exponent, as measured on gfx1036 for v_mul_f32 and v_mullit_f32: 0x3f7ffffe * 0x00800001 gives 0x00800000 there and gave 0 here. One factor is now multiplied by 2^64, which is exact below 2^64, and the product with the other factor, rounded once to 24 bits in the normal range, is compared with 2^-62 on its magnitude bits. A zero product is still not tiny, and a factor of 2^64 or more can't give a tiny product since the other factor is zero or at least 2^-126. The check takes 7 IR instructions instead of 20, which makes the SPIR-V of float-heavy pixel shaders smaller and quicker for drivers to compile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
Replaced by the next PR, rebased onto main be40308 (TechnicalDebt conflict with boykopovar#1290). |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
With f32 denormals flushed,
flushTinyProductdecides whether a product is tiny. It did that on the exact value, from the exponents and aUMulHiof the significands. RDNA2 detects tininess after rounding to 24 bits with an unbounded exponent, which TechnicalDebt records as measured on gfx1036 forv_mul_f32andv_mullit_f32:0x3f7ffffe * 0x00800001gives0x00800000on the hardware and 0 here.The check now multiplies one factor by 2^64 and multiplies the result by the other factor. Scaling by 2^64 is exact below 2^64, so the second multiply rounds the exact product to 24 bits once, in the normal range. Its magnitude bits are then compared with those of 2^-62 (
0x20800000), and a zero product is not tiny, as before. A factor of 2^64 or more cannot give a tiny product, since the other factor is zero or at least 2^-126. NaN and infinity compare as not tiny.0x3f7ffffe * 0x00800001now gives0x00800000, as on RDNA2.F32ConstantFactorTininesspins this lane.UMulHi.hasUnitSignificandwas only needed for the carry and is removed.v_mul_legacy_f32use it too, but their rounding point is not measured.Why
The ps5-opengl UI renderer's large pixel shader (VITA5 PPSA39410, Homebrew UI Lab PPSA99050) has 1,587 checked products. On an RTX 5070 Laptop (driver 616.92), creating its graphics pipeline takes 14.7 s with a cold driver cache. UI Lab waits at most 2 s for a submission to retire, so it stops at
submission retirement failedon every cold start.I timed the same SPIR-V module, dumped from
Pipeline.cpp, in a standalone Vulkan program. Each variant below replaces one emulation pattern with a pass-through. These are timing experiments only, and the variants are not correct:With this change:
That still exceeds UI Lab's 2 s wait; the NaN-result and denormal-flush selects are the other two large costs.
Tested
Windows 11, WinLibs GCC 15.2.0 r7, NVIDIA RTX 5070 Laptop (616.92) and AMD Radeon 880M (AMDVLK 2.0.353).
agc_driverfloat tests (ctest -R "^agc_driver_(f32|f16|f64|vop|mix|fma|sin|interpolation|denormal|nan)") pass on the NVIDIA and on the AMD GPU (ANYPS5_GPU=AMD).agc_driver_f32_constant_factor_tininessfails without the source change (lane 2 no float mode v_mul_f32 0x3f7ffffe is 0x00000000, expected the product that rounds to 24 bits at 2^-126 0x00800000) and passes with it.check_conventions.pypassed.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🤖 Generated with Claude Code