diff options
author | Josh Bleecher Snyder <josharian@gmail.com> | 2020-04-23 19:22:26 -0700 |
---|---|---|
committer | Josh Bleecher Snyder <josharian@gmail.com> | 2020-04-24 16:44:20 +0000 |
commit | 67a8660b5acd570530f3777727d67e739e54cb2b (patch) | |
tree | 4a2550a3801fcb5bf4e8a341309a8315ab46ff24 /src/cmd/compile/internal/ssa/rewriteWasm.go | |
parent | 3a37fd4010dc20403d642e2c628cb0656a4fb968 (diff) | |
download | go-67a8660b5acd570530f3777727d67e739e54cb2b.tar.gz go-67a8660b5acd570530f3777727d67e739e54cb2b.zip |
cmd/compile: CSE the RHS of rewrite rules
Keep track of all expressions encountered while
generating a rewrite result, and re-use them whenever possible.
Named expressions may still be used for clarity when desired.
Change-Id: I640dca108763eb8baeff8f9a4169300af3445b82
Reviewed-on: https://go-review.googlesource.com/c/go/+/229800
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martà <mvdan@mvdan.cc>
Diffstat (limited to 'src/cmd/compile/internal/ssa/rewriteWasm.go')
-rw-r--r-- | src/cmd/compile/internal/ssa/rewriteWasm.go | 70 |
1 files changed, 19 insertions, 51 deletions
diff --git a/src/cmd/compile/internal/ssa/rewriteWasm.go b/src/cmd/compile/internal/ssa/rewriteWasm.go index 9d527fff92..16e6f96917 100644 --- a/src/cmd/compile/internal/ssa/rewriteWasm.go +++ b/src/cmd/compile/internal/ssa/rewriteWasm.go @@ -3206,9 +3206,7 @@ func rewriteValueWasm_OpSignExt16to32(v *Value) bool { v1 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) v1.AuxInt = int64ToAuxInt(48) v0.AddArg2(x, v1) - v2 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) - v2.AuxInt = int64ToAuxInt(48) - v.AddArg2(v0, v2) + v.AddArg2(v0, v1) return true } } @@ -3247,9 +3245,7 @@ func rewriteValueWasm_OpSignExt16to64(v *Value) bool { v1 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) v1.AuxInt = int64ToAuxInt(48) v0.AddArg2(x, v1) - v2 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) - v2.AuxInt = int64ToAuxInt(48) - v.AddArg2(v0, v2) + v.AddArg2(v0, v1) return true } } @@ -3288,9 +3284,7 @@ func rewriteValueWasm_OpSignExt32to64(v *Value) bool { v1 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) v1.AuxInt = int64ToAuxInt(32) v0.AddArg2(x, v1) - v2 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) - v2.AuxInt = int64ToAuxInt(32) - v.AddArg2(v0, v2) + v.AddArg2(v0, v1) return true } } @@ -3329,9 +3323,7 @@ func rewriteValueWasm_OpSignExt8to16(v *Value) bool { v1 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) v1.AuxInt = int64ToAuxInt(56) v0.AddArg2(x, v1) - v2 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) - v2.AuxInt = int64ToAuxInt(56) - v.AddArg2(v0, v2) + v.AddArg2(v0, v1) return true } } @@ -3370,9 +3362,7 @@ func rewriteValueWasm_OpSignExt8to32(v *Value) bool { v1 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) v1.AuxInt = int64ToAuxInt(56) v0.AddArg2(x, v1) - v2 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) - v2.AuxInt = int64ToAuxInt(56) - v.AddArg2(v0, v2) + v.AddArg2(v0, v1) return true } } @@ -3411,9 +3401,7 @@ func rewriteValueWasm_OpSignExt8to64(v *Value) bool { v1 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) v1.AuxInt = int64ToAuxInt(56) v0.AddArg2(x, v1) - v2 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) - v2.AuxInt = int64ToAuxInt(56) - v.AddArg2(v0, v2) + v.AddArg2(v0, v1) return true } } @@ -4526,9 +4514,7 @@ func rewriteValueWasm_OpZero(v *Value) bool { v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) v0.AuxInt = int64ToAuxInt(0) v1 := b.NewValue0(v.Pos, OpWasmI64Store16, types.TypeMem) - v2 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) - v2.AuxInt = int64ToAuxInt(0) - v1.AddArg3(destptr, v2, mem) + v1.AddArg3(destptr, v0, mem) v.AddArg3(destptr, v0, v1) return true } @@ -4545,9 +4531,7 @@ func rewriteValueWasm_OpZero(v *Value) bool { v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) v0.AuxInt = int64ToAuxInt(0) v1 := b.NewValue0(v.Pos, OpWasmI64Store32, types.TypeMem) - v2 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) - v2.AuxInt = int64ToAuxInt(0) - v1.AddArg3(destptr, v2, mem) + v1.AddArg3(destptr, v0, mem) v.AddArg3(destptr, v0, v1) return true } @@ -4564,9 +4548,7 @@ func rewriteValueWasm_OpZero(v *Value) bool { v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) v0.AuxInt = int64ToAuxInt(0) v1 := b.NewValue0(v.Pos, OpWasmI64Store32, types.TypeMem) - v2 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) - v2.AuxInt = int64ToAuxInt(0) - v1.AddArg3(destptr, v2, mem) + v1.AddArg3(destptr, v0, mem) v.AddArg3(destptr, v0, v1) return true } @@ -4583,9 +4565,7 @@ func rewriteValueWasm_OpZero(v *Value) bool { v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) v0.AuxInt = int64ToAuxInt(0) v1 := b.NewValue0(v.Pos, OpWasmI64Store32, types.TypeMem) - v2 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) - v2.AuxInt = int64ToAuxInt(0) - v1.AddArg3(destptr, v2, mem) + v1.AddArg3(destptr, v0, mem) v.AddArg3(destptr, v0, v1) return true } @@ -4624,9 +4604,7 @@ func rewriteValueWasm_OpZero(v *Value) bool { v0 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) v0.AuxInt = int64ToAuxInt(0) v1 := b.NewValue0(v.Pos, OpWasmI64Store, types.TypeMem) - v2 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) - v2.AuxInt = int64ToAuxInt(0) - v1.AddArg3(destptr, v2, mem) + v1.AddArg3(destptr, v0, mem) v.AddArg3(destptr, v0, v1) return true } @@ -4644,13 +4622,9 @@ func rewriteValueWasm_OpZero(v *Value) bool { v0.AuxInt = int64ToAuxInt(0) v1 := b.NewValue0(v.Pos, OpWasmI64Store, types.TypeMem) v1.AuxInt = int64ToAuxInt(8) - v2 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) - v2.AuxInt = int64ToAuxInt(0) - v3 := b.NewValue0(v.Pos, OpWasmI64Store, types.TypeMem) - v4 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) - v4.AuxInt = int64ToAuxInt(0) - v3.AddArg3(destptr, v4, mem) - v1.AddArg3(destptr, v2, v3) + v2 := b.NewValue0(v.Pos, OpWasmI64Store, types.TypeMem) + v2.AddArg3(destptr, v0, mem) + v1.AddArg3(destptr, v0, v2) v.AddArg3(destptr, v0, v1) return true } @@ -4668,18 +4642,12 @@ func rewriteValueWasm_OpZero(v *Value) bool { v0.AuxInt = int64ToAuxInt(0) v1 := b.NewValue0(v.Pos, OpWasmI64Store, types.TypeMem) v1.AuxInt = int64ToAuxInt(16) - v2 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) - v2.AuxInt = int64ToAuxInt(0) + v2 := b.NewValue0(v.Pos, OpWasmI64Store, types.TypeMem) + v2.AuxInt = int64ToAuxInt(8) v3 := b.NewValue0(v.Pos, OpWasmI64Store, types.TypeMem) - v3.AuxInt = int64ToAuxInt(8) - v4 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) - v4.AuxInt = int64ToAuxInt(0) - v5 := b.NewValue0(v.Pos, OpWasmI64Store, types.TypeMem) - v6 := b.NewValue0(v.Pos, OpWasmI64Const, typ.Int64) - v6.AuxInt = int64ToAuxInt(0) - v5.AddArg3(destptr, v6, mem) - v3.AddArg3(destptr, v4, v5) - v1.AddArg3(destptr, v2, v3) + v3.AddArg3(destptr, v0, mem) + v2.AddArg3(destptr, v0, v3) + v1.AddArg3(destptr, v0, v2) v.AddArg3(destptr, v0, v1) return true } |