]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: absorb SNEZ into branch on riscv64
authorJoel Sing <joel@sing.id.au>
Sun, 1 Mar 2020 17:25:54 +0000 (04:25 +1100)
committerJoel Sing <joel@sing.id.au>
Tue, 3 Mar 2020 12:04:46 +0000 (12:04 +0000)
Change-Id: I55fd93843a7fb574a7dd66ebb87fdd96e944d555
Reviewed-on: https://go-review.googlesource.com/c/go/+/221682
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/compile/internal/ssa/gen/RISCV64.rules
src/cmd/compile/internal/ssa/rewriteRISCV64.go

index 9c1169dc67fa44d10c58e3dfc24a735991e07099..a19f8aa55bb3bc95eec196bbe55ca47bf439ebad 100644 (file)
 
 // Optimizations
 
+// Absorb SNEZ into branch.
+(BNE (SNEZ x) yes no) -> (BNE x yes no)
+
 // Fold ADD+MOVDconst into ADDI where possible.
 (ADD (MOVDconst [off]) ptr) && is32Bit(off) -> (ADDI [off] ptr)
 
index b363b10ad780bef2aab6d0df0b7cc93134cad23c..6b3f4f70b50454e66468631c91094574891de0d1 100644 (file)
@@ -4387,6 +4387,15 @@ func rewriteValueRISCV64_OpZeroExt8to64(v *Value) bool {
 }
 func rewriteBlockRISCV64(b *Block) bool {
        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:
                // match: (If cond yes no)
                // result: (BNE cond yes no)