Repository navigation
Conversation
Contributor
|
I think it would be better to add this cflag to the cflags when building mesa instead (a parameter to meson cmd arg?) since this changes the behavior of generated code and may very well break other projects that assume default ps5 flags. Will keep pr open for a while so I can ponder… |
This branch has not been deployed
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.
A program that enables IEEE denormal handling at runtime can still misclassify subnormal values when compiled with the SDK wrappers. Clang's PS5 target defaults to
preserve-signdenormal assumptions, so optimization can remove the subnormal branch of__builtin_fpclassifyeven after the program clears MXCSR's FTZ and DAZ bits.This passes
-fdenormal-fp-math=ieeefrom bothprospero-clangandprospero-clang++. It preserves the classification needed by homebrew that enables IEEE handling, including the Vulkan CTS calculations that exposed the problem in my ports. The flag precedes the user's arguments, so an explicit-fdenormal-fp-math=preserve-signstill overrides it.The change affects compiler assumptions only. It does not change startup MXCSR, and applications that need hardware denormal handling still have to configure it.
Reproducer and validation
samples/test_denormalsclassifies the smallest positive binary32 subnormal with FTZ and DAZ disabled, then restores the caller's MXCSR. The classifier is in a separate translation unit so the caller cannot constant-fold it.Built and linked the PS5 sample with Clang/LLD 23.1.1. Also linked its PS5-target C objects into an x86-64 Linux test executable to check the generated CPU code. With
preserve-sign, it reportedFP_NORMAL(4) and failed; withieee, it reportedFP_SUBNORMAL(8) and passed. Both objects used the SDK headers, so their classification constants agree.Checked both C and C++ wrapper output: the default retains IEEE assumptions, and the explicit
preserve-signoverride restores the old model. Both wrapper scripts passbash -n.No new console run was performed. The host run verifies the generated classification code, not PS5 process startup behavior. This is a proposed default-policy change; projects intentionally relying on flush-to-zero compiler assumptions can retain them with the explicit flag.
Refs #70.