(BNEZ (SEQZ x) yes no) => (BEQZ x yes no)
(BNEZ (SNEZ x) yes no) => (BNEZ x yes no)
+// Absorb NEG into branch when possible.
+(BEQZ x:(NEG y) yes no) && x.Uses == 1 => (BEQZ y yes no)
+(BNEZ x:(NEG y) yes no) && x.Uses == 1 => (BNEZ y yes no)
+
// Convert BEQZ/BNEZ into more optimal branch conditions.
(BEQZ (SUB x y) yes no) => (BEQ x y yes no)
(BNEZ (SUB x y) yes no) => (BNE x y yes no)
b.resetWithControl(BlockRISCV64BEQZ, x)
return true
}
+ // match: (BEQZ x:(NEG y) yes no)
+ // cond: x.Uses == 1
+ // result: (BEQZ y yes no)
+ for b.Controls[0].Op == OpRISCV64NEG {
+ x := b.Controls[0]
+ y := x.Args[0]
+ if !(x.Uses == 1) {
+ break
+ }
+ b.resetWithControl(BlockRISCV64BEQZ, y)
+ return true
+ }
// match: (BEQZ (SUB x y) yes no)
// result: (BEQ x y yes no)
for b.Controls[0].Op == OpRISCV64SUB {
b.resetWithControl(BlockRISCV64BNEZ, x)
return true
}
+ // match: (BNEZ x:(NEG y) yes no)
+ // cond: x.Uses == 1
+ // result: (BNEZ y yes no)
+ for b.Controls[0].Op == OpRISCV64NEG {
+ x := b.Controls[0]
+ y := x.Args[0]
+ if !(x.Uses == 1) {
+ break
+ }
+ b.resetWithControl(BlockRISCV64BNEZ, y)
+ return true
+ }
// match: (BNEZ (SUB x y) yes no)
// result: (BNE x y yes no)
for b.Controls[0].Op == OpRISCV64SUB {