From: Michael Beck Date: Thu, 24 Feb 2005 15:04:39 +0000 (+0000) Subject: added code for if-conversion X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=31f937ccb5603ac79aa6431789b8fd215c152131;p=libfirm added code for if-conversion [r5245] --- diff --git a/ir/stat/firmstat.c b/ir/stat/firmstat.c index 1bac51828..c85a575e2 100644 --- a/ir/stat/firmstat.c +++ b/ir/stat/firmstat.c @@ -1260,6 +1260,24 @@ static void stat_dead_node_elim_stop(void *ctx, ir_graph *irg) --status->in_dead_node_elim; } +/** + * if-conversion was tried + */ +static void stat_if_conversion(void *context, ir_graph *irg, ir_node *phi, + int pos, ir_node *mux, if_result_t reason) +{ + if (! status->stat_options) + return; + + STAT_ENTER; + { + graph_entry_t *graph = graph_get_entry(irg, status->irg_hash); + + cnt_inc(&graph->cnt_if_conv[reason]); + } + STAT_LEAVE; +} + /** * A multiply was replaced by a series of Shifts/Adds/Subs * @@ -1444,6 +1462,7 @@ void init_stat(unsigned enable_options) HOOK(hook_strength_red, stat_strength_red); HOOK(hook_dead_node_elim_start, stat_dead_node_elim_start); HOOK(hook_dead_node_elim_stop, stat_dead_node_elim_stop); + HOOK(hook_if_conversion, stat_if_conversion); HOOK(hook_arch_dep_replace_mul_with_shifts, stat_arch_dep_replace_mul_with_shifts); HOOK(hook_arch_dep_replace_div_by_const, stat_arch_dep_replace_div_by_const); HOOK(hook_arch_dep_replace_mod_by_const, stat_arch_dep_replace_mod_by_const); diff --git a/ir/stat/firmstat_t.h b/ir/stat/firmstat_t.h index 95438f950..b54845460 100644 --- a/ir/stat/firmstat_t.h +++ b/ir/stat/firmstat_t.h @@ -76,27 +76,28 @@ enum leaf_call_state_t { * An entry for ir_graphs. These numbers are calculated for every IR graph. */ typedef struct _graph_entry_t { - HASH_MAP(node_entry_t) *opcode_hash; /**< hash map containing the opcode counter */ - HASH_MAP(block_entry_t) *block_hash; /**< hash map containing the block counter */ - counter_t cnt_walked; /**< walker walked over the graph */ - counter_t cnt_walked_blocks; /**< walker walked over the graph blocks */ - counter_t cnt_was_inlined; /**< number of times other graph were inlined */ - counter_t cnt_got_inlined; /**< number of times this graph was inlined */ - counter_t cnt_strength_red; /**< number of times strength reduction was successful on this graph */ - counter_t cnt_edges; /**< number of DF edges in this graph */ - counter_t cnt_all_calls; /**< number of all calls */ - counter_t cnt_call_with_cnst_arg; /**< number of calls with const args */ - counter_t cnt_indirect_calls; /**< number of indirect calls */ - HASH_MAP(opt_entry_t) *opt_hash[HOOK_OPT_LAST]; /**< hash maps containing opcode counter for optimizations */ - ir_graph *irg; /**< the graph of this object */ - entity *ent; /**< the entity of this graph if one exists */ - set *address_mark; /**< a set containing the address marks of the nodes */ - unsigned is_deleted:1; /**< set if this irg was deleted */ - unsigned is_leaf:1; /**< set, if this irg is a leaf function */ - unsigned is_leaf_call:2; /**< set, if this irg calls only leaf functions */ - unsigned is_recursive:1; /**< set, if this irg has recursive calls */ - unsigned is_chain_call:1; /**< set, if this irg is a chain call */ - unsigned is_analyzed:1; /**< helper: set, if this irg was already analysed */ + HASH_MAP(node_entry_t) *opcode_hash; /**< hash map containing the opcode counter */ + HASH_MAP(block_entry_t) *block_hash; /**< hash map containing the block counter */ + counter_t cnt_walked; /**< walker walked over the graph */ + counter_t cnt_walked_blocks; /**< walker walked over the graph blocks */ + counter_t cnt_was_inlined; /**< number of times other graph were inlined */ + counter_t cnt_got_inlined; /**< number of times this graph was inlined */ + counter_t cnt_strength_red; /**< number of times strength reduction was successful on this graph */ + counter_t cnt_edges; /**< number of DF edges in this graph */ + counter_t cnt_all_calls; /**< number of all calls */ + counter_t cnt_call_with_cnst_arg; /**< number of calls with const args */ + counter_t cnt_indirect_calls; /**< number of indirect calls */ + counter_t cnt_if_conv[IF_RESULT_LAST]; /**< number of if conversions */ + HASH_MAP(opt_entry_t) *opt_hash[HOOK_OPT_LAST]; /**< hash maps containing opcode counter for optimizations */ + ir_graph *irg; /**< the graph of this object */ + entity *ent; /**< the entity of this graph if one exists */ + set *address_mark; /**< a set containing the address marks of the nodes */ + unsigned is_deleted:1; /**< set if this irg was deleted */ + unsigned is_leaf:1; /**< set, if this irg is a leaf function */ + unsigned is_leaf_call:2; /**< set, if this irg calls only leaf functions */ + unsigned is_recursive:1; /**< set, if this irg has recursive calls */ + unsigned is_chain_call:1; /**< set, if this irg is a chain call */ + unsigned is_analyzed:1; /**< helper: set, if this irg was already analysed */ } graph_entry_t; /** diff --git a/ir/stat/stat_dmp.c b/ir/stat/stat_dmp.c index 305dfcf74..a1922c9c6 100644 --- a/ir/stat/stat_dmp.c +++ b/ir/stat/stat_dmp.c @@ -35,9 +35,18 @@ static const char *opt_names[] = { "Architecture dependant optimization", "Reassociation optimization", "Polymorphic call optimization", + "an if conversion was tried", "Lowered", }; +static const char *if_conv_names[] = { + "if conv done :", + "if conv side effect :", + "if conv Phi node found :", + "if conv to deep DAG's :", + "if conv bad control flow :", +}; + /** * dumps a opcode hash into human readable form */ @@ -99,7 +108,7 @@ static void simple_dump_edges(dumper_t *dmp, counter_t *cnt) */ static void simple_dump_graph(dumper_t *dmp, graph_entry_t *entry) { - int dump_opts = 1; + int i, dump_opts = 1; block_entry_t *b_entry; if (entry->irg) { @@ -129,14 +138,19 @@ static void simple_dump_graph(dumper_t *dmp, graph_entry_t *entry) entry->cnt_walked.cnt[0], entry->cnt_walked_blocks.cnt[0], entry->cnt_was_inlined.cnt[0], entry->cnt_got_inlined.cnt[0], - entry->cnt_strength_red.cnt[0], - entry->is_leaf ? "YES" : "NO", - entry->is_leaf_call == LCS_NON_LEAF_CALL ? "NO" : (entry->is_leaf_call == LCS_LEAF_CALL ? "Yes" : "Maybe"), - entry->is_recursive ? "YES" : "NO", - entry->is_chain_call ? "YES" : "NO", + entry->cnt_strength_red.cnt[0], + entry->is_leaf ? "YES" : "NO", + entry->is_leaf_call == LCS_NON_LEAF_CALL ? "NO" : (entry->is_leaf_call == LCS_LEAF_CALL ? "Yes" : "Maybe"), + entry->is_recursive ? "YES" : "NO", + entry->is_chain_call ? "YES" : "NO", entry->cnt_all_calls.cnt[0], entry->cnt_indirect_calls.cnt[0] ); + + for (i = 0; i < sizeof(entry->cnt_if_conv)/sizeof(entry->cnt_if_conv[0]); ++i) { + fprintf(dmp->f, " %s : %u\n", if_conv_names[i], entry->cnt_if_conv[i].cnt[0]); + } + } else { fprintf(dmp->f, "\nGlobals counts:\n");