add first statistic support for GVN-PRE and combo
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Tue, 19 Aug 2008 12:28:40 +0000 (12:28 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Tue, 19 Aug 2008 12:28:40 +0000 (12:28 +0000)
[r21258]

include/libfirm/dbginfo.h
include/libfirm/firmstat.h
include/libfirm/iropt_dbg.h
ir/debug/dbginfo.c
ir/opt/combo.c
ir/stat/stat_dmp.c

index 904dce5..48e2177 100644 (file)
@@ -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;
index ea97abb..8906bba 100644 (file)
@@ -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 */
index f91a5ff..a504c1d 100644 (file)
          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
index b998f55..178ce44 100644 (file)
@@ -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)
index 6ea1d31..8f95093 100644 (file)
@@ -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;
                                }
index 967a3f0..3fb01e6 100644 (file)
@@ -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" },