Skip to content

Commit 704d129

Browse files
committed
Clarify in the docs that mul_add is not always faster.
More info: - rust-lang/rust#49842 - rust-lang/rust#50572
1 parent f412562 commit 704d129

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/float.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,8 +1237,10 @@ pub trait Float
12371237
fn is_sign_negative(self) -> bool;
12381238

12391239
/// Fused multiply-add. Computes `(self * a) + b` with only one rounding
1240-
/// error. This produces a more accurate result with better performance than
1241-
/// a separate multiplication operation followed by an add.
1240+
/// error, yielding a more accurate result than an unfused multiply-add.
1241+
///
1242+
/// Using `mul_add` can be more performant than an unfused multiply-add if
1243+
/// the target architecture has a dedicated `fma` CPU instruction.
12421244
///
12431245
/// ```
12441246
/// use num_traits::Float;

src/real.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,10 @@ pub trait Real
215215
fn is_sign_negative(self) -> bool;
216216

217217
/// Fused multiply-add. Computes `(self * a) + b` with only one rounding
218-
/// error. This produces a more accurate result with better performance than
219-
/// a separate multiplication operation followed by an add.
218+
/// error, yielding a more accurate result than an unfused multiply-add.
219+
///
220+
/// Using `mul_add` can be more performant than an unfused multiply-add if
221+
/// the target architecture has a dedicated `fma` CPU instruction.
220222
///
221223
/// ```
222224
/// use num_traits::real::Real;

0 commit comments

Comments
 (0)