mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
math: simplify comparison in FMA when swapping p and z
Discovered by Junchen Li on CL 246858, the comparison before p and z are
swapped can be simplified from
pe < ze || (pe == ze && (pm1 < zm1 || (pm1 == zm1 && pm2 < zm2)))
to
pe < ze || pe == ze && pm1 < zm1
because zm2 is initialized to 0 before the branch.
Change-Id: Iee92d570038df2b0f8941ef6e422a022654ab2d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/247241
Run-TryBot: Akhil Indurti <aindurti@gmail.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
d10241fcf6
commit
6f90ee36e9
1 changed files with 1 additions and 1 deletions
|
|
@ -128,7 +128,7 @@ func FMA(x, y, z float64) float64 {
|
||||||
pe -= int32(is62zero)
|
pe -= int32(is62zero)
|
||||||
|
|
||||||
// Swap addition operands so |p| >= |z|
|
// Swap addition operands so |p| >= |z|
|
||||||
if pe < ze || (pe == ze && (pm1 < zm1 || (pm1 == zm1 && pm2 < zm2))) {
|
if pe < ze || pe == ze && pm1 < zm1 {
|
||||||
ps, pe, pm1, pm2, zs, ze, zm1, zm2 = zs, ze, zm1, zm2, ps, pe, pm1, pm2
|
ps, pe, pm1, pm2, zs, ze, zm1, zm2 = zs, ze, zm1, zm2, ps, pe, pm1, pm2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue