-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/compile: math.Trunc produces incorrect result on riscv64 in Go 1.23rc1 #68322
Comments
@golang/riscv64 |
Yes, that riscv64 assembly looks bad. It converts float64->int64->float64, which doesn't work if the input float is bigger than 2^63-1. (For your example it is 2^64-2^11, I think, but generally it is a problem for very large floats.) We could probably compare |
Change https://go.dev/cl/596516 mentions this issue: |
Change https://go.dev/cl/600075 mentions this issue: |
This CL reapplies CL 504737 and adds integer precision limitation check, since CL 504737 only checks whether floating point number is +-Inf or NaN. This CL is also ~7% faster than CL 504737. Updates #68322 goos: linux goarch: riscv64 pkg: math │ math.old.bench │ math.new.bench │ │ sec/op │ sec/op vs base │ Ceil 54.09n ± 0% 18.72n ± 0% -65.39% (p=0.000 n=10) Floor 40.72n ± 0% 18.72n ± 0% -54.03% (p=0.000 n=10) Round 20.73n ± 0% 20.73n ± 0% ~ (p=1.000 n=10) RoundToEven 24.07n ± 0% 24.07n ± 0% ~ (p=1.000 n=10) Trunc 38.72n ± 0% 18.72n ± 0% -51.65% (p=0.000 n=10) geomean 33.56n 20.09n -40.13% Change-Id: I06cfe2cb9e2535cd705d40b6650a7e71fedd906c Reviewed-on: https://go-review.googlesource.com/c/go/+/600075 Reviewed-by: Keith Randall <[email protected]> Reviewed-by: Joel Sing <[email protected]> Reviewed-by: Keith Randall <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
Go version
go version go1.23rc1 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
I created the following reproducer
What did you see happen?
I cross compiled the test with GOOS=linux GOARCH=riscv64, and run it in the qemu environment. Then the test passed with Go 1.22 but was failing with Go 1.23rc1.
What did you expect to see?
The test passes.
The text was updated successfully, but these errors were encountered: