Add options to control denormal modes#1616
Merged
Merged
Conversation
dneto0
requested changes
Jul 2, 2026
Introduce `-denorm-preserve` and `-denorm-flush-to-zero` options to clspv. These options allow specifying which floating-point types (fp16, fp32, fp64) should preserve denormals or flush them to zero. Refactor existing options to use a unified `FloatingPointType` enum instead of separate enums for FMA and RoundingModeRTE. Introduce `DenormMode` enum to represent the denormal handling state (preserve, flush_to_zero, unspecified, error). The new options are used to: - Set Clang's `FP32DenormalMode` and `FPDenormalMode` accordingly. - Emit `DenormPreserve` or `DenormFlushToZero` execution modes and capabilities in the SPIR-V producer. Validation is added in `ParseOptions` to ensure: - Preserve and FlushToZero are mutually exclusive for a given type. - fp16 and fp64 share the same mode, as they are mapped to the single `FPDenormalMode` in Clang CodeGenOptions. The unused `cl-denorms-are-zero` option is marked as having no effect.
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.
Introduce
-denorm-preserveand-denorm-flush-to-zerooptions to clspv.These options allow specifying which floating-point types (fp16, fp32, fp64)
should preserve denormals or flush them to zero.
Refactor existing options to use a unified
FloatingPointTypeenum instead ofseparate enums for FMA and RoundingModeRTE.
Introduce
DenormModeenum to represent the denormal handling state(preserve, flush_to_zero, unspecified, error).
The new options are used to:
FP32DenormalModeandFPDenormalModeaccordingly.DenormPreserveorDenormFlushToZeroexecution modes andcapabilities in the SPIR-V producer.
Validation is added in
ParseOptionsto ensure:FPDenormalModein Clang CodeGenOptions.The unused
cl-denorms-are-zerooption is marked as having no effect.