From cf8cc7f63c7ddefb666a6e8d99a4843d3277db9f Mon Sep 17 00:00:00 2001 From: Richard Musiol Date: Sun, 24 Mar 2019 12:14:27 +0100 Subject: cmd/compile: add saturating conversions on wasm This change adds the GOWASM option "satconv" to enable the generation of experimental saturating (non-trapping) float-to-int conversions. It improves the performance of the conversion by 42%. Previously the conversions had already been augmented with helper functions to have saturating behavior. Now Wasm.rules is always using the new operation names and wasm/ssa.go is falling back to the helpers if the feature is not enabled. The feature is in phase 4 of the WebAssembly proposal process: https://github.com/WebAssembly/meetings/blob/master/process/phases.md More information on the feature can be found at: https://github.com/WebAssembly/nontrapping-float-to-int-conversions/blob/master/proposals/nontrapping-float-to-int-conversion/Overview.md Change-Id: Ic6c3688017054ede804b02b6b0ffd4a02ef33ad7 Reviewed-on: https://go-review.googlesource.com/c/go/+/170119 Reviewed-by: Cherry Zhang Run-TryBot: Cherry Zhang TryBot-Result: Gobot Gobot --- src/cmd/internal/objabi/util.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/cmd/internal/objabi') diff --git a/src/cmd/internal/objabi/util.go b/src/cmd/internal/objabi/util.go index 02f9d9273a..e28447d141 100644 --- a/src/cmd/internal/objabi/util.go +++ b/src/cmd/internal/objabi/util.go @@ -79,10 +79,14 @@ func goppc64() int { type gowasmFeatures struct { SignExt bool + SatConv bool } func (f *gowasmFeatures) String() string { var flags []string + if f.SatConv { + flags = append(flags, "satconv") + } if f.SignExt { flags = append(flags, "signext") } @@ -92,6 +96,8 @@ func (f *gowasmFeatures) String() string { func gowasm() (f gowasmFeatures) { for _, opt := range strings.Split(envOr("GOWASM", ""), ",") { switch opt { + case "satconv": + f.SatConv = true case "signext": f.SignExt = true case "": -- cgit v1.3-5-g9baa