added FS_OPT_SUB_TO_NOT and FS_OPT_SUB_TO_CONV
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Thu, 14 Aug 2008 13:37:49 +0000 (13:37 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Thu, 14 Aug 2008 13:37:49 +0000 (13:37 +0000)
[r21172]

include/libfirm/firmstat.h
ir/ir/iropt.c
ir/stat/stat_dmp.c

index b13c5a7..af4f481 100644 (file)
@@ -60,6 +60,8 @@ enum firmstat_optimizations_t {
        FS_OPT_SUB_SUB_X_Y_Z,                     /**< (x - y) - z = x - (y + z) */
        FS_OPT_SUB_C_NOT_X,                       /**< c - ~a = a + (c+1) */
        FS_OPT_SUB_TO_ADD,                        /**< (-a) - b = -(a + b), a - (b - c) = a + (c - b), a - (b * C) -> a + (b * -C) */
+       FS_OPT_SUB_TO_NOT,                        /**< /* -1 - x -> ~x on two's complement */
+       FS_OPT_SUB_TO_CONV,                       /**< /* a - NULL = (int)a */
        FS_OPT_MUL_MINUS,                         /**< (-a) * (b - c) -> a * (c - b) */
        FS_OPT_MUL_MINUS_1,                       /**< a * -1 = -a */
        FS_OPT_MINUS_MUL_C,                       /**< (-a) * C = a * (-C) */
index 03d03d4..6fc0cef 100644 (file)
@@ -2319,7 +2319,9 @@ static ir_node *transform_node_Sub(ir_node *n) {
                if (is_Const(b) && is_Const_null(b) && mode_is_reference(lmode)) {
                        /* a Sub(a, NULL) is a hidden Conv */
                        dbg_info *dbg = get_irn_dbg_info(n);
-                       return new_rd_Conv(dbg, current_ir_graph, get_nodes_block(n), a, mode);
+                       n = new_rd_Conv(dbg, current_ir_graph, get_nodes_block(n), a, mode);
+                       DBG_OPT_ALGSIM0(oldn, n, FS_OPT_SUB_TO_CONV);
+                       return n;
                }
 
                if (mode == lmode                                     &&
@@ -2328,7 +2330,9 @@ static ir_node *transform_node_Sub(ir_node *n) {
                    get_Const_tarval(a) == get_mode_minus_one(mode)) {
                        /* -1 - x -> ~x */
                        dbg_info *dbg = get_irn_dbg_info(n);
-                       return new_rd_Not(dbg, current_ir_graph, get_nodes_block(n), b, mode);
+                       n = new_rd_Not(dbg, current_ir_graph, get_nodes_block(n), b, mode);
+                       DBG_OPT_ALGSIM0(oldn, n, FS_OPT_SUB_TO_NOT);
+                       return n;
                }
        }
 
index 7e74ccf..967a3f0 100644 (file)
@@ -78,6 +78,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)" },