Add a fold_redundant_jumps() pass to the branch relaxation phase. (#887)

This commit is contained in:
Sean Stangl
2019-08-09 15:30:11 -06:00
committed by GitHub
parent e6e274a3aa
commit c7b4b98cac
8 changed files with 178 additions and 41 deletions

View File

@@ -88,7 +88,7 @@ fn create_pre_header(
{
// We only follow normal edges (not the back edges)
if !domtree.dominates(header, last_inst, &func.layout) {
change_branch_jump_destination(last_inst, pre_header, func);
func.change_branch_destination(last_inst, pre_header);
}
}
{
@@ -136,15 +136,6 @@ fn has_pre_header(
result
}
// Change the destination of a jump or branch instruction. Does nothing if called with a non-jump
// or non-branch instruction.
fn change_branch_jump_destination(inst: Inst, new_ebb: Ebb, func: &mut Function) {
match func.dfg[inst].branch_destination_mut() {
None => (),
Some(instruction_dest) => *instruction_dest = new_ebb,
}
}
/// Test whether the given opcode is unsafe to even consider for LICM.
fn trivially_unsafe_for_licm(opcode: Opcode) -> bool {
opcode.can_store()