diff options
author | Joel Sing <joel@sing.id.au> | 2021-08-17 19:01:52 +1000 |
---|---|---|
committer | Joel Sing <joel@sing.id.au> | 2021-08-21 11:22:07 +0000 |
commit | bcd146d398da2a873bb3f5a6e026c70b411a4486 (patch) | |
tree | a81df93abbe37d417d3bb0f81af3148749f81724 /src/cmd/compile/internal/ssa/gen | |
parent | dcee007aad6cca16cec0383a394dd7db92cd6790 (diff) | |
download | go-bcd146d398da2a873bb3f5a6e026c70b411a4486.tar.gz go-bcd146d398da2a873bb3f5a6e026c70b411a4486.zip |
cmd/compile: convert branch with zero to more optimal branch zero on riscv64
Convert BLT and BGE with a zero valued constant to BGTZ/BLTZ/BLEZ/BGEZ as
appropriate.
Removes over 4,500 instructions from the go binary on riscv64.
Change-Id: Icc266e968b126ba04863ec88529630a9dd44498b
Reviewed-on: https://go-review.googlesource.com/c/go/+/342849
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/ssa/gen')
-rw-r--r-- | src/cmd/compile/internal/ssa/gen/RISCV64.rules | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/ssa/gen/RISCV64.rules b/src/cmd/compile/internal/ssa/gen/RISCV64.rules index 1acef2a273..1414b2b34d 100644 --- a/src/cmd/compile/internal/ssa/gen/RISCV64.rules +++ b/src/cmd/compile/internal/ssa/gen/RISCV64.rules @@ -596,11 +596,15 @@ (BEQZ (SLTU x y) yes no) => (BGEU x y yes no) (BNEZ (SLTU x y) yes no) => (BLTU x y yes no) -// Convert branch with zero to BEQZ/BNEZ. +// Convert branch with zero to more optimal branch zero. (BEQ (MOVDconst [0]) cond yes no) => (BEQZ cond yes no) (BEQ cond (MOVDconst [0]) yes no) => (BEQZ cond yes no) (BNE (MOVDconst [0]) cond yes no) => (BNEZ cond yes no) (BNE cond (MOVDconst [0]) yes no) => (BNEZ cond yes no) +(BLT (MOVDconst [0]) cond yes no) => (BGTZ cond yes no) +(BLT cond (MOVDconst [0]) yes no) => (BLTZ cond yes no) +(BGE (MOVDconst [0]) cond yes no) => (BLEZ cond yes no) +(BGE cond (MOVDconst [0]) yes no) => (BGEZ cond yes no) // Store zero (MOVBstore [off] {sym} ptr (MOVDconst [0]) mem) => (MOVBstorezero [off] {sym} ptr mem) |