diff options
author | Joel Sing <joel@sing.id.au> | 2020-02-26 03:58:59 +1100 |
---|---|---|
committer | Joel Sing <joel@sing.id.au> | 2020-02-26 17:59:57 +0000 |
commit | c27dd0c9e581edb71c834e161db6a920ca239997 (patch) | |
tree | 8aec1a1484bf4c31e853a7c2db9f5a3b80c4f8f9 /src/cmd/compile/internal/ssa/rewriteRISCV64.go | |
parent | a1103dcc27b9c85800624367ebb89ef46d4307af (diff) | |
download | go-c27dd0c9e581edb71c834e161db6a920ca239997.tar.gz go-c27dd0c9e581edb71c834e161db6a920ca239997.zip |
cmd/compile: improve Eq32/Neq32 on riscv64
Use SUBW to perform a 32-bit subtraction, rather than zero extending from
32 to 64 bits. This reduces Eq32 and Neq32 to two instructions, rather than
the four instructions required previously.
Change-Id: Ib2798324881e9db842c864e91a0c1b1e48c4b67b
Reviewed-on: https://go-review.googlesource.com/c/go/+/220921
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/cmd/compile/internal/ssa/rewriteRISCV64.go')
-rw-r--r-- | src/cmd/compile/internal/ssa/rewriteRISCV64.go | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/cmd/compile/internal/ssa/rewriteRISCV64.go b/src/cmd/compile/internal/ssa/rewriteRISCV64.go index fe1604eca51..61da7a41bdb 100644 --- a/src/cmd/compile/internal/ssa/rewriteRISCV64.go +++ b/src/cmd/compile/internal/ssa/rewriteRISCV64.go @@ -816,18 +816,15 @@ func rewriteValueRISCV64_OpEq32(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block - typ := &b.Func.Config.Types // match: (Eq32 x y) - // result: (SEQZ (ZeroExt32to64 (SUB <x.Type> x y))) + // result: (SEQZ (SUBW <x.Type> x y)) for { x := v_0 y := v_1 v.reset(OpRISCV64SEQZ) - v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) - v1 := b.NewValue0(v.Pos, OpRISCV64SUB, x.Type) - v1.AddArg(x) - v1.AddArg(y) - v0.AddArg(v1) + v0 := b.NewValue0(v.Pos, OpRISCV64SUBW, x.Type) + v0.AddArg(x) + v0.AddArg(y) v.AddArg(v0) return true } @@ -2217,18 +2214,15 @@ func rewriteValueRISCV64_OpNeq32(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block - typ := &b.Func.Config.Types // match: (Neq32 x y) - // result: (SNEZ (ZeroExt32to64 (SUB <x.Type> x y))) + // result: (SNEZ (SUBW <x.Type> x y)) for { x := v_0 y := v_1 v.reset(OpRISCV64SNEZ) - v0 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) - v1 := b.NewValue0(v.Pos, OpRISCV64SUB, x.Type) - v1.AddArg(x) - v1.AddArg(y) - v0.AddArg(v1) + v0 := b.NewValue0(v.Pos, OpRISCV64SUBW, x.Type) + v0.AddArg(x) + v0.AddArg(y) v.AddArg(v0) return true } |