X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Fifconv.c;h=22ab6f068cb8c8c184478fd02a65062a67b50a2d;hb=8c9921a1fc166552f6e416434fd8394a4fc210a3;hp=04502fc4525f4c8b5caf5eacce5e98094880b2ce;hpb=9aab2f882395c6b4df60388d2d49c356eb6fd4e8;p=libfirm diff --git a/ir/opt/ifconv.c b/ir/opt/ifconv.c index 04502fc45..22ab6f068 100644 --- a/ir/opt/ifconv.c +++ b/ir/opt/ifconv.c @@ -21,7 +21,6 @@ * @file ir/opt/ifconv.c * @brief If conversion * @author Christoph Mallon - * @version $Id$ */ #include "config.h" @@ -40,6 +39,7 @@ #include "array_t.h" #include "irpass_t.h" #include "be.h" +#include "opt_manage.h" #include "irdump.h" #include "debug.h" @@ -52,7 +52,7 @@ typedef struct walker_env { bool changed; /**< Set if the graph was changed. */ } walker_env; -DEBUG_ONLY(static firm_dbg_module_t *dbg); +DEBUG_ONLY(static firm_dbg_module_t *dbg;) /** * Returns non-zero if a Block can be emptied. @@ -283,6 +283,8 @@ restart: ir_cdep* cdep; pred0 = get_Block_cfgpred_block(block, i); + if (pred0 == block) continue; + for (cdep = find_cdep(pred0); cdep != NULL; cdep = get_cdep_next(cdep)) { const ir_node* dependency = get_cdep_node(cdep); ir_node* projx0 = walk_to_projx(pred0, dependency); @@ -310,6 +312,7 @@ restart: dbg_info* cond_dbg; pred1 = get_Block_cfgpred_block(block, j); + if (pred1 == block) continue; if (!is_cdep_on(pred1, dependency)) continue; @@ -461,7 +464,7 @@ static void collect_phis(ir_node *node, void *env) } } -void opt_if_conv(ir_graph *irg) +static ir_graph_state_t do_ifconv(ir_graph *irg) { walker_env env; const backend_params *be_params = be_get_backend_param(); @@ -474,9 +477,6 @@ void opt_if_conv(ir_graph *irg) DB((dbg, LEVEL_1, "Running if-conversion on %+F\n", irg)); - normalize_one_return(irg); - remove_critical_cf_edges(irg); - compute_cdep(irg); ir_reserve_resources(irg, IR_RESOURCE_BLOCK_MARK | IR_RESOURCE_PHI_LIST); @@ -489,15 +489,22 @@ void opt_if_conv(ir_graph *irg) if (env.changed) { local_optimize_graph(irg); - - /* graph has changed, invalidate analysis info */ - set_irg_outs_inconsistent(irg); - set_irg_extblk_inconsistent(irg); - set_irg_loopinfo_inconsistent(irg); - set_irg_doms_inconsistent(irg); } free_cdep(irg); + + return IR_GRAPH_STATE_NO_CRITICAL_EDGES | IR_GRAPH_STATE_ONE_RETURN; +} + +static optdesc_t opt_ifconv = { + "if-conversion", + IR_GRAPH_STATE_NO_CRITICAL_EDGES | IR_GRAPH_STATE_NO_UNREACHABLE_CODE | IR_GRAPH_STATE_NO_BADS | IR_GRAPH_STATE_ONE_RETURN, + do_ifconv, +}; + +void opt_if_conv(ir_graph *irg) +{ + perform_irg_optimization(irg, &opt_ifconv); } ir_graph_pass_t *opt_if_conv_pass(const char *name)