-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Enable logf128 constant folding for hosts with 128bit long double #96287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4cc6905
Enable logf128 constant folding for AArch64
MDevereau 97a0b20
Remove aarch64 constraint
MDevereau 94c6914
Enable optimization without opt-in
MDevereau 422fed8
Check for viable logf128 and use that for float128's typedef
MDevereau 613f6a4
Remove cmake tests
MDevereau 5705316
Lit uses LLVM_HAS_LOGF128 to run tests and is no longer a command lin…
MDevereau 6ceda72
Remove check for __LDBL_MANT_DIG__
MDevereau cc0a937
Merge branch 'main' into aarch64-logf128
MDevereau File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of explicitly checking the gcc version, can we
typedef decltype(logf128(0.)) float128;
or something like that?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would require including math.h in this file (which isn't a problem but worth mentioning). It's also possible for hosts to satisfy the condition and fall through to this but not have logf128 (I've seen x86 with clang do this). It's possible to add HAS_LOGF128 to the check, which is set at CMake time in order to get around this, but this isn't really about logf128 and more about the 128 bit floating-point types themselves. Granted, my logf128 patches are the only thing using this, but it still seems incorrect.
Apart from this, it does function well though.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm mostly concerned that checking for
__GNUC__
is overly specific, and might break on compilers you haven't seen, or compilers which don't exist yet (e.g. if clang's support for _Float128 changes).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've instead decided to move to a CMake test which checks the availability of logf128, the availability of a true 128bit float type and that type's compatibility with the logf128 symbol to receive accurate answers instead of trying to do this inside a header file.
A problem I faced when trying to run this on an x86 machine was that the size of long doubles were defined to be 16 bytes (when they are actually fp80) however calling logf128 with this type caused error codes to be returned from the function while compiling without issue. Using __float128 which is guaranteed to perform a 128 bit calculation even though the machine uses fp80 works OK though. I'm seeing both x86 with fp80 and aarch64 compile and run this without issues now. Instead of explicitly checking the GCC version, the _Float128 type which is available in GCC12+ is now asserted for availability and correctness and used if it is available.