Fix missing modification of jump table in licm
This commit is contained in:
committed by
Yoshitomo Nakanishi
parent
2cec20aa57
commit
855a6374dd
@@ -61,8 +61,8 @@ pub fn do_licm(
|
||||
domtree.compute(func, cfg);
|
||||
}
|
||||
|
||||
// Insert a pre-header before the header, modifying the function layout and CFG to reflect it.
|
||||
// A jump instruction to the header is placed at the end of the pre-header.
|
||||
/// Insert a pre-header before the header, modifying the function layout and CFG to reflect it.
|
||||
/// A jump instruction to the header is placed at the end of the pre-header.
|
||||
fn create_pre_header(
|
||||
isa: &dyn TargetIsa,
|
||||
header: Block,
|
||||
@@ -81,30 +81,31 @@ fn create_pre_header(
|
||||
for typ in header_args_types {
|
||||
pre_header_args_value.push(func.dfg.append_block_param(pre_header, typ), pool);
|
||||
}
|
||||
|
||||
for BlockPredecessor {
|
||||
inst: last_inst, ..
|
||||
} in cfg.pred_iter(header)
|
||||
{
|
||||
// We only follow normal edges (not the back edges)
|
||||
if !domtree.dominates(header, last_inst, &func.layout) {
|
||||
func.change_branch_destination(last_inst, pre_header);
|
||||
func.rewrite_branch_destination(last_inst, header, pre_header);
|
||||
}
|
||||
}
|
||||
{
|
||||
let mut pos = EncCursor::new(func, isa).at_top(header);
|
||||
// Inserts the pre-header at the right place in the layout.
|
||||
pos.insert_block(pre_header);
|
||||
pos.next_inst();
|
||||
pos.ins().jump(header, pre_header_args_value.as_slice(pool));
|
||||
}
|
||||
|
||||
// Inserts the pre-header at the right place in the layout.
|
||||
let mut pos = EncCursor::new(func, isa).at_top(header);
|
||||
pos.insert_block(pre_header);
|
||||
pos.next_inst();
|
||||
pos.ins().jump(header, pre_header_args_value.as_slice(pool));
|
||||
|
||||
pre_header
|
||||
}
|
||||
|
||||
// Detects if a loop header has a natural pre-header.
|
||||
//
|
||||
// A loop header has a pre-header if there is only one predecessor that the header doesn't
|
||||
// dominate.
|
||||
// Returns the pre-header Block and the instruction jumping to the header.
|
||||
/// Detects if a loop header has a natural pre-header.
|
||||
///
|
||||
/// A loop header has a pre-header if there is only one predecessor that the header doesn't
|
||||
/// dominate.
|
||||
/// Returns the pre-header Block and the instruction jumping to the header.
|
||||
fn has_pre_header(
|
||||
layout: &Layout,
|
||||
cfg: &ControlFlowGraph,
|
||||
@@ -176,9 +177,9 @@ fn is_loop_invariant(inst: Inst, dfg: &DataFlowGraph, loop_values: &FxHashSet<Va
|
||||
true
|
||||
}
|
||||
|
||||
// Traverses a loop in reverse post-order from a header block and identify loop-invariant
|
||||
// instructions. These loop-invariant instructions are then removed from the code and returned
|
||||
// (in reverse post-order) for later use.
|
||||
/// Traverses a loop in reverse post-order from a header block and identify loop-invariant
|
||||
/// instructions. These loop-invariant instructions are then removed from the code and returned
|
||||
/// (in reverse post-order) for later use.
|
||||
fn remove_loop_invariant_instructions(
|
||||
lp: Loop,
|
||||
func: &mut Function,
|
||||
|
||||
Reference in New Issue
Block a user