amd64: correctly select sign of zeros on f32x4/f64x2 min/max (#730)

This commit is contained in:
Takeshi Yoneda
2022-08-02 19:47:49 +09:00
committed by GitHub
parent b02b5513e8
commit 9dfdab2548
6 changed files with 250 additions and 93 deletions

View File

@@ -805,7 +805,9 @@ func f32Equal(expected, actual float32) (matched bool) {
} else if math.IsNaN(float64(expected)) { // NaN cannot be compared with themselves, so we have to use IsNaN
matched = math.IsNaN(float64(actual))
} else {
matched = expected == actual
// Compare the bit patterns directly, rather than == on float32 since in Go, -0 and 0 equals,
// but in the Wasm spec, they are treated as different.
matched = math.Float32bits(expected) == math.Float32bits(actual)
}
return
}
@@ -820,7 +822,9 @@ func f64Equal(expected, actual float64) (matched bool) {
} else if math.IsNaN(expected) { // NaN cannot be compared with themselves, so we have to use IsNaN
matched = math.IsNaN(actual)
} else {
matched = expected == actual
// Compare the bit patterns directly, rather than == on float64 since in Go, -0 and 0 equals,
// but in the Wasm spec, they are treated as different.
matched = math.Float64bits(expected) == math.Float64bits(actual)
}
return
}