-
Notifications
You must be signed in to change notification settings - Fork 10.5k
FloatingPoint.radix should be transparent. #25789
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
FloatingPoint.radix should be transparent. #25789
Conversation
@swift-ci please smoke test |
What's the reasoning for making this transparent? (cf. docs/TransparentAttr.rst) |
It is occasionally necessary to select between generic algorithms in code that should be compiling down to just a few instructions. Going through a witness table in those cases is catastrophic. E.g. if we need to rescale a computation to avoid overflow, we want to divide by the radix (which is always exact for large values), not a fixed value (which would introduce an extra rounding for either radix-2 or radix-10 or both).
|
FWIW, |
It will still help when the compiler can specialize a generic function. E.g. internal func a<T: FloatingPoint>(_ x: T) -> T {
if T.radix == 2 {
// do something with a simpler algorithm
}
// do the more complex thing
}
func b(_ x: Float) -> Float {
return a(x)/2
} We should be able to specialize and inline |
Yes, but |
|
@swift-ci please smoke test |
Not sure why we missed this one, but there it is.