diff --git a/Sources/ComplexModule/Complex+AlgebraicField.swift b/Sources/ComplexModule/Complex+AlgebraicField.swift index c1ff5e4..4908b57 100644 --- a/Sources/ComplexModule/Complex+AlgebraicField.swift +++ b/Sources/ComplexModule/Complex+AlgebraicField.swift @@ -124,12 +124,12 @@ extension Complex: AlgebraicField { return nil } - @inlinable + @_transparent public static func _relaxedAdd(_ a: Self, _ b: Self) -> Self { Complex(Relaxed.sum(a.x, b.x), Relaxed.sum(a.y, b.y)) } - @inlinable + @_transparent public static func _relaxedMul(_ a: Self, _ b: Self) -> Self { Complex( Relaxed.sum(Relaxed.product(a.x, b.x), -Relaxed.product(a.y, b.y)), diff --git a/Sources/RealModule/Double+Real.swift b/Sources/RealModule/Double+Real.swift index 57e51f9..4c6b341 100644 --- a/Sources/RealModule/Double+Real.swift +++ b/Sources/RealModule/Double+Real.swift @@ -220,11 +220,6 @@ extension Double: Real { } #endif - @_transparent - public static func _mulAdd(_ a: Double, _ b: Double, _ c: Double) -> Double { - _numerics_muladd(a, b, c) - } - @_transparent public static func _relaxedAdd(_ a: Double, _ b: Double) -> Double { _numerics_relaxed_add(a, b) diff --git a/Sources/RealModule/Float+Real.swift b/Sources/RealModule/Float+Real.swift index b6f1da0..ab459bb 100644 --- a/Sources/RealModule/Float+Real.swift +++ b/Sources/RealModule/Float+Real.swift @@ -193,11 +193,6 @@ extension Float: Real { } #endif - @_transparent - public static func _mulAdd(_ a: Float, _ b: Float, _ c: Float) -> Float { - _numerics_muladdf(a, b, c) - } - @_transparent public static func _relaxedAdd(_ a: Float, _ b: Float) -> Float { _numerics_relaxed_addf(a, b) diff --git a/Sources/RealModule/Float16+Real.swift b/Sources/RealModule/Float16+Real.swift index 2da3956..9613ebc 100644 --- a/Sources/RealModule/Float16+Real.swift +++ b/Sources/RealModule/Float16+Real.swift @@ -176,11 +176,6 @@ extension Float16: Real { // TODO: once clang stabilizes the calling conventions for _Float16 on Intel, // we can re-enable these; presently the type is disabled on the target. #if !(arch(i386) || arch(x86_64)) - @_transparent - public static func _mulAdd(_ a: Float16, _ b: Float16, _ c: Float16) -> Float16 { - _numerics_muladdf16(a, b, c) - } - @_transparent public static func _relaxedAdd(_ a: Float16, _ b: Float16) -> Float16 { _numerics_relaxed_addf16(a, b) diff --git a/Sources/RealModule/RealFunctions.swift b/Sources/RealModule/RealFunctions.swift index 4e77543..31e6d16 100644 --- a/Sources/RealModule/RealFunctions.swift +++ b/Sources/RealModule/RealFunctions.swift @@ -76,8 +76,4 @@ public protocol RealFunctions: ElementaryFunctions { /// See also `gamma()` and `logGamma()`. static func signGamma(_ x: Self) -> FloatingPointSign #endif - - /// a*b + c, computed _either_ with an FMA or with separate multiply and add, - /// whichever is fastest on the compilation target. - static func _mulAdd(_ a: Self, _ b: Self, _ c: Self) -> Self } diff --git a/Sources/RealModule/RelaxedArithmetic.swift b/Sources/RealModule/RelaxedArithmetic.swift index 58890d1..e3a5865 100644 --- a/Sources/RealModule/RelaxedArithmetic.swift +++ b/Sources/RealModule/RelaxedArithmetic.swift @@ -49,8 +49,7 @@ extension Relaxed { /// /// Floating-point addition and multiplication are not associative operations, /// so the Swift compiler does not have any flexibility in how it evaluates - /// an expression - /// like: + /// an expression like: /// ``` /// func sumOfSquares(array: [Float]) -> Float { /// array.reduce(0) { $0 + $1*$1 } @@ -75,9 +74,9 @@ extension Relaxed { /// a*b + c, computed _either_ with an FMA or with separate multiply and add, /// whichever is fastest according to the optimizer's heuristics. @_transparent - public static func multiplyAdd( + public static func multiplyAdd( _ a: T, _ b: T, _ c: T ) -> T { - T._mulAdd(a, b, c) + T._relaxedAdd(c, T._relaxedMul(a, b)) } } diff --git a/Sources/_NumericsShims/include/_NumericsShims.h b/Sources/_NumericsShims/include/_NumericsShims.h index 605ccde..016c235 100644 --- a/Sources/_NumericsShims/include/_NumericsShims.h +++ b/Sources/_NumericsShims/include/_NumericsShims.h @@ -386,12 +386,6 @@ HEADER_SHIM long double libm_lgammal(long double x, int *signp) { #define CLANG_RELAX_FP _Pragma("clang fp reassociate(on) contract(fast)") #if !(__i386__ || __x86_64__) -/// a*b + c evaluated _either_ as two operations or fma, whichever is faster. -HEADER_SHIM _Float16 _numerics_muladdf16(_Float16 a, _Float16 b, _Float16 c) { -#pragma STDC FP_CONTRACT ON - return a*b + c; -} - /// a + b with the "allow reassociation" and "allow FMA formation" flags /// set in the IR. HEADER_SHIM _Float16 _numerics_relaxed_addf16(_Float16 a, _Float16 b) { @@ -407,12 +401,6 @@ HEADER_SHIM _Float16 _numerics_relaxed_mulf16(_Float16 a, _Float16 b) { } #endif -/// a*b + c evaluated _either_ as two operations or fma, whichever is faster. -HEADER_SHIM float _numerics_muladdf(float a, float b, float c) { -#pragma STDC FP_CONTRACT ON - return a*b + c; -} - /// a + b with the "allow reassociation" and "allow FMA formation" flags /// set in the IR. HEADER_SHIM float _numerics_relaxed_addf(float a, float b) { @@ -427,12 +415,6 @@ HEADER_SHIM float _numerics_relaxed_mulf(float a, float b) { return a * b; } -/// a*b + c evaluated _either_ as two operations or fma, whichever is faster. -HEADER_SHIM double _numerics_muladd(double a, double b, double c) { -#pragma STDC FP_CONTRACT ON - return a*b + c; -} - /// a + b with the "allow reassociation" and "allow FMA formation" flags /// set in the IR. HEADER_SHIM double _numerics_relaxed_add(double a, double b) {