diff options
| author | Joel Sing <joel@sing.id.au> | 2021-03-06 04:46:07 +1100 |
|---|---|---|
| committer | Joel Sing <joel@sing.id.au> | 2021-03-08 03:23:21 +0000 |
| commit | 125eca0f7210da1bbf1a4a1460a87d1c33366b99 (patch) | |
| tree | 8b399ec2752041280209c129444b87d7306bdcd8 /src | |
| parent | 597b5d192e39d7bba38dd461b96effe6e524984b (diff) | |
| download | go-125eca0f7210da1bbf1a4a1460a87d1c33366b99.tar.xz | |
cmd/compile: improve IsNonNil rule on riscv64
IsNonNil is readily implemented using SNEZ on riscv64, removing over 8,000
instructions from the go binary. Other rules will improve on this sequence,
however in this case it makes sense to use a direct simplification.
Change-Id: Ib4068599532398afcd05f51d160673ef5fb5e5a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/299230
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Michael Munday <mike.munday@lowrisc.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd/compile/internal/ssa/gen/RISCV64.rules | 2 | ||||
| -rw-r--r-- | src/cmd/compile/internal/ssa/rewriteRISCV64.go | 18 |
2 files changed, 3 insertions, 17 deletions
diff --git a/src/cmd/compile/internal/ssa/gen/RISCV64.rules b/src/cmd/compile/internal/ssa/gen/RISCV64.rules index d7efef039e..dbe04f1d58 100644 --- a/src/cmd/compile/internal/ssa/gen/RISCV64.rules +++ b/src/cmd/compile/internal/ssa/gen/RISCV64.rules @@ -423,7 +423,7 @@ (Convert ...) => (MOVconvert ...) // Checks -(IsNonNil p) => (NeqPtr (MOVDconst [0]) p) +(IsNonNil ...) => (SNEZ ...) (IsInBounds ...) => (Less64U ...) (IsSliceInBounds ...) => (Leq64U ...) diff --git a/src/cmd/compile/internal/ssa/rewriteRISCV64.go b/src/cmd/compile/internal/ssa/rewriteRISCV64.go index 7f77477da7..895f380d33 100644 --- a/src/cmd/compile/internal/ssa/rewriteRISCV64.go +++ b/src/cmd/compile/internal/ssa/rewriteRISCV64.go @@ -239,7 +239,8 @@ func rewriteValueRISCV64(v *Value) bool { v.Op = OpLess64U return true case OpIsNonNil: - return rewriteValueRISCV64_OpIsNonNil(v) + v.Op = OpRISCV64SNEZ + return true case OpIsSliceInBounds: v.Op = OpLeq64U return true @@ -1101,21 +1102,6 @@ func rewriteValueRISCV64_OpHmul32u(v *Value) bool { return true } } -func rewriteValueRISCV64_OpIsNonNil(v *Value) bool { - v_0 := v.Args[0] - b := v.Block - typ := &b.Func.Config.Types - // match: (IsNonNil p) - // result: (NeqPtr (MOVDconst [0]) p) - for { - p := v_0 - v.reset(OpNeqPtr) - v0 := b.NewValue0(v.Pos, OpRISCV64MOVDconst, typ.UInt64) - v0.AuxInt = int64ToAuxInt(0) - v.AddArg2(v0, p) - return true - } -} func rewriteValueRISCV64_OpLeq16(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] |
