-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[stdlib] Apply @_transparent consistently for (U)Int128 #74523
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 |
@swift-ci please benchmark |
This comment was marked as outdated.
This comment was marked as outdated.
stdlib/public/core/Int128.swift
Outdated
#elseif _pointerBitWidth(_32) | ||
UInt(Builtin.trunc_Int64_Int32(_low._value)) | ||
#else | ||
UInt(truncatingIfNeeded: _low) |
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.
Formally I think the #else
branch here should probably hit the default implementation instead, but that requires refactoring this a bit, so I'm ok with this for 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.
Yeah this implementation is technically incorrect for words larger than 64 bits, so I just wrote this as truncating self.
@inline(__always) | ||
|
||
@available(SwiftStdlib 6.0, *) | ||
@_transparent |
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 certain that we want these to be @_transparent
. These are potentially pretty heavyweight operations to drop into the caller (though we might reap benefits in the case of constant divisors).
@stephentyrone how do we feel about making |
It's a little bit weird since we don't have them for any other integer types, but other than that I'm OK with it. |
@swift-ci please test |
@swift-ci please benchmark |
Update UInt128.swift
@swift-ci please test |
@swift-ci please test |
Do you also want to |
@swift-ci test WebAssembly |
Sure! |
[stdlib] Apply @_transparent consistently for (U)Int128
Also adds a concrete implementation of
_lowWord
for bothInt128
andUInt128
. I've sprinkled available attributes everywhere because I personally dislike the implicit availability from the extension declaration because a new API introduced in an existing extension may forget to add availability which would be incorrect, so littering this everywhere hopefully makes it more obvious.Resolves: #74481