diff options
author | Agniva De Sarker <agnivade@yahoo.co.in> | 2019-06-16 16:07:55 +0530 |
---|---|---|
committer | Agniva De Sarker <agniva.quicksilver@gmail.com> | 2019-08-28 04:44:21 +0000 |
commit | 8fedb2d3383c29a00c8b43dc456a0ac03f836b45 (patch) | |
tree | 6de90627002fe602a5bfeba425ab4d701b9520cb /src/cmd/compile/internal/ssa/rewriteWasm.go | |
parent | b9ef4c0f5605efeb5e7e0a4ab817401d5e353b94 (diff) | |
download | go-8fedb2d3383c29a00c8b43dc456a0ac03f836b45.tar.gz go-8fedb2d3383c29a00c8b43dc456a0ac03f836b45.zip |
cmd/compile: optimize bounded shifts on wasm
Use the shiftIsBounded function to generate more efficient
Shift instructions.
Updates #25167
Change-Id: Id350f8462dc3a7ed3bfed0bcbea2860b8f40048a
Reviewed-on: https://go-review.googlesource.com/c/go/+/182558
Run-TryBot: Agniva De Sarker <agniva.quicksilver@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Richard Musiol <neelance@gmail.com>
Diffstat (limited to 'src/cmd/compile/internal/ssa/rewriteWasm.go')
-rw-r--r-- | src/cmd/compile/internal/ssa/rewriteWasm.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ssa/rewriteWasm.go b/src/cmd/compile/internal/ssa/rewriteWasm.go index 4bded46065..f57305dade 100644 --- a/src/cmd/compile/internal/ssa/rewriteWasm.go +++ b/src/cmd/compile/internal/ssa/rewriteWasm.go @@ -2729,6 +2729,20 @@ func rewriteValueWasm_OpLsh64x64_0(v *Value) bool { b := v.Block typ := &b.Func.Config.Types // match: (Lsh64x64 x y) + // cond: shiftIsBounded(v) + // result: (I64Shl x y) + for { + y := v.Args[1] + x := v.Args[0] + if !(shiftIsBounded(v)) { + break + } + v.reset(OpWasmI64Shl) + v.AddArg(x) + v.AddArg(y) + return true + } + // match: (Lsh64x64 x y) // cond: // result: (Select (I64Shl x y) (I64Const [0]) (I64LtU y (I64Const [64]))) for { @@ -4256,6 +4270,20 @@ func rewriteValueWasm_OpRsh64Ux64_0(v *Value) bool { b := v.Block typ := &b.Func.Config.Types // match: (Rsh64Ux64 x y) + // cond: shiftIsBounded(v) + // result: (I64ShrU x y) + for { + y := v.Args[1] + x := v.Args[0] + if !(shiftIsBounded(v)) { + break + } + v.reset(OpWasmI64ShrU) + v.AddArg(x) + v.AddArg(y) + return true + } + // match: (Rsh64Ux64 x y) // cond: // result: (Select (I64ShrU x y) (I64Const [0]) (I64LtU y (I64Const [64]))) for { @@ -4333,6 +4361,20 @@ func rewriteValueWasm_OpRsh64x64_0(v *Value) bool { b := v.Block typ := &b.Func.Config.Types // match: (Rsh64x64 x y) + // cond: shiftIsBounded(v) + // result: (I64ShrS x y) + for { + y := v.Args[1] + x := v.Args[0] + if !(shiftIsBounded(v)) { + break + } + v.reset(OpWasmI64ShrS) + v.AddArg(x) + v.AddArg(y) + return true + } + // match: (Rsh64x64 x y) // cond: // result: (I64ShrS x (Select <typ.Int64> y (I64Const [63]) (I64LtU y (I64Const [64])))) for { |