runtime: fix softfloat64 add/sub for normal operands cancelling to subnormal When fadd64/fsub64 cancel two near-equal, opposite-sign normal operands into a subnormal result, fpack64 is handed a mantissa far below 1<<mantbits64 while exp is still a normal-range exponent. fpack64 saved mant0/exp0/trunc0 before its normalization loop, so the denormal branch restored an un-normalized mantissa and right-shifted it to align to the subnormal exponent (the wrong direction here), returning the un-normalized cancellation mantissa at the wrong scale instead of the correctly rounded subnormal. Save mant0/exp0/trunc0 after the normalization loop so the denormal path restores a normalized mantissa and aligns correctly. This is a no-op for callers that already pass a normalized mantissa (fmul64, fdiv64, conversions). fpack32 is updated identically for parity, though its denormal branch is not reachable with an un-normalized mantissa through any current caller. This only manifests on softfloat targets (e.g. GOMIPS=softfloat), which is why it has gone unnoticed on hardware-float platforms. A randomized differential check against hardware found the previous code wrong on >50% of normal pairs that cancel into a subnormal; with this change those cases match hardware. Fixes #79964 Change-Id: I29f7ec79905ddb98af4f997a69b0a2f0574c3c9d GitHub-Last-Rev: 42a73cd890f798e432c1aa5a279c758cb465e323 GitHub-Pull-Request: golang/go#79965 Reviewed-on: https://go-review.googlesource.com/c/go/+/789861 Reviewed-by: Sayer Turner <sayerturner65@gmail.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Keith Randall <khr@golang.org> LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.
Gopher image by Renee French, licensed under Creative Commons 4.0 Attribution license.
Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.
Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.
Official binary distributions are available at https://go.dev/dl/.
After downloading a binary release, visit https://go.dev/doc/install for installation instructions.
If a binary distribution is not available for your combination of operating system and architecture, visit https://go.dev/doc/install/source for source installation instructions.
Go is the work of thousands of contributors. We appreciate your help!
To contribute, please read the contribution guidelines at https://go.dev/doc/contribute.
Note that the Go project uses the issue tracker for bug reports and proposals only. See https://go.dev/wiki/Questions for a list of places to ask questions about the Go language.