-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[stdlib] Implement fixed-width integer conversion from binary floating point #11259
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
|
@swift-ci Please test |
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 must be missing something. Is (value: 42, exact: false) a possible result? To me it looks like the nullability of value holds enough information.
UPD: Ahh.. I get it now.
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.
/cc @stephentyrone
|
@moiseev Where I could use specific guidance for this patch (besides review of its soundness) is use of optimization hints such as My hunch is that there are places where these hints could improve performance, but I'm not familiar with these facilities and unsure how I'd even go about determining where it would help. |
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.
RIP my favorite comment
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.
/cc @swiftix IIRC this @_sepamtics attribute was mainly to avoid an unnecessary binary size increase. Am I right?
@xwu my first thought is to mark initializers as @inline(always) and _convert as @inlineable The only way to see the impact of these changes though, is to implement a benchmark. I'd say we can land this PR first, add a benchmark in a separate PR and then start playing with improvements.
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.
@moiseev Yes, you are right.@semantics was used to avoid an unnecessary binary size increase.
|
@xwu Please refer to the amazing document @milseman has started recently for the description of |
|
Build failed |
|
Build failed |
|
@moiseev Excellent; please test again and merge when you're ready. I have added only the most obvious |
|
Before that, could you run a rebase to squash this down to as few commits as possible and remove the last merge commit? |
Make internal stdlib function public because it is called from stdlib tests Add some first-thought optimizations
|
@CodaFi Done. |
|
@swift-ci please test |
|
Build failed |
|
Build failed |
|
@swift-ci please test Linux platform |
Now that SE-0104 has been revised, it is possible to implement, on
FixedWidthInteger, the protocol requirement for conversions from any binary floating point value. This PR provides one such implementation.