aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/softfloat.go
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2018-11-16 22:53:04 -0500
committerCherry Zhang <cherryyz@google.com>2018-11-23 17:16:36 +0000
commit63a3993a336714f95400e3e614064d4ae72995de (patch)
tree089ffcda77c7c2f0a000e858992c523a430b5826 /src/cmd/compile/internal/ssa/softfloat.go
parent649b89377e91ad6dbe710784f9e662082d31a1ff (diff)
downloadgo-63a3993a336714f95400e3e614064d4ae72995de.tar.gz
go-63a3993a336714f95400e3e614064d4ae72995de.zip
cmd/compile: use correct store types in softfloat
When using softfloat, floating point ops are rewritten to integer ops. The types of store ops were not rewritten. This may lower to floating point stores, which are problematic. This CL fixes this by rewriting the store types as well. This fixes test/fixedbugs/issue28688.go on Wasm. Softfloat mode is not used by default on Wasm, and it is not needed as Wasm spec supports floating points. But it is nice to have the correct types. Change-Id: Ib5e19e19fa9491b15c2f60320f8724cace5cefb5 Reviewed-on: https://go-review.googlesource.com/c/149965 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/ssa/softfloat.go')
-rw-r--r--src/cmd/compile/internal/ssa/softfloat.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/ssa/softfloat.go b/src/cmd/compile/internal/ssa/softfloat.go
index b41819c6ad..4b578b133b 100644
--- a/src/cmd/compile/internal/ssa/softfloat.go
+++ b/src/cmd/compile/internal/ssa/softfloat.go
@@ -4,7 +4,10 @@
package ssa
-import "math"
+import (
+ "cmd/compile/internal/types"
+ "math"
+)
func softfloat(f *Func) {
if !f.Config.SoftFloat {
@@ -53,6 +56,15 @@ func softfloat(f *Func) {
v.Type = f.Config.Types.UInt64
}
newInt64 = newInt64 || v.Type.Size() == 8
+ } else if (v.Op == OpStore || v.Op == OpZero || v.Op == OpMove) && v.Aux.(*types.Type).IsFloat() {
+ switch size := v.Aux.(*types.Type).Size(); size {
+ case 4:
+ v.Aux = f.Config.Types.UInt32
+ case 8:
+ v.Aux = f.Config.Types.UInt64
+ default:
+ v.Fatalf("bad float type with size %d", size)
+ }
}
}
}