Remove ia32_am_ternary. The only users were Div an IDiv, which are perfectly fine...
[libfirm] / ir / be / ia32 / ia32_transform.c
index d73e848..9d01476 100644 (file)
@@ -737,20 +737,19 @@ static void match_arguments(ia32_address_mode_t *am, ir_node *block,
                }
                am->op_type = ia32_AddrModeS;
        } else {
+               am->op_type = ia32_Normal;
+
                if (flags & match_try_am) {
                        am->new_op1 = NULL;
                        am->new_op2 = NULL;
-                       am->op_type = ia32_Normal;
                        return;
                }
 
                new_op1 = (op1 == NULL ? NULL : be_transform_node(op1));
                if (new_op2 == NULL)
                        new_op2 = be_transform_node(op2);
-               am->op_type = ia32_Normal;
-               am->ls_mode = get_irn_mode(op2);
-               if (flags & match_mode_neutral)
-                       am->ls_mode = mode_Iu;
+               am->ls_mode =
+                       (flags & match_mode_neutral ? mode_Iu : get_irn_mode(op2));
        }
        if (addr->base == NULL)
                addr->base = noreg_gp;
@@ -2700,6 +2699,9 @@ static bool upper_bits_clean(ir_node *transformed_node, ir_mode *mode)
        if (get_mode_size_bits(mode) >= 32)
                return true;
 
+       if (is_Proj(transformed_node))
+               return upper_bits_clean(get_Proj_pred(transformed_node), mode);
+
        if (is_ia32_Conv_I2I(transformed_node)
                        || is_ia32_Conv_I2I8Bit(transformed_node)) {
                ir_mode *smaller_mode = get_ia32_ls_mode(transformed_node);
@@ -2721,6 +2723,7 @@ static bool upper_bits_clean(ir_node *transformed_node, ir_mode *mode)
                                return true;
                        }
                }
+               return upper_bits_clean(get_irn_n(transformed_node, n_ia32_Shr_val), mode);
        }
 
        if (is_ia32_And(transformed_node) && !mode_is_signed(mode)) {
@@ -2734,8 +2737,11 @@ static bool upper_bits_clean(ir_node *transformed_node, ir_mode *mode)
                                return true;
                        }
                }
+               /* TODO recurse? */
        }
 
+       /* TODO recurse on Or, Xor, ... if appropriate? */
+
        if (is_ia32_Immediate(transformed_node)
                        || is_ia32_Const(transformed_node)) {
                const ia32_immediate_attr_t *attr
@@ -2805,8 +2811,8 @@ static ir_node *gen_Cmp(ir_node *node)
                                                                                match_8bit | match_16bit);
 
                /* use 32bit compare mode if possible since the opcode is smaller */
-               if (upper_bits_clean(am.new_op1, cmp_mode)
-                               && upper_bits_clean(am.new_op2, cmp_mode)) {
+               if (upper_bits_clean(am.new_op1, cmp_mode) &&
+                   upper_bits_clean(am.new_op2, cmp_mode)) {
                        cmp_mode = mode_is_signed(cmp_mode) ? mode_Is : mode_Iu;
                }
 
@@ -2828,8 +2834,8 @@ static ir_node *gen_Cmp(ir_node *node)
                                match_16bit_am | match_am_and_immediates |
                                match_immediate | match_8bit | match_16bit);
                /* use 32bit compare mode if possible since the opcode is smaller */
-               if (upper_bits_clean(am.new_op1, cmp_mode)
-                               && upper_bits_clean(am.new_op2, cmp_mode)) {
+               if (upper_bits_clean(am.new_op1, cmp_mode) &&
+                   upper_bits_clean(am.new_op2, cmp_mode)) {
                        cmp_mode = mode_is_signed(cmp_mode) ? mode_Is : mode_Iu;
                }