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:
@@ -270,7 +270,6 @@ impl InstructionData {
|
||||
pub fn analyze_branch(&self) -> BranchInfo {
|
||||
match *self {
|
||||
Self::Jump { destination, .. } => BranchInfo::SingleDest(destination),
|
||||
Self::Branch { destination, .. } => BranchInfo::SingleDest(destination),
|
||||
Self::Brif {
|
||||
blocks: [block_then, block_else],
|
||||
..
|
||||
@@ -292,9 +291,6 @@ impl InstructionData {
|
||||
match self {
|
||||
Self::Jump {
|
||||
ref destination, ..
|
||||
}
|
||||
| Self::Branch {
|
||||
ref destination, ..
|
||||
} => std::slice::from_ref(destination),
|
||||
Self::Brif { blocks, .. } => blocks,
|
||||
Self::BranchTable { .. } => &[],
|
||||
@@ -313,10 +309,6 @@ impl InstructionData {
|
||||
Self::Jump {
|
||||
ref mut destination,
|
||||
..
|
||||
}
|
||||
| Self::Branch {
|
||||
ref mut destination,
|
||||
..
|
||||
} => std::slice::from_mut(destination),
|
||||
Self::Brif { blocks, .. } => blocks,
|
||||
Self::BranchTable { .. } => &mut [],
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
//! determined by the `Layout` data structure defined in this module.
|
||||
|
||||
use crate::entity::SecondaryMap;
|
||||
use crate::ir::dfg::DataFlowGraph;
|
||||
use crate::ir::progpoint::{ExpandedProgramPoint, ProgramOrder};
|
||||
use crate::ir::{Block, Inst};
|
||||
use crate::packed_option::PackedOption;
|
||||
@@ -594,19 +593,6 @@ impl Layout {
|
||||
self.insts[inst].prev.expand()
|
||||
}
|
||||
|
||||
/// Fetch the first instruction in a block's terminal branch group.
|
||||
pub fn canonical_branch_inst(&self, dfg: &DataFlowGraph, block: Block) -> Option<Inst> {
|
||||
// Basic blocks permit at most two terminal branch instructions.
|
||||
// If two, the former is conditional and the latter is unconditional.
|
||||
let last = self.last_inst(block)?;
|
||||
if let Some(prev) = self.prev_inst(last) {
|
||||
if dfg.insts[prev].opcode().is_branch() {
|
||||
return Some(prev);
|
||||
}
|
||||
}
|
||||
Some(last)
|
||||
}
|
||||
|
||||
/// Insert `inst` before the instruction `before` in the same block.
|
||||
pub fn insert_inst(&mut self, inst: Inst, before: Inst) {
|
||||
debug_assert_eq!(self.inst_block(inst), None);
|
||||
@@ -662,24 +648,6 @@ impl Layout {
|
||||
}
|
||||
}
|
||||
|
||||
/// Iterate over a limited set of instruction which are likely the branches of `block` in layout
|
||||
/// order. Any instruction not visited by this iterator is not a branch, but an instruction visited by this may not be a branch.
|
||||
pub fn block_likely_branches(&self, block: Block) -> Insts {
|
||||
// Note: Checking whether an instruction is a branch or not while walking backward might add
|
||||
// extra overhead. However, we know that the number of branches is limited to 2 at the end of
|
||||
// each block, and therefore we can just iterate over the last 2 instructions.
|
||||
let mut iter = self.block_insts(block);
|
||||
let head = iter.head;
|
||||
let tail = iter.tail;
|
||||
iter.next_back();
|
||||
let head = iter.next_back().or(head);
|
||||
Insts {
|
||||
layout: self,
|
||||
head,
|
||||
tail,
|
||||
}
|
||||
}
|
||||
|
||||
/// Split the block containing `before` in two.
|
||||
///
|
||||
/// Insert `new_block` after the old block and move `before` and the following instructions to
|
||||
|
||||
Reference in New Issue
Block a user