cranelift: Remove redundant branch and select instructions (#5097)
As discussed in the 2022/10/19 meeting, this PR removes many of the branch and select instructions that used iflags, in favor if using brz/brnz and select in their place. Additionally, it reworks selectif_spectre_guard to take an i8 input instead of an iflags input. For reference, the removed instructions are: br_icmp, brif, brff, trueif, trueff, and selectif.
This commit is contained in:
@@ -1089,12 +1089,6 @@
|
||||
(decl cc_invert (CC) CC)
|
||||
(extern constructor cc_invert cc_invert)
|
||||
|
||||
(decl intcc_reverse (IntCC) IntCC)
|
||||
(extern constructor intcc_reverse intcc_reverse)
|
||||
|
||||
(decl floatcc_inverse (FloatCC) FloatCC)
|
||||
(extern constructor floatcc_inverse floatcc_inverse)
|
||||
|
||||
;; Fails if the argument is not either CC.NZ or CC.Z.
|
||||
(decl cc_nz_or_z (CC) CC)
|
||||
(extern extractor cc_nz_or_z cc_nz_or_z)
|
||||
|
||||
@@ -2760,16 +2760,6 @@
|
||||
(rule (lower_branch (jump _ _) (single_target target))
|
||||
(side_effect (jmp_known target)))
|
||||
|
||||
;; Rules for `brif` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(rule (lower_branch (brif cc (ifcmp a b) _ _) (two_targets taken not_taken))
|
||||
(side_effect (jmp_cond_icmp (emit_cmp cc a b) taken not_taken)))
|
||||
|
||||
;; Rules for `brff` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(rule (lower_branch (brff cc (ffcmp a b) _ _) (two_targets taken not_taken))
|
||||
(side_effect (jmp_cond_fcmp (emit_fcmp cc a b) taken not_taken)))
|
||||
|
||||
;; Rules for `brz` and `brnz` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(rule 2 (lower_branch (brz (icmp cc a b) _ _) (two_targets taken not_taken))
|
||||
@@ -2828,22 +2818,14 @@
|
||||
(src Gpr val))
|
||||
(x64_test size src src)))
|
||||
|
||||
;; Rules for `bricmp` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(rule (lower_branch (br_icmp cc a b _ _) (two_targets taken not_taken))
|
||||
(side_effect (jmp_cond_icmp (emit_cmp cc a b) taken not_taken)))
|
||||
|
||||
;; Rules for `br_table` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(rule (lower_branch (br_table idx @ (value_type ty) _ _) (jump_table_targets default_target jt_targets))
|
||||
(side_effect (jmp_table_seq ty idx default_target jt_targets)))
|
||||
|
||||
;; Rules for `selectif` and `selectif_spectre_guard` ;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Rules for `select_spectre_guard` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(rule (lower (selectif cc (ifcmp a b) x y))
|
||||
(select_icmp (emit_cmp cc a b) x y))
|
||||
|
||||
(rule (lower (selectif_spectre_guard cc (ifcmp a b) x y))
|
||||
(rule (lower (select_spectre_guard (icmp cc a b) x y))
|
||||
(select_icmp (emit_cmp cc a b) x y))
|
||||
|
||||
;; Rules for `fcvt_from_sint` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
@@ -419,8 +419,7 @@ fn lower_insn_to_regs(
|
||||
| Opcode::GetStackPointer
|
||||
| Opcode::GetReturnAddress
|
||||
| Opcode::Select
|
||||
| Opcode::Selectif
|
||||
| Opcode::SelectifSpectreGuard
|
||||
| Opcode::SelectSpectreGuard
|
||||
| Opcode::FcvtFromSint
|
||||
| Opcode::FcvtLowFromSint
|
||||
| Opcode::FcvtFromUint
|
||||
@@ -499,8 +498,6 @@ fn lower_insn_to_regs(
|
||||
|
||||
Opcode::Bmask => unimplemented!("Bmask not implemented"),
|
||||
|
||||
Opcode::Trueif | Opcode::Trueff => unimplemented!("trueif / trueff not implemented"),
|
||||
|
||||
Opcode::Vsplit | Opcode::Vconcat => {
|
||||
unimplemented!("Vector split/concat ops not implemented.");
|
||||
}
|
||||
@@ -570,13 +567,7 @@ fn lower_insn_to_regs(
|
||||
panic!("trapz / trapnz / resumable_trapnz should have been removed by legalization!");
|
||||
}
|
||||
|
||||
Opcode::Jump
|
||||
| Opcode::Brz
|
||||
| Opcode::Brnz
|
||||
| Opcode::BrIcmp
|
||||
| Opcode::Brif
|
||||
| Opcode::Brff
|
||||
| Opcode::BrTable => {
|
||||
Opcode::Jump | Opcode::Brz | Opcode::Brnz | Opcode::BrTable => {
|
||||
panic!("Branch opcode reached non-branch lowering logic!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -593,16 +593,6 @@ impl Context for IsleContext<'_, '_, MInst, Flags, IsaFlags, 6> {
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn intcc_reverse(&mut self, cc: &IntCC) -> IntCC {
|
||||
cc.reverse()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn floatcc_inverse(&mut self, cc: &FloatCC) -> FloatCC {
|
||||
cc.inverse()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn sum_extend_fits_in_32_bits(
|
||||
&mut self,
|
||||
|
||||
Reference in New Issue
Block a user