From 77c348bef494a5d4e1fbf754957884de5c0bfe99 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Tue, 19 Aug 2008 12:28:40 +0000 Subject: [PATCH] add first statistic support for GVN-PRE and combo [r21258] --- include/libfirm/dbginfo.h | 2 ++ include/libfirm/firmstat.h | 7 +++++++ include/libfirm/iropt_dbg.h | 26 ++++++++++++++++++++++++++ ir/debug/dbginfo.c | 2 ++ ir/opt/combo.c | 14 +++++++++++++- ir/stat/stat_dmp.c | 7 +++++++ 6 files changed, 57 insertions(+), 1 deletion(-) diff --git a/include/libfirm/dbginfo.h b/include/libfirm/dbginfo.h index 904dce527..48e2177a7 100644 --- a/include/libfirm/dbginfo.h +++ b/include/libfirm/dbginfo.h @@ -85,6 +85,8 @@ typedef enum { dbg_rem_poly_call, /**< Remove polymorphic call. */ dbg_dead_code, /**< Removing unreachable code, I.e. blocks that are never executed. */ dbg_opt_confirm, /**< A Firm subgraph was replace because of a Confirmation. */ + dbg_gvn_pre, /**< A Firm node was replace because of the GVN-PRE algorithm. */ + dbg_combo, /**< A Firm node was replace because of the combo algorithm. */ dbg_backend, /**< A Firm subgraph was replaced because of a Backend transformation */ dbg_max /**< Maximum value. */ } dbg_action; diff --git a/include/libfirm/firmstat.h b/include/libfirm/firmstat.h index ea97abb06..8906bba79 100644 --- a/include/libfirm/firmstat.h +++ b/include/libfirm/firmstat.h @@ -114,6 +114,13 @@ enum firmstat_optimizations_t { 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: replaced a follower */ + FS_OPT_COMBO_CONGRUENT, /**< Combo: replaced by congruent */ 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 */ diff --git a/include/libfirm/iropt_dbg.h b/include/libfirm/iropt_dbg.h index f91a5ffa8..a504c1dd3 100644 --- a/include/libfirm/iropt_dbg.h +++ b/include/libfirm/iropt_dbg.h @@ -390,4 +390,30 @@ hook_merge_nodes(NULL, 0, &n, 1, HOOK_OPT_CONFIRM_E); \ } while(0) +/** + * Merge the debug info due to a GVN-PRE result. + * + * @param oldn the old node + * @param n the new node replacing oldn + * @param flag firm statistics option + */ +#define DBG_OPT_GVN_PRE(oldn, n, flag) \ + do { \ + hook_merge_nodes(&n, 1, &oldn, 1, flag); \ + __dbg_info_merge_pair(n, oldn, dbg_gvn_pre); \ + } while(0) + +/** + * Merge the debug info due to a combo result. + * + * @param oldn the old node + * @param n the new node replacing oldn + * @param flag firm statistics option + */ +#define DBG_OPT_COMBO(oldn, n, flag) \ + do { \ + hook_merge_nodes(&n, 1, &oldn, 1, flag); \ + __dbg_info_merge_pair(n, oldn, dbg_combo); \ + } while(0) + #endif diff --git a/ir/debug/dbginfo.c b/ir/debug/dbginfo.c index b998f559b..178ce44af 100644 --- a/ir/debug/dbginfo.c +++ b/ir/debug/dbginfo.c @@ -69,6 +69,8 @@ const char *dbg_action_2_str(dbg_action a) { CASE(dbg_rem_poly_call); CASE(dbg_dead_code); CASE(dbg_opt_confirm); + CASE(dbg_gvn_pre); + CASE(dbg_combo); CASE(dbg_backend); default: if (a <= dbg_max) diff --git a/ir/opt/combo.c b/ir/opt/combo.c index 6ea1d311f..8f95093bc 100644 --- a/ir/opt/combo.c +++ b/ir/opt/combo.c @@ -48,6 +48,7 @@ #include "irop.h" #include "irouts.h" #include "irgmod.h" +#include "iropt_dbg.h" #include "debug.h" #include "error.h" @@ -2693,6 +2694,7 @@ static void apply_cf(ir_node *block, void *ctx) { if (can_exchange(pred)) { ir_node *new_block = get_nodes_block(pred); + DBG_OPT_COMBO(block, new_block, FS_OPT_COMBO_CF); exchange(block, new_block); node->node = new_block; env->modified = 1; @@ -2741,6 +2743,7 @@ static void apply_cf(ir_node *block, void *ctx) { set_irn_node(c, node); node->node = c; DB((dbg, LEVEL_1, "%+F is replaced by %+F\n", phi, c)); + DBG_OPT_COMBO(phi, c, FS_OPT_COMBO_CONST); exchange(phi, c); env->modified = 1; } else { @@ -2759,6 +2762,7 @@ static void apply_cf(ir_node *block, void *ctx) { node->node = s; DB((dbg, LEVEL_1, "%+F is replaced by %+F because of cf change\n", phi, s)); + DBG_OPT_COMBO(phi, s, FS_OPT_COMBO_FOLLOWER); exchange(phi, s); phi_node->node = s; env->modified = 1; @@ -2775,6 +2779,7 @@ static void apply_cf(ir_node *block, void *ctx) { if (can_exchange(pred)) { ir_node *new_block = get_nodes_block(pred); + DBG_OPT_COMBO(block, new_block, FS_OPT_COMBO_CF); exchange(block, new_block); node->node = new_block; env->modified = 1; @@ -2830,11 +2835,12 @@ static void apply_result(ir_node *irn, void *ctx) { node_t *sel = get_irn_node(get_Cond_selector(cond)); if (is_tarval(sel->type.tv) && tarval_is_constant(sel->type.tv)) { - /* Cond selector is a constant, make a Jmp */ + /* Cond selector is a constant and the Proj is reachable, make a Jmp */ ir_node *jmp = new_r_Jmp(current_ir_graph, block->node); set_irn_node(jmp, node); node->node = jmp; DB((dbg, LEVEL_1, "%+F is replaced by %+F\n", irn, jmp)); + DBG_OPT_COMBO(irn, jmp, FS_OPT_COMBO_CF); exchange(irn, jmp); env->modified = 1; } @@ -2855,6 +2861,7 @@ static void apply_result(ir_node *irn, void *ctx) { set_irn_node(c, node); node->node = c; DB((dbg, LEVEL_1, "%+F is replaced by %+F\n", irn, c)); + DBG_OPT_COMBO(irn, c, FS_OPT_COMBO_CONST); exchange(irn, c); env->modified = 1; } @@ -2866,6 +2873,7 @@ static void apply_result(ir_node *irn, void *ctx) { node->node = symc; DB((dbg, LEVEL_1, "%+F is replaced by %+F\n", irn, symc)); + DBG_OPT_COMBO(irn, symc, FS_OPT_COMBO_CONST); exchange(irn, symc); env->modified = 1; } @@ -2876,6 +2884,10 @@ static void apply_result(ir_node *irn, void *ctx) { if (leader != irn) { DB((dbg, LEVEL_1, "%+F from part%d is replaced by %+F\n", irn, node->part->nr, leader)); + if (node->is_follower) + DBG_OPT_COMBO(irn, leader, FS_OPT_COMBO_FOLLOWER); + else + DBG_OPT_COMBO(irn, leader, FS_OPT_COMBO_CONGRUENT); exchange(irn, leader); env->modified = 1; } diff --git a/ir/stat/stat_dmp.c b/ir/stat/stat_dmp.c index 967a3f0c5..3fb01e604 100644 --- a/ir/stat/stat_dmp.c +++ b/ir/stat/stat_dmp.c @@ -132,6 +132,13 @@ static const struct { { 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_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" }, -- 2.20.1