Commit 2f191c89 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

opt: Simplify computed goto with known destination to unconditional branch.

parent a697cdf9
......@@ -36,6 +36,7 @@ libFirm 1.22.1 (2016-01-07)
* sparc: Support the asm constaint `K`
* sparc: Support computed goto
* arm: Support computed goto
* opt: Simplify computed goto with known destination to unconditional branch
* Bugfixes
libFirm 1.22.0 (2015-12-31)
......
......@@ -5740,11 +5740,28 @@ static ir_node *transform_node_Block(ir_node *block)
ir_node *bad = NULL;
for (int i = 0; i < arity; ++i) {
ir_node *const pred = get_Block_cfgpred(block, i);
if (is_Bad(pred) || !is_block_unreachable(get_nodes_block(pred)))
if (is_Bad(pred)) {
continue;
if (bad == NULL)
bad = new_r_Bad(irg, mode_X);
set_irn_n(block, i, bad);
} else if (is_block_unreachable(get_nodes_block(pred))) {
goto bad;
} else if (is_IJmp(pred)) {
ir_node *const target = get_IJmp_target(pred);
if (is_Address(target)) {
ir_entity *const entity = get_Address_entity(target);
if (entity == get_Block_entity(block)) {
/* BB[x](..., IJmp(Adress[x]), ...) ==> BB[x](..., Jmp, ...) */
dbg_info *const dbgi = get_irn_dbg_info(pred);
ir_node* const jmp = new_rd_Jmp(dbgi, get_nodes_block(pred));
set_irn_n(block, i, jmp);
} else {
/* BB[x](..., IJmp(Adress[y]), ...), x != y ==> BB[x](..., Bad, ...) */
bad:
if (!bad)
bad = new_r_Bad(irg, mode_X);
set_irn_n(block, i, bad);
}
}
}
}
return block;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment