`suboptimal_flops` incorrectly claims that `mul_add` is always more efficient
C-bug
### Summary
The documentation for [`mul_add`](https://doc.rust-lang.org/std/primitive.f64.html#method.mul_add) states:
> Using `mul_add` may be more performant than an unfused multiply-add if the target architecture has a dedicated `fma` CPU instruction. However, this is not always true, and will be heavily dependant on designing algorithms with specific target hardware in mind.
However, the lint message from `suboptimal_flops` says “multiply and add expressions can be calculated more efficiently and accurately”. The “more efficiently” part should not be stated without caveat.
### Reproducer
Code:
```rust
#![warn(clippy::suboptimal_flops)]
fn foo(x: f64) -> f64 {
x * 2.0 + 10.0
}
```
Current output:
```
warning: multiply and add expressions can be calculated more efficiently and accurately
--> src/lib.rs:4:5
|
4 | x * 2.0 + 10.0
| ^^^^^^^^^^^^^^ help: consider using: `x.mul_add(2.0, 10.0)`
```
Desired output:
```
warning: multiply and add expressions can be calculated more accurately
--> src/lib.rs:4:5
|
4 | x * 2.0 + 10.0
| ^^^^^^^^^^^^^^ help: consider using: `x.mul_add(2.0, 10.0)`
```
### Version
```text
rustc 1.96.0 (ac68faa20 2026-05-25)
binary: rustc
commit-hash: ac68faa20c58cbccd01ee7208bf3b6e93a7d7f96
commit-date: 2026-05-25
host: aarch64-apple-darwin
release: 1.96.0
LLVM version: 22.1.2
```
### Additional Labels
_No response_
0 条评论