1
0
mirror of https://github.com/golang/go synced 2024-11-17 15:04:45 -07:00

cmd/compile: absorb SNEZ into branch on riscv64

Change-Id: I55fd93843a7fb574a7dd66ebb87fdd96e944d555
Reviewed-on: https://go-review.googlesource.com/c/go/+/221682
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
Joel Sing 2020-03-02 04:25:54 +11:00
parent d28b8524a4
commit c9ece81cc8
2 changed files with 12 additions and 0 deletions

View File

@ -458,6 +458,9 @@
// Optimizations // Optimizations
// Absorb SNEZ into branch.
(BNE (SNEZ x) yes no) -> (BNE x yes no)
// Fold ADD+MOVDconst into ADDI where possible. // Fold ADD+MOVDconst into ADDI where possible.
(ADD (MOVDconst [off]) ptr) && is32Bit(off) -> (ADDI [off] ptr) (ADD (MOVDconst [off]) ptr) && is32Bit(off) -> (ADDI [off] ptr)

View File

@ -4387,6 +4387,15 @@ func rewriteValueRISCV64_OpZeroExt8to64(v *Value) bool {
} }
func rewriteBlockRISCV64(b *Block) bool { func rewriteBlockRISCV64(b *Block) bool {
switch b.Kind { switch b.Kind {
case BlockRISCV64BNE:
// match: (BNE (SNEZ x) yes no)
// result: (BNE x yes no)
for b.Controls[0].Op == OpRISCV64SNEZ {
v_0 := b.Controls[0]
x := v_0.Args[0]
b.resetWithControl(BlockRISCV64BNE, x)
return true
}
case BlockIf: case BlockIf:
// match: (If cond yes no) // match: (If cond yes no)
// result: (BNE cond yes no) // result: (BNE cond yes no)