cranelift: Remove brz and brnz (#5630)
Remove the brz and brnz instructions, as their behavior is now redundant with brif.
This commit is contained in:
@@ -362,7 +362,7 @@
|
||||
;; One-way conditional branch: jcond cond target.
|
||||
;;
|
||||
;; This instruction is useful when we have conditional jumps depending on
|
||||
;; more than two conditions, see for instance the lowering of Brz/brnz
|
||||
;; more than two conditions, see for instance the lowering of Brif
|
||||
;; with Fcmp inputs.
|
||||
;;
|
||||
;; A note of caution: in contexts where the branch target is another
|
||||
|
||||
@@ -184,8 +184,7 @@ mod tests {
|
||||
|
||||
let mut pos = FuncCursor::new(&mut func);
|
||||
pos.insert_block(block0);
|
||||
pos.ins().brnz(v0, block2, &[]);
|
||||
pos.ins().jump(block1, &[]);
|
||||
pos.ins().brif(v0, block2, &[], block1, &[]);
|
||||
|
||||
pos.insert_block(block1);
|
||||
pos.ins().return_(&[]);
|
||||
|
||||
@@ -2904,41 +2904,6 @@
|
||||
(jmp_cond (CC.NZ) then else))))
|
||||
|
||||
|
||||
;; Rules for `brz` and `brnz` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(rule 2 (lower_branch (brz (maybe_uextend (icmp cc a b)) _) (two_targets taken not_taken))
|
||||
(let ((cmp IcmpCondResult (invert_icmp_cond_result (emit_cmp cc a b))))
|
||||
(emit_side_effect (jmp_cond_icmp cmp taken not_taken))))
|
||||
|
||||
(rule 2 (lower_branch (brz (maybe_uextend (fcmp cc a b)) _) (two_targets taken not_taken))
|
||||
(let ((cmp FcmpCondResult (emit_fcmp (floatcc_inverse cc) a b)))
|
||||
(emit_side_effect (jmp_cond_fcmp cmp taken not_taken))))
|
||||
|
||||
(rule 1 (lower_branch (brz val @ (value_type $I128) _) (two_targets taken not_taken))
|
||||
(emit_side_effect (jmp_cond_icmp (cmp_zero_i128 (CC.NZ) val) taken not_taken)))
|
||||
|
||||
(rule 0 (lower_branch (brz val @ (value_type (ty_int_bool_or_ref)) _) (two_targets taken not_taken))
|
||||
(emit_side_effect
|
||||
(with_flags_side_effect (cmp_zero_int_bool_ref val)
|
||||
(jmp_cond (CC.Z) taken not_taken))))
|
||||
|
||||
|
||||
(rule 2 (lower_branch (brnz (maybe_uextend (icmp cc a b)) _) (two_targets taken not_taken))
|
||||
(emit_side_effect (jmp_cond_icmp (emit_cmp cc a b) taken not_taken)))
|
||||
|
||||
(rule 2 (lower_branch (brnz (maybe_uextend (fcmp cc a b)) _) (two_targets taken not_taken))
|
||||
(let ((cmp FcmpCondResult (emit_fcmp cc a b)))
|
||||
(emit_side_effect (jmp_cond_fcmp cmp taken not_taken))))
|
||||
|
||||
(rule 1 (lower_branch (brnz val @ (value_type $I128) _) (two_targets taken not_taken))
|
||||
(emit_side_effect (jmp_cond_icmp (cmp_zero_i128 (CC.Z) val) taken not_taken)))
|
||||
|
||||
(rule 0 (lower_branch (brnz val @ (value_type (ty_int_bool_or_ref)) _) (two_targets taken not_taken))
|
||||
(emit_side_effect
|
||||
(with_flags_side_effect (cmp_zero_int_bool_ref val)
|
||||
(jmp_cond (CC.NZ) taken not_taken))))
|
||||
|
||||
|
||||
;; Compare an I128 value to zero, returning a flags result suitable for making a
|
||||
;; jump decision. The comparison is implemented as `(hi == 0) && (low == 0)`,
|
||||
;; and the result can be interpreted as follows
|
||||
|
||||
@@ -261,23 +261,20 @@ mod test {
|
||||
let v0 = pos.ins().iconst(I32, 0x1234);
|
||||
pos.set_srcloc(SourceLoc::new(2));
|
||||
let v1 = pos.ins().iadd(arg0, v0);
|
||||
pos.ins().brnz(v1, bb1, &[v1]);
|
||||
pos.ins().jump(bb2, &[]);
|
||||
pos.ins().brif(v1, bb1, &[v1], bb2, &[]);
|
||||
|
||||
pos.insert_block(bb1);
|
||||
pos.set_srcloc(SourceLoc::new(3));
|
||||
let v2 = pos.ins().isub(v1, v0);
|
||||
pos.set_srcloc(SourceLoc::new(4));
|
||||
let v3 = pos.ins().iadd(v2, bb1_param);
|
||||
pos.ins().brnz(v1, bb2, &[]);
|
||||
pos.ins().jump(bb3, &[v3]);
|
||||
pos.ins().brif(v1, bb2, &[], bb3, &[v3]);
|
||||
|
||||
pos.func.layout.set_cold(bb2);
|
||||
pos.insert_block(bb2);
|
||||
pos.set_srcloc(SourceLoc::new(5));
|
||||
let v4 = pos.ins().iadd(v1, v0);
|
||||
pos.ins().brnz(v4, bb2, &[]);
|
||||
pos.ins().jump(bb1, &[v4]);
|
||||
pos.ins().brif(v4, bb2, &[], bb1, &[v4]);
|
||||
|
||||
pos.insert_block(bb3);
|
||||
pos.set_srcloc(SourceLoc::new(6));
|
||||
|
||||
Reference in New Issue
Block a user