cleanup dbginfo public API: no dbg_snprint anymore
[libfirm] / ir / ir / iropt.c
index c8d5383..89d4cc5 100644 (file)
@@ -308,7 +308,7 @@ static tarval *computed_value_Eor(const ir_node *n) {
        tb = value_of(b);
 
        if ((ta != tarval_bad) && (tb != tarval_bad)) {
-               return tarval_eor (ta, tb);
+               return tarval_eor(ta, tb);
        }
        return tarval_bad;
 }  /* computed_value_Eor */
@@ -337,7 +337,7 @@ static tarval *computed_value_Shl(const ir_node *n) {
        tarval *tb = value_of(b);
 
        if ((ta != tarval_bad) && (tb != tarval_bad)) {
-               return tarval_shl (ta, tb);
+               return tarval_shl(ta, tb);
        }
        return tarval_bad;
 }  /* computed_value_Shl */
@@ -353,7 +353,7 @@ static tarval *computed_value_Shr(const ir_node *n) {
        tarval *tb = value_of(b);
 
        if ((ta != tarval_bad) && (tb != tarval_bad)) {
-               return tarval_shr (ta, tb);
+               return tarval_shr(ta, tb);
        }
        return tarval_bad;
 }  /* computed_value_Shr */
@@ -369,7 +369,7 @@ static tarval *computed_value_Shrs(const ir_node *n) {
        tarval *tb = value_of(b);
 
        if ((ta != tarval_bad) && (tb != tarval_bad)) {
-               return tarval_shrs (ta, tb);
+               return tarval_shrs(ta, tb);
        }
        return tarval_bad;
 }  /* computed_value_Shrs */
@@ -1596,7 +1596,6 @@ static ir_node *equivalent_node_Proj_CopyB(ir_node *proj) {
                        DBG_OPT_ALGSIM0(oldn, proj, FS_OPT_NOP);
                        break;
 
-               case pn_CopyB_M_except:
                case pn_CopyB_X_except:
                        DBG_OPT_EXC_REM(proj);
                        proj = get_irg_bad(current_ir_graph);
@@ -2775,6 +2774,28 @@ static ir_node *transform_node_Mul(ir_node *n) {
                        DBG_OPT_ALGSIM1(oldn, a, b, n, FS_OPT_MUL_MINUS);
                        return n;
                }
+       } else if (is_Shl(a)) {
+               ir_node *const shl_l = get_Shl_left(a);
+               if (is_Const(shl_l) && is_Const_one(shl_l)) {
+                       /* (1 << x) * b -> b << x */
+                       dbg_info *const dbgi  = get_irn_dbg_info(n);
+                       ir_node  *const block = get_nodes_block(n);
+                       ir_node  *const shl_r = get_Shl_right(a);
+                       n = new_rd_Shl(dbgi, block, b, shl_r, mode);
+                       // TODO add me DBG_OPT_ALGSIM1(oldn, a, b, n, FS_OPT_MUL_SHIFT);
+                       return n;
+               }
+       } else if (is_Shl(b)) {
+               ir_node *const shl_l = get_Shl_left(b);
+               if (is_Const(shl_l) && is_Const_one(shl_l)) {
+                       /* a * (1 << x) -> a << x */
+                       dbg_info *const dbgi  = get_irn_dbg_info(n);
+                       ir_node  *const block = get_nodes_block(n);
+                       ir_node  *const shl_r = get_Shl_right(b);
+                       n = new_rd_Shl(dbgi, block, a, shl_r, mode);
+                       // TODO add me DBG_OPT_ALGSIM1(oldn, a, b, n, FS_OPT_MUL_SHIFT);
+                       return n;
+               }
        }
        if (get_mode_arithmetic(mode) == irma_ieee754) {
                if (is_Const(a)) {
@@ -3273,7 +3294,7 @@ static ir_node *transform_bitwise_distributive(ir_node *n,
                        n = trans_func(n);
                        n = new_r_Conv(blk, n, get_irn_mode(oldn));
 
-                       DBG_OPT_ALGSIM1(oldn, a, b, n, FS_OPT_SHIFT_AND);
+                       DBG_OPT_ALGSIM1(oldn, a, b, n, FS_OPT_CONV);
                        return n;
                }
        }
@@ -4632,7 +4653,6 @@ static ir_node *transform_node_Proj_CopyB(ir_node *proj) {
                        DBG_OPT_EXC_REM(proj);
                        proj = new_r_Jmp(get_nodes_block(copyb));
                        break;
-               case pn_CopyB_M_except:
                case pn_CopyB_X_except:
                        DBG_OPT_EXC_REM(proj);
                        proj = get_irg_bad(get_irn_irg(proj));
@@ -5974,7 +5994,10 @@ static int node_cmp_attr_SymConst(ir_node *a, ir_node *b) {
 
 /** Compares the attributes of two Call nodes. */
 static int node_cmp_attr_Call(ir_node *a, ir_node *b) {
-       return get_irn_call_attr(a) != get_irn_call_attr(b);
+       const call_attr *pa = get_irn_call_attr(a);
+       const call_attr *pb = get_irn_call_attr(b);
+       return (pa->type != pb->type)
+               || (pa->tail_call != pb->tail_call);
 }  /* node_cmp_attr_Call */
 
 /** Compares the attributes of two Sel nodes. */