add some comments, DBG_OPT call
[libfirm] / ir / ir / iropt.c
index b98c922..e02a230 100644 (file)
@@ -178,7 +178,7 @@ static tarval *computed_value_Minus(ir_node *n) {
        ir_node *a = get_Minus_op(n);
        tarval *ta = value_of(a);
 
-       if ((ta != tarval_bad) && mode_is_signed(get_irn_mode(a)))
+       if (ta != tarval_bad)
                return tarval_neg(ta);
 
        return tarval_bad;
@@ -1200,7 +1200,7 @@ static ir_node *equivalent_node_Conv(ir_node *n) {
                                n = b; /* Convb(Conv*(xxxb(...))) == xxxb(...) */
                                DBG_OPT_ALGSIM1(oldn, a, b, n, FS_OPT_CONV);
                        } else if (mode_is_int(n_mode)) {
-                               if (smaller_mode(b_mode, a_mode)){
+                               if (get_mode_size_bits(b_mode) <= get_mode_size_bits(a_mode)) {
                                        n = b;        /* ConvS(ConvL(xxxS(...))) == xxxS(...) */
                                        DBG_OPT_ALGSIM1(oldn, a, b, n, FS_OPT_CONV);
                                }
@@ -3177,6 +3177,9 @@ static ir_node *transform_node_Not(ir_node *n) {
  * Optimize:
  *   -(~x) = x + 1
  *   -(a-b) = b - a
+ *   -(a >>u (size-1)) = a >>s (size-1)
+ *   -(a >>s (size-1)) = a >>u (size-1)
+ *   -(a * const) -> a * -const
  */
 static ir_node *transform_node_Minus(ir_node *n) {
        ir_node *c, *oldn = n;
@@ -3252,6 +3255,7 @@ static ir_node *transform_node_Minus(ir_node *n) {
                        ir_graph *irg   = current_ir_graph;
                        ir_node  *block = get_nodes_block(a);
                        n = new_rd_Mul(dbg, irg, block, mul_l, cnst, mode);
+                       DBG_OPT_ALGSIM2(oldn, a, n, FS_OPT_MINUS_MUL_C);
                        return n;
                }
        }
@@ -3657,10 +3661,12 @@ static ir_node *transform_node_Proj_Cmp(ir_node *proj) {
         */
        if (is_Const(right)) {
                c = right;
-       } else if (is_Const(left)) {
+       } else if (is_irn_constlike(left)) {
                c     = left;
                left  = right;
                right = c;
+               if(!is_Const(c))
+                       c = NULL;
 
                proj_nr = get_inversed_pnc(proj_nr);
                changed |= 1;