-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Declare some FloatingPointSign members explicitly for @inlinable #16043
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
Conversation
The compiler can synthesize these, but it doesn't mark them @inlinable, since in the general case they're just a "default" implementation and not "the only implementation forever". But for a two-element enum that's based on a part of IEEE 754, it's probably safe to assume this is the only implementation forever, and that can be important for performance. https://bugs.swift.org/browse/SR-7094
@swift-ci Please benchmark |
@swift-ci Please test |
Confirming that we will never want to change these. |
Also @natecook1000 I deliberately didn't put any doc comments on these, assuming they'd be mirrored down from the protocols like they were before. Is that correct? |
@jrose-apple I don't know the current state of docs inheritance—it hasn't been great lately. I can follow up once these are in… |
} | ||
|
||
@inlinable | ||
public static func ==(a: FloatingPointSign, b: FloatingPointSign) -> Bool { |
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.
We should have a default == witness for RawRepresentable things somewhere
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.
We probably do, but a client isn't supposed to inline that when using it on someone else's type.
|
||
@inlinable | ||
public init?(rawValue: Int) { | ||
switch rawValue { |
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.
Why don't we synthesize @inlinable members for any frozen RawRepresentable enum?
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 not a fan of this approach. Are there other RawRepresentable enums in the standard library?
See the discussion in #15589, but the short form is "this is the only such enum; we can decide what to do in the general case later". |
Build comment file:Optimized (O)Regression (23)
Improvement (16)
No Changes (383)
Unoptimized (Onone)Regression (99)
Improvement (12)
No Changes (311)
Hardware Overview
|
I'm pretty sure these benchmark results are nonsense. None of these things even touch FloatingPointSign, so unless these three functions changed the code size of the standard library so drastically this is just random noise. Why do we have benchmarks with a ±30% swing anyway? *grump* (I was looking for changes in BinaryFloatingPointProperties, but it turns out those are so fast already that you can't tell.) |
Yeah, there's something deeply suspicious about those benchmark regressions. |
That's in fact interesting. Usually the noise is within 10% |
…ftlang#16043) The compiler can synthesize these, but it doesn't mark them @inlinable, since in the general case they're just a "default" implementation and not "the only implementation forever". But for a two-element enum that's based on a part of IEEE 754, it's probably safe to assume this is the only implementation forever, and that can be important for performance. https://bugs.swift.org/browse/SR-7094 (cherry picked from commit f6b67f3)
The compiler can synthesize these, but it doesn't mark them @inlinable, since in the general case they're just a "default" implementation and not "the only implementation forever". But for a two-element enum that's based on a part of IEEE 754, it's probably safe to assume this is the only implementation forever, and that can be important for performance.
SR-7094 / rdar://problem/38030106