Simplify and optimize fdim (#442)
The cases with NaN arguments can be handled by the same x - y expression, and this generates much better code: https://godbolt.org/z/f3rnT8jx4.
This commit is contained in:
parent
72ec4b39ca
commit
bfbe919adf
1 changed files with 1 additions and 9 deletions
|
|
@ -1,13 +1,5 @@
|
|||
use super::super::Float;
|
||||
|
||||
pub fn fdim<F: Float>(x: F, y: F) -> F {
|
||||
if x.is_nan() {
|
||||
x
|
||||
} else if y.is_nan() {
|
||||
y
|
||||
} else if x > y {
|
||||
x - y
|
||||
} else {
|
||||
F::ZERO
|
||||
}
|
||||
if x <= y { F::ZERO } else { x - y }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue