Repository navigation
fix(shader): keep f32 denormals in compares when denormals are kept - #3895
Merged
oneandonlydean merged 1 commit intoOct 12, 2026
Merged
Conversation
This was referenced Oct 11, 2026
Contributor
|
Windows run of this head (
|
With the f32 denormal field of FLOAT_MODE set to keep, v_cmp_X_f32 and v_cmpx_X_f32 read a denormal operand as zero: NVIDIA, RADV and lavapipe all flush denormals in their float compares. Compare the operands as sign-magnitude integers instead, with NaN handled apart. Compares with flushed denormals are unchanged. This matches RDNA2 (gfx1036) on 256 operand pairs per opcode, with f32 denormals kept and flushed. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
CouchRiv
force-pushed
the
fix-shader-vcmpx-f32-family
branch
from
October 11, 2026 23:22
124bfde to
de54527
Compare
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
With the f32 denormal field of
FLOAT_MODEset to keep denormals,v_cmp_X_f32andv_cmpx_X_f32read a denormal operand as zero:The compares are emitted as the SPIR-V float compares, and NVIDIA, RADV and lavapipe all flush denormals in those. With denormals flushed the hardware does the same, so that case was right.
When denormals are kept, the operands are now compared as sign-magnitude integers (so +0 and -0 still compare equal) and a NaN in either operand gives the ordered or unordered result. Compares with flushed denormals, f16 and f64 compares and the constant-operand paths are untouched. Only shaders that keep f32 denormals pay the extra integer ops.
On RDNA2 (gfx1036, Radeon 610M) the IEEE mode makes no difference to these compares; the f32 denormal mode does. 256 operand pairs per opcode (zeros, denormals including the largest, the smallest normal, ±1, infinities, quiet and signalling NaNs, the largest finite value) for the 12 conditions
eq ge gt le lg lt neq nge ngt nle nlg nltin both encodings, in IEEE 0 and 1 with denormals kept and flushed: 24,576 rows measured, 0 differing after this change.Tested
Linux (CachyOS), GCC; RTX 4070 Ti (NVIDIA), Radeon 610M (RADV) and lavapipe (Mesa 26.2.4).
main:agc_driver_vcmp_f32_denormalsfails on all three drivers (v_cmpx_eq_f32of 0x00000000 and 0x00000001 is 1, expected 0). Green with this change on every driver below.ctest -R "agc_driver_(vcmp_f32_denormals|f32_compare_constant|f32_denormal_flush|vop3_compare_modifiers|vopc_compare|vopc_compare_table|f32_min_max_nan|f32_arithmetic_nan|f32_result_clamp)$"after a clean build:tools/check_conventions.py --base origin/mainandgit diff --check: clean.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 repositoryAI-assisted: yes