Skip to content

Commit b9b809c

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-next
2 parents b63e32a + 60fc39e commit b9b809c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

stdlib/public/core/FloatingPoint.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,6 @@ public protocol FloatingPoint : SignedNumeric, Strideable, Hashable
230230
/// the initializer has the same magnitude as `magnitudeOf`.
231231
init(signOf: Self, magnitudeOf: Self)
232232

233-
234233
/// Creates a new value, rounded to the closest possible representation.
235234
///
236235
/// If two representable values are equally close, the result is the value

stdlib/public/core/FloatingPointTypes.swift.gyb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,15 @@ extension ${Self}: BinaryFloatingPoint {
973973
%end
974974
}
975975

976+
// For core standard library floating-point types, LLVM can lower copysign
977+
// for us; this gets somewhat better codegen than the generic implementation,
978+
// but more importantly allows it to participate in other optimizations
979+
// at the LLVM level.
980+
@_transparent
981+
public init(signOf sign: ${Self}, magnitudeOf mag: ${Self}) {
982+
_value = Builtin.int_copysign_FPIEEE${bits}(mag._value, sign._value)
983+
}
984+
976985
/// Rounds the value to an integral value using the specified rounding rule.
977986
///
978987
/// The following example rounds a value using four different rounding rules:

0 commit comments

Comments
 (0)