X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fstat%2Fstat_dmp.c;h=9ccceaac54d9d0b406102752f069c21d0b78f8d5;hb=3da5ed2598245b896255bc444aaa1768f6098cfe;hp=a210c8751050218cc6d888b5def31c6386afa801;hpb=a8cbb483ba7b090d5a20001c63f11588c6b97629;p=libfirm diff --git a/ir/stat/stat_dmp.c b/ir/stat/stat_dmp.c index a210c8751..9ccceaac5 100644 --- a/ir/stat/stat_dmp.c +++ b/ir/stat/stat_dmp.c @@ -23,9 +23,7 @@ * @author Michael Beck * @version $Id$ */ -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif +#include "config.h" #include "stat_dmp.h" #include "irtools.h" @@ -63,6 +61,7 @@ static const struct { { HOOK_OPT_CONFIRM_C, "Confirm-based optimization: replaced by const" }, { HOOK_OPT_CONFIRM_E, "Confirm-based optimization: evaluated" }, { HOOK_OPT_EXC_REM, "a exception edge was removed due to a Confirmation prove" }, + { HOOK_OPT_NORMALIZE, "a commutative node was normalized" }, { HOOK_LOWERED, "Lowered" }, { HOOK_BACKEND, "Backend transformation" }, { FS_OPT_NEUTRAL_0, "algebraic simplification: a op 0 = 0 op a = a" }, @@ -78,6 +77,8 @@ static const struct { { FS_OPT_SUB_SUB_X_Y_Z, "algebraic simplification: (x - y) - z = x - (y + z)" }, { FS_OPT_SUB_C_NOT_X, "algebraic simplification: c - ~a = a + (c+1)" }, { FS_OPT_SUB_TO_ADD, "algebraic simplification: (-a) - b = -(a + b), a - (b - c) = a + (c - b), a - (b * C) = a + (b * -C)" }, + { FS_OPT_SUB_TO_NOT, "algebraic simplification: -1 - x -> ~x" }, + { FS_OPT_SUB_TO_CONV, "algebraic simplification: a - NULL = (int)a" }, { FS_OPT_MUL_MINUS, "algebraic simplification: (-a) * (b - c) = a * (c - b)" }, { FS_OPT_MUL_MINUS_1, "algebraic simplification: a * -1 = -a" }, { FS_OPT_MINUS_MUL_C, "algebraic simplification: (-a) * C = a * (-C)" }, @@ -86,10 +87,11 @@ static const struct { { FS_OPT_AND, "algebraic simplification: a & 0b1...1 = 0b1...1 & a = a & a = (a|X) & a = a" }, { FS_OPT_TO_EOR, "algebraic simplification: (a|b) & ~(a&b) = a^b" }, { FS_OPT_EOR_A_A, "algebraic simplification: a ^ a = 0" }, - { FS_OPT_EOR_TO_NOT_BOOL,"algebraic simplification: bool ^ 1 = !bool" }, + { FS_OPT_EOR_A_B_A, "algebraic simplification: (a ^ b) ^ a = b" }, + { FS_OPT_EOR_TO_NOT_BOOL,"boolean simplification: bool ^ 1 = !bool" }, { FS_OPT_EOR_TO_NOT, "algebraic simplification: x ^ 0b1..1 = ~x, (a ^ b) & b = ~a & b" }, { FS_OPT_NOT_CMP, "algebraic simplification: !(a cmp b) = a !cmp b" }, - { FS_OPT_OR_SHFT_TO_ROT, "algebraic simplification: (x << c) | (x >> (bits - c)) == Rot(x, c)" }, + { FS_OPT_OR_SHFT_TO_ROTL,"algebraic simplification: (x << c) | (x >> (bits - c)) == Rotl(x, c)" }, { FS_OPT_REASSOC_SHIFT, "algebraic simplification: (x SHF c1) SHF c2 = x SHF (c1+c2)" }, { FS_OPT_SHIFT_AND, "algebraic simplification: (a SHF c) AND (b SHF c) = (a AND b) SHF c" }, { FS_OPT_SHIFT_OR, "algebraic simplification: (a SHF c) OR (b SHF c) = (a OR b) SHF c" }, @@ -97,13 +99,21 @@ static const struct { { FS_OPT_CONV, "algebraic simplification: Conv could be removed" }, { FS_OPT_CAST, "algebraic simplification: a Cast could be removed" }, { FS_OPT_MIN_MAX_EQ, "algebraic simplification: Min(a,a) = Max(a,a) = a" }, + { FS_OPT_MUX_COMBINE, "boolean simplification: two Mux nodes where combined into one" }, + { FS_OPT_MUX_CONV, "boolean simplification: MuxI(sel, 1, 0) = (I)sel" }, + { FS_OPT_MUX_BOOL, "boolean simplification: Muxb(sel, true, false) = sel" }, + { FS_OPT_MUX_NOT_BOOL, "boolean simplification: Muxb(sel, false, true) = Not(sel)" }, + { FS_OPT_MUX_OR_BOOL, "boolean simplification: Muxb(sel, true, x) = Or(sel, x)" }, + { FS_OPT_MUX_ORNOT_BOOL, "boolean simplification: Muxb(sel, x, true) = Or(Not(sel), x)" }, + { FS_OPT_MUX_AND_BOOL, "boolean simplification: Muxb(sel, x, false) = And(sel, x)" }, + { FS_OPT_MUX_ANDNOT_BOOL,"boolean simplification: Muxb(sel, false, x) = And(Not(sel), x)" }, { FS_OPT_MUX_C, "algebraic simplification: Mux(C, f, t) = C ? t : f" }, { FS_OPT_MUX_EQ, "algebraic simplification: Mux(v, x, x) = x" }, - { FS_OPT_MUX_TRANSFORM, "algebraic simplification: Mux(a, b, c) = b OR Mux(a,b, c) = c" }, + { FS_OPT_MUX_TRANSFORM, "algebraic simplification: Mux(t ==/!= f, t, f) = f/t, Mux(t ==/!= 0, -t, t) = -t/t" }, { FS_OPT_MUX_TO_MIN, "algebraic simplification: Mux(a < b, a, b) = Min(a,b)" }, { FS_OPT_MUX_TO_MAX, "algebraic simplification: Mux(a > b, a, b) = Max(a,b)" }, - { FS_OPT_MUX_TO_ABS, "algebraic simplification: Mux(a > b, a, b) = Abs(a,b)" }, - { FS_OPT_MUX_TO_SHR, "algebraic simplification: Mux(a > b, a, b) = a >> b" }, + { FS_OPT_MUX_TO_ABS, "algebraic simplification: Mux(a > 0, a, -a) = Abs(a)" }, + { FS_OPT_MUX_TO_BITOP, "algebraic simplification: Mux((a & 2^x) ==/!= 0, 2^x, 0) = (a & 2^x) (xor 2^x)" }, { FS_OPT_IDEM_UNARY, "algebraic simplification: Idempotent unary operation" }, { FS_OPT_MINUS_NOT, "algebraic simplification: -(~x) = x + 1" }, { FS_OPT_NOT_MINUS_1, "algebraic simplification: ~(x - 1) = -x" }, @@ -122,6 +132,15 @@ static const struct { { FS_OPT_CMP_CNST_MAGN, "CMP optimization: reduced magnitude of a const" }, { FS_OPT_CMP_SHF_TO_AND, "CMP optimization: transformed shift into And" }, { FS_OPT_CMP_MOD_TO_AND, "CMP optimization: transformed Mod into And" }, + { FS_OPT_NOP, "the operation is a NOP" }, + { FS_OPT_GVN_FOLLOWER, "GVN-PRE: replaced a follower" }, + { FS_OPT_GVN_FULLY, "GVN-PRE: replaced by fully redundant value" }, + { FS_OPT_GVN_PARTLY, "GVN-PRE: replaced by partly redundant value" }, + { FS_OPT_COMBO_CONST, "Combo: evaluated into Constant" }, + { FS_OPT_COMBO_CF, "Combo: removed conditional control flow" }, + { FS_OPT_COMBO_FOLLOWER, "Combo: removed a follower" }, + { FS_OPT_COMBO_CONGRUENT,"Combo: replaced by congruent" }, + { FS_OPT_JUMPTHREADING, "Jump threading: removed conditional control flow" }, { FS_OPT_RTS_ABS, "RTS optimization: call to abs() replaced" }, { FS_OPT_RTS_ALLOCA, "RTS optimization: call to alloca() replaced" }, { FS_OPT_RTS_SQRT, "RTS optimization: call to sqrt() replaced" }, @@ -141,9 +160,13 @@ static const struct { { FS_OPT_RTS_SYMMETRIC, "RTS optimization: call to symmetric function f(-x) replaced by f(x)" }, { FS_OPT_RTS_STRCMP, "RTS optimization: call to strcmp() replaced" }, { FS_OPT_RTS_STRNCMP, "RTS optimization: call to strncmp() replaced" }, + { FS_OPT_RTS_STRCPY, "RTS optimization: call to strcpy() replaced" }, + { FS_OPT_RTS_STRLEN, "RTS optimization: call to strlen() replaced" }, { FS_OPT_RTS_MEMCPY, "RTS optimization: call to memcpy() replaced" }, + { FS_OPT_RTS_MEMPCPY, "RTS optimization: call to mempcpy() replaced" }, + { FS_OPT_RTS_MEMMOVE, "RTS optimization: call to memmove() replaced" }, { FS_OPT_RTS_MEMSET, "RTS optimization: call to memset() replaced" }, - { FS_OPT_RTS_STRLEN, "RTS optimization: call to strlen() replaced" }, + { FS_OPT_RTS_MEMCMP, "RTS optimization: call to memcmp() replaced" }, { FS_BE_IA32_LEA, "ia32 Backend transformation: Lea was created" }, { FS_BE_IA32_LOAD_LEA, "ia32 Backend transformation: Load merged with a Lea" }, { FS_BE_IA32_STORE_LEA, "ia32 Backend transformation: Store merged with a Lea" }, @@ -175,36 +198,42 @@ static void simple_dump_opcode_hash(dumper_t *dmp, pset *set) counter_t f_alive; counter_t f_new_node; counter_t f_Id; + counter_t f_normlized; cnt_clr(&f_alive); cnt_clr(&f_new_node); cnt_clr(&f_Id); + cnt_clr(&f_normlized); - fprintf(dmp->f, "%-16s %-8s %-8s %-8s\n", "Opcode", "alive", "created", "->Id"); + fprintf(dmp->f, "%-16s %-8s %-8s %-8s %-8s\n", "Opcode", "alive", "created", "->Id", "normalized"); foreach_pset(set, entry) { - fprintf(dmp->f, "%-16s %8u %8u %8u\n", + fprintf(dmp->f, "%-16s %8u %8u %8u %8u\n", get_id_str(entry->op->name), cnt_to_uint(&entry->cnt_alive), cnt_to_uint(&entry->new_node), - cnt_to_uint(&entry->into_Id) + cnt_to_uint(&entry->into_Id), + cnt_to_uint(&entry->normalized) ); - cnt_add(&f_alive, &entry->cnt_alive); - cnt_add(&f_new_node, &entry->new_node); - cnt_add(&f_Id, &entry->into_Id); + cnt_add(&f_alive, &entry->cnt_alive); + cnt_add(&f_new_node, &entry->new_node); + cnt_add(&f_Id, &entry->into_Id); + cnt_add(&f_normlized, &entry->normalized); } /* foreach_pset */ fprintf(dmp->f, "-------------------------------------------\n"); - fprintf(dmp->f, "%-16s %8u %8u %8u\n", "Sum", + fprintf(dmp->f, "%-16s %8u %8u %8u %8u\n", "Sum", cnt_to_uint(&f_alive), cnt_to_uint(&f_new_node), - cnt_to_uint(&f_Id) + cnt_to_uint(&f_Id), + cnt_to_uint(&f_normlized) ); } /* simple_dump_opcode_hash */ /** * Return the name of an optimization. */ -static const char *get_opt_name(int index) { +static const char *get_opt_name(int index) +{ assert(index < (int) ARR_SIZE(opt_names) && "index out of range"); assert((int) opt_names[index].kind == index && "opt_names broken"); return opt_names[index].name; @@ -262,9 +291,10 @@ static void simple_dump_be_block_reg_pressure(dumper_t *dmp, graph_entry_t *entr } /* simple_dump_be_block_reg_pressure */ /** prints a distribution entry */ -static void simple_dump_distrib_entry(const distrib_entry_t *entry, void *env) { +static void simple_dump_distrib_entry(const distrib_entry_t *entry, void *env) +{ dumper_t *dmp = env; - fprintf(dmp->f, "%12d", cnt_to_uint(&entry->cnt)); + fprintf(dmp->f, "%12u", cnt_to_uint(&entry->cnt)); } /* simple_dump_distrib_entry */ /** @@ -296,7 +326,8 @@ static void simple_dump_be_block_sched_ready(dumper_t *dmp, graph_entry_t *entry /** * Adds the counter for given entry to another distribution table. */ -static void add_distrib_entry(const distrib_entry_t *entry, void *env) { +static void add_distrib_entry(const distrib_entry_t *entry, void *env) +{ distrib_tbl_t *sum_tbl = env; stat_add_int_distrib_tbl(sum_tbl, PTR_TO_INT(entry->object), &entry->cnt); @@ -433,7 +464,7 @@ static void simple_dump_edges(dumper_t *dmp, counter_t *cnt) if (! dmp->f) return; - fprintf(dmp->f, "%-16s %8d\n", "Edges", cnt_to_uint(cnt)); + fprintf(dmp->f, "%-16s %8u\n", "Edges", cnt_to_uint(cnt)); } /* simple_dump_edges */ /** @@ -468,6 +499,7 @@ static void simple_dump_graph(dumper_t *dmp, graph_entry_t *entry) " calls only leaf functions : %s\n" " recursive : %s\n" " chain call : %s\n" + " strict : %s\n" " calls : %u\n" " indirect calls : %u\n" " external calls : %u\n", @@ -480,6 +512,7 @@ static void simple_dump_graph(dumper_t *dmp, graph_entry_t *entry) 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->is_strict ? "YES" : "NO", cnt_to_uint(&entry->cnt[gcnt_all_calls]), cnt_to_uint(&entry->cnt[gcnt_indirect_calls]), cnt_to_uint(&entry->cnt[gcnt_external_calls]) @@ -615,7 +648,8 @@ static void simple_dump_const_tbl(dumper_t *dmp, const constant_info_t *tbl) /** * Dumps a line of the parameter table */ -static void dump_tbl_line(const distrib_entry_t *entry, void *env) { +static void dump_tbl_line(const distrib_entry_t *entry, void *env) +{ dumper_t *dmp = env; fprintf(dmp->f, "%d : %u\n", PTR_TO_INT(entry->object), cnt_to_uint(&entry->cnt)); @@ -624,7 +658,8 @@ static void dump_tbl_line(const distrib_entry_t *entry, void *env) { /** * dumps the parameter distribution table */ -static void simple_dump_param_tbl(dumper_t *dmp, const distrib_tbl_t *tbl, graph_entry_t *global) { +static void simple_dump_param_tbl(dumper_t *dmp, const distrib_tbl_t *tbl, graph_entry_t *global) +{ fprintf(dmp->f, "\nCall parameter Information:\n"); fprintf(dmp->f, "---------------------\n"); @@ -642,7 +677,8 @@ static void simple_dump_param_tbl(dumper_t *dmp, const distrib_tbl_t *tbl, graph /** * dumps the optimization counter table */ -static void simple_dump_opt_cnt(dumper_t *dmp, const counter_t *tbl, unsigned len) { +static void simple_dump_opt_cnt(dumper_t *dmp, const counter_t *tbl, unsigned len) +{ unsigned i; fprintf(dmp->f, "\nOptimization counts:\n"); @@ -660,7 +696,8 @@ static void simple_dump_opt_cnt(dumper_t *dmp, const counter_t *tbl, unsigned le /** * initialize the simple dumper */ -static void simple_init(dumper_t *dmp, const char *name) { +static void simple_init(dumper_t *dmp, const char *name) +{ char fname[2048]; snprintf(fname, sizeof(fname), "%s.txt", name); @@ -673,7 +710,8 @@ static void simple_init(dumper_t *dmp, const char *name) { /** * finishes the simple dumper */ -static void simple_finish(dumper_t *dmp) { +static void simple_finish(dumper_t *dmp) +{ if (dmp->f) fclose(dmp->f); dmp->f = NULL; @@ -757,7 +795,7 @@ static void csv_dump_graph(dumper_t *dmp, graph_entry_t *entry) csv_count_nodes(dmp, entry, cnt); - fprintf(dmp->f, "%-40s, %p, %d, %d, %d, %d\n", + fprintf(dmp->f, "%-40s, %p, %u, %u, %u, %u\n", name, (void *)entry->irg, cnt_to_uint(&cnt[0]), @@ -781,7 +819,8 @@ static void csv_dump_const_tbl(dumper_t *dmp, const constant_info_t *tbl) /** * dumps the parameter distribution table */ -static void csv_dump_param_tbl(dumper_t *dmp, const distrib_tbl_t *tbl, graph_entry_t *global) { +static void csv_dump_param_tbl(dumper_t *dmp, const distrib_tbl_t *tbl, graph_entry_t *global) +{ (void) dmp; (void) tbl; (void) global; @@ -791,7 +830,8 @@ static void csv_dump_param_tbl(dumper_t *dmp, const distrib_tbl_t *tbl, graph_en /** * dumps the optimization counter */ -static void csv_dump_opt_cnt(dumper_t *dmp, const counter_t *tbl, unsigned len) { +static void csv_dump_opt_cnt(dumper_t *dmp, const counter_t *tbl, unsigned len) +{ (void) dmp; (void) tbl; (void) len;