Commit 9500e1cb authored by Christoph Mallon's avatar Christoph Mallon
Browse files

When making a 'Sub', automatically infer its mode from its operands.

parent d4e62cfa
...@@ -290,7 +290,7 @@ static void rewrite_float_unsigned_Conv(ir_node *node) ...@@ -290,7 +290,7 @@ static void rewrite_float_unsigned_Conv(ir_node *node)
/* true block: Do some arithmetic to use the signed conversion */ /* true block: Do some arithmetic to use the signed conversion */
ir_node *true_block = new_r_Block(irg, ARRAY_SIZE(in_true), in_true); ir_node *true_block = new_r_Block(irg, ARRAY_SIZE(in_true), in_true);
ir_node *true_jmp = new_r_Jmp(true_block); ir_node *true_jmp = new_r_Jmp(true_block);
ir_node *sub = new_r_Sub(true_block, fp_const, fp_x, src_mode); ir_node *sub = new_r_Sub(true_block, fp_const, fp_x);
ir_node *sub_conv = new_rd_Conv(dbgi, true_block, sub, mode_Ls); ir_node *sub_conv = new_rd_Conv(dbgi, true_block, sub, mode_Ls);
ir_node *sign_bit = create_sign_bit_const(irg); ir_node *sign_bit = create_sign_bit_const(irg);
collect_new_start_block_node(sign_bit); collect_new_start_block_node(sign_bit);
......
...@@ -238,11 +238,11 @@ static void lower64_shl(ir_node *node, ir_mode *mode) ...@@ -238,11 +238,11 @@ static void lower64_shl(ir_node *node, ir_mode *mode)
ir_node *shl1 = new_rd_Shl(dbgi, block, left_high, right_low); ir_node *shl1 = new_rd_Shl(dbgi, block, left_high, right_low);
ir_graph *irg = get_irn_irg(node); ir_graph *irg = get_irn_irg(node);
ir_node *c32 = new_r_Const_long(irg, umode, 32); ir_node *c32 = new_r_Const_long(irg, umode, 32);
ir_node *sub = new_rd_Sub(dbgi, block, right_low, c32, umode); ir_node *sub = new_rd_Sub(dbgi, block, right_low, c32);
ir_node *llo_conv = new_rd_Conv(dbgi, block, left_low, mode); ir_node *llo_conv = new_rd_Conv(dbgi, block, left_low, mode);
ir_node *shl2 = new_rd_Shl(dbgi, block, llo_conv, sub); ir_node *shl2 = new_rd_Shl(dbgi, block, llo_conv, sub);
ir_node *or = new_rd_Or(dbgi, block, shl1, shl2); ir_node *or = new_rd_Or(dbgi, block, shl1, shl2);
ir_node *sub2 = new_rd_Sub(dbgi, block, c32, right_low, umode); ir_node *sub2 = new_rd_Sub(dbgi, block, c32, right_low);
ir_node *shr = new_rd_Shr(dbgi, block, llo_conv, sub2); ir_node *shr = new_rd_Shr(dbgi, block, llo_conv, sub2);
ir_node *or2 = new_rd_Or(dbgi, block, or, shr); ir_node *or2 = new_rd_Or(dbgi, block, or, shr);
/* Res_lo = L_lo << R */ /* Res_lo = L_lo << R */
...@@ -271,11 +271,11 @@ static void lower64_shr(ir_node *node, ir_mode *mode) ...@@ -271,11 +271,11 @@ static void lower64_shr(ir_node *node, ir_mode *mode)
ir_node *shr1 = new_rd_Shr(dbgi, block, left_low, right_low); ir_node *shr1 = new_rd_Shr(dbgi, block, left_low, right_low);
ir_graph *irg = get_irn_irg(node); ir_graph *irg = get_irn_irg(node);
ir_node *c32 = new_r_Const_long(irg, umode, 32); ir_node *c32 = new_r_Const_long(irg, umode, 32);
ir_node *sub = new_rd_Sub(dbgi, block, right_low, c32, umode); ir_node *sub = new_rd_Sub(dbgi, block, right_low, c32);
ir_node *lhi_conv = new_rd_Conv(dbgi, block, left_high, umode); ir_node *lhi_conv = new_rd_Conv(dbgi, block, left_high, umode);
ir_node *shr2 = new_rd_Shr(dbgi, block, lhi_conv, sub); ir_node *shr2 = new_rd_Shr(dbgi, block, lhi_conv, sub);
ir_node *or = new_rd_Or(dbgi, block, shr1, shr2); ir_node *or = new_rd_Or(dbgi, block, shr1, shr2);
ir_node *sub2 = new_rd_Sub(dbgi, block, c32, right_low, umode); ir_node *sub2 = new_rd_Sub(dbgi, block, c32, right_low);
ir_node *shl = new_rd_Shl(dbgi, block, lhi_conv, sub2); ir_node *shl = new_rd_Shl(dbgi, block, lhi_conv, sub2);
ir_node *or2 = new_rd_Or(dbgi, block, or, shl); ir_node *or2 = new_rd_Or(dbgi, block, or, shl);
/* Res_hi = L_hi >> R */ /* Res_hi = L_hi >> R */
...@@ -304,7 +304,7 @@ static void lower64_shrs(ir_node *node, ir_mode *mode) ...@@ -304,7 +304,7 @@ static void lower64_shrs(ir_node *node, ir_mode *mode)
ir_node *shr = new_rd_Shr(dbgi, block, left_low, right_low); ir_node *shr = new_rd_Shr(dbgi, block, left_low, right_low);
ir_graph *irg = get_irn_irg(node); ir_graph *irg = get_irn_irg(node);
ir_node *c32 = new_r_Const_long(irg, umode, 32); ir_node *c32 = new_r_Const_long(irg, umode, 32);
ir_node *sub = new_rd_Sub(dbgi, block, c32, right_low, umode); ir_node *sub = new_rd_Sub(dbgi, block, c32, right_low);
ir_node *subs = new_bd_arm_SubS_t(dbgi, block, right_low, c32); ir_node *subs = new_bd_arm_SubS_t(dbgi, block, right_low, c32);
ir_node *subs_res = new_r_Proj(subs, umode, pn_arm_SubS_t_res); ir_node *subs_res = new_r_Proj(subs, umode, pn_arm_SubS_t_res);
ir_node *subs_flags = new_r_Proj(subs, mode_ANY, pn_arm_SubS_t_flags); ir_node *subs_flags = new_r_Proj(subs, mode_ANY, pn_arm_SubS_t_flags);
......
...@@ -201,32 +201,32 @@ static void ia32_lower_sub64(ir_node *node, ir_mode *mode) ...@@ -201,32 +201,32 @@ static void ia32_lower_sub64(ir_node *node, ir_mode *mode)
ir_node *right_low = get_lowered_low(right); ir_node *right_low = get_lowered_low(right);
ir_node *right_high = get_lowered_high(right); ir_node *right_high = get_lowered_high(right);
ir_mode *low_mode = get_irn_mode(left_low); ir_mode *low_mode = get_irn_mode(left_low);
ir_mode *high_mode = get_irn_mode(left_high);
carry_result cr = lower_sub_borrow(left, right, low_mode); carry_result cr = lower_sub_borrow(left, right, low_mode);
assert(get_irn_mode(left_low) == get_irn_mode(right_low)); assert(get_irn_mode(left_low) == get_irn_mode(right_low));
assert(get_irn_mode(left_high) == get_irn_mode(right_high)); assert(get_irn_mode(left_high) == get_irn_mode(right_high));
if (cr == no_carry) { if (cr == no_carry) {
ir_node *sub_low = new_rd_Sub(dbg, block, left_low, right_low, low_mode); ir_node *sub_low = new_rd_Sub(dbg, block, left_low, right_low);
ir_node *sub_high = new_rd_Sub(dbg, block, left_high, right_high, high_mode); ir_node *sub_high = new_rd_Sub(dbg, block, left_high, right_high);
ir_set_dw_lowered(node, sub_low, sub_high); ir_set_dw_lowered(node, sub_low, sub_high);
} else if (cr == must_carry && (is_Const(left_high) || is_Const(right_high))) { } else if (cr == must_carry && (is_Const(left_high) || is_Const(right_high))) {
ir_node *sub_high; ir_node *sub_high;
ir_graph *irg = get_irn_irg(right_high); ir_graph *irg = get_irn_irg(right_high);
ir_mode *high_mode = get_irn_mode(left_high);
ir_node *one = new_rd_Const(dbg, irg, get_mode_one(high_mode)); ir_node *one = new_rd_Const(dbg, irg, get_mode_one(high_mode));
if (is_Const(right_high)) { if (is_Const(right_high)) {
ir_node *new_const = new_rd_Add(dbg, block, right_high, one); ir_node *new_const = new_rd_Add(dbg, block, right_high, one);
sub_high = new_rd_Sub(dbg, block, left_high, new_const, high_mode); sub_high = new_rd_Sub(dbg, block, left_high, new_const);
} else if (is_Const(left_high)) { } else if (is_Const(left_high)) {
ir_node *new_const = new_rd_Sub(dbg, block, left_high, one, high_mode); ir_node *new_const = new_rd_Sub(dbg, block, left_high, one);
sub_high = new_rd_Sub(dbg, block, new_const, right_high, high_mode); sub_high = new_rd_Sub(dbg, block, new_const, right_high);
} else { } else {
panic("logic error"); panic("logic error");
} }
ir_node *sub_low = new_rd_Sub(dbg, block, left_low, right_low, low_mode); ir_node *sub_low = new_rd_Sub(dbg, block, left_low, right_low);
ir_set_dw_lowered(node, sub_low, sub_high); ir_set_dw_lowered(node, sub_low, sub_high);
} else { } else {
/* l_res = a_l - b_l */ /* l_res = a_l - b_l */
...@@ -396,7 +396,7 @@ static void ia32_lower_conv64(ir_node *node, ir_mode *mode) ...@@ -396,7 +396,7 @@ static void ia32_lower_conv64(ir_node *node, ir_mode *mode)
ir_node *fphi_in[] = { ir_node *fphi_in[] = {
opc, opc,
new_rd_Sub(dbg, upper_blk, opc, flt_corr, x86_mode_E) new_rd_Sub(dbg, upper_blk, opc, flt_corr)
}; };
ir_node *flt_phi ir_node *flt_phi
= new_r_Phi(lower_blk, ARRAY_SIZE(fphi_in), fphi_in, = new_r_Phi(lower_blk, ARRAY_SIZE(fphi_in), fphi_in,
......
...@@ -226,8 +226,7 @@ static void rewrite_float_unsigned_Conv(ir_node *node) ...@@ -226,8 +226,7 @@ static void rewrite_float_unsigned_Conv(ir_node *node)
ir_node *c_const = new_r_Const_long(irg, mode_s, 0x80000000L); ir_node *c_const = new_r_Const_long(irg, mode_s, 0x80000000L);
collect_new_start_block_node(c_const); collect_new_start_block_node(c_const);
ir_node *sub = new_rd_Sub(dbgi, true_block, float_x, limitc, ir_node *sub = new_rd_Sub(dbgi, true_block, float_x, limitc);
mode_f);
ir_node *sub_conv = new_rd_Conv(dbgi, true_block, sub, mode_s); ir_node *sub_conv = new_rd_Conv(dbgi, true_block, sub, mode_s);
ir_node *xorn = new_rd_Eor(dbgi, true_block, sub_conv, c_const); ir_node *xorn = new_rd_Eor(dbgi, true_block, sub_conv, c_const);
......
...@@ -410,7 +410,7 @@ static ir_node *build_graph(mul_env *env, instruction *inst) ...@@ -410,7 +410,7 @@ static ir_node *build_graph(mul_env *env, instruction *inst)
case SUB: { case SUB: {
ir_node *l = build_graph(env, inst->in[0]); ir_node *l = build_graph(env, inst->in[0]);
ir_node *r = build_graph(env, inst->in[1]); ir_node *r = build_graph(env, inst->in[1]);
return inst->irn = new_rd_Sub(env->dbg, env->blk, l, r, env->mode); return inst->irn = new_rd_Sub(env->dbg, env->blk, l, r);
} }
case ADD: { case ADD: {
ir_node *l = build_graph(env, inst->in[0]); ir_node *l = build_graph(env, inst->in[0]);
...@@ -838,7 +838,7 @@ static ir_node *replace_div_by_mulh(ir_node *div, ir_tarval *tv) ...@@ -838,7 +838,7 @@ static ir_node *replace_div_by_mulh(ir_node *div, ir_tarval *tv)
if (mag.need_add) if (mag.need_add)
q = new_rd_Add(dbg, block, q, n); q = new_rd_Add(dbg, block, q, n);
else if (mag.need_sub) else if (mag.need_sub)
q = new_rd_Sub(dbg, block, q, n, mode); q = new_rd_Sub(dbg, block, q, n);
/* Do we need the shift */ /* Do we need the shift */
if (mag.s > 0) { if (mag.s > 0) {
...@@ -957,7 +957,7 @@ ir_node *arch_dep_replace_div_by_const(ir_node *irn) ...@@ -957,7 +957,7 @@ ir_node *arch_dep_replace_div_by_const(ir_node *irn)
if (n_flag) { /* negate the result */ if (n_flag) { /* negate the result */
ir_node *k_node = new_r_Const_null(irg, mode); ir_node *k_node = new_r_Const_null(irg, mode);
res = new_rd_Sub(dbg, block, k_node, res, mode); res = new_rd_Sub(dbg, block, k_node, res);
} }
} else { /* unsigned case */ } else { /* unsigned case */
ir_node *k_node = new_r_Const_long(irg, mode_Iu, k); ir_node *k_node = new_r_Const_long(irg, mode_Iu, k);
...@@ -1037,7 +1037,7 @@ ir_node *arch_dep_replace_mod_by_const(ir_node *irn) ...@@ -1037,7 +1037,7 @@ ir_node *arch_dep_replace_mod_by_const(ir_node *irn)
= tarval_shl_unsigned(get_mode_all_one(mode), k); = tarval_shl_unsigned(get_mode_all_one(mode), k);
k_node = new_r_Const(irg, k_val); k_node = new_r_Const(irg, k_val);
curr = new_rd_And(dbg, block, curr, k_node); curr = new_rd_And(dbg, block, curr, k_node);
res = new_rd_Sub(dbg, block, left, curr, mode); res = new_rd_Sub(dbg, block, left, curr);
} else { /* unsigned case */ } else { /* unsigned case */
ir_tarval *k_val ir_tarval *k_val
= tarval_shr_unsigned(get_mode_all_one(mode), = tarval_shr_unsigned(get_mode_all_one(mode),
...@@ -1049,7 +1049,7 @@ ir_node *arch_dep_replace_mod_by_const(ir_node *irn) ...@@ -1049,7 +1049,7 @@ ir_node *arch_dep_replace_mod_by_const(ir_node *irn)
} else if (allow_Mulh(params, mode)) { } else if (allow_Mulh(params, mode)) {
res = replace_div_by_mulh(irn, tv); res = replace_div_by_mulh(irn, tv);
res = new_rd_Mul(dbg, block, res, c); res = new_rd_Mul(dbg, block, res, c);
res = new_rd_Sub(dbg, block, left, res, mode); res = new_rd_Sub(dbg, block, left, res);
} }
return res; return res;
......
...@@ -334,8 +334,7 @@ ir_node *duplicate_subgraph(dbg_info *dbg, ir_node *n, ir_node *block) ...@@ -334,8 +334,7 @@ ir_node *duplicate_subgraph(dbg_info *dbg, ir_node *n, ir_node *block)
case iro_Sub: case iro_Sub:
return new_rd_Sub(dbg, block, return new_rd_Sub(dbg, block,
duplicate_subgraph(dbg, get_Sub_left(n), block), duplicate_subgraph(dbg, get_Sub_left(n), block),
duplicate_subgraph(dbg, get_Sub_right(n), block), duplicate_subgraph(dbg, get_Sub_right(n), block));
mode);
case iro_Mul: case iro_Mul:
return new_rd_Mul(dbg, block, return new_rd_Mul(dbg, block,
duplicate_subgraph(dbg, get_Mul_left(n), block), duplicate_subgraph(dbg, get_Mul_left(n), block),
......
...@@ -243,7 +243,7 @@ static bool normalize_switch(switch_info_t *info, ir_mode *selector_mode) ...@@ -243,7 +243,7 @@ static bool normalize_switch(switch_info_t *info, ir_mode *selector_mode)
ir_graph *irg = get_irn_irg(switchn); ir_graph *irg = get_irn_irg(switchn);
ir_node *min_const = new_r_Const(irg, min); ir_node *min_const = new_r_Const(irg, min);
dbg_info *dbgi = get_irn_dbg_info(switchn); dbg_info *dbgi = get_irn_dbg_info(switchn);
selector = new_rd_Sub(dbgi, block, selector, min_const, mode); selector = new_rd_Sub(dbgi, block, selector, min_const);
info->switch_max = tarval_sub(info->switch_max, min); info->switch_max = tarval_sub(info->switch_max, min);
info->switch_min = get_mode_null(mode); info->switch_min = get_mode_null(mode);
...@@ -286,8 +286,7 @@ static ir_node *create_case_cond(const ir_switch_table_entry *entry, ...@@ -286,8 +286,7 @@ static ir_node *create_case_cond(const ir_switch_table_entry *entry,
cmp = new_rd_Cmp(dbgi, block, selector, minconst, ir_relation_equal); cmp = new_rd_Cmp(dbgi, block, selector, minconst, ir_relation_equal);
} else { } else {
ir_tarval *adjusted_max = tarval_sub(entry->max, entry->min); ir_tarval *adjusted_max = tarval_sub(entry->max, entry->min);
ir_node *sub = new_rd_Sub(dbgi, block, selector, minconst, ir_node *sub = new_rd_Sub(dbgi, block, selector, minconst);
get_tarval_mode(adjusted_max));
ir_node *maxconst = new_r_Const(irg, adjusted_max); ir_node *maxconst = new_r_Const(irg, adjusted_max);
cmp = new_rd_Cmp(dbgi, block, sub, maxconst, ir_relation_less_equal); cmp = new_rd_Cmp(dbgi, block, sub, maxconst, ir_relation_less_equal);
} }
......
...@@ -232,7 +232,7 @@ static ir_node *bool_and(cond_pair* const cpair, ir_node *dst_block) ...@@ -232,7 +232,7 @@ static ir_node *bool_and(cond_pair* const cpair, ir_node *dst_block)
return NULL; return NULL;
} }
c = new_r_Const(irg, tv_lo); c = new_r_Const(irg, tv_lo);
sub = new_r_Sub(block, x, c, mode); sub = new_r_Sub(block, x, c);
subc = new_r_Const(irg, tarval_sub(tv_hi, tv_lo)); subc = new_r_Const(irg, tarval_sub(tv_hi, tv_lo));
cmp = new_r_Cmp(block, sub, subc, rel_hi); cmp = new_r_Cmp(block, sub, subc, rel_hi);
return cmp; return cmp;
...@@ -363,7 +363,7 @@ static ir_node *bool_or(cond_pair *const cpair, ir_node *dst_block) ...@@ -363,7 +363,7 @@ static ir_node *bool_or(cond_pair *const cpair, ir_node *dst_block)
return NULL; return NULL;
} }
c = new_r_Const(irg, tv_lo); c = new_r_Const(irg, tv_lo);
sub = new_r_Sub(block, x, c, mode); sub = new_r_Sub(block, x, c);
subc = new_r_Const(irg, tarval_sub(tv_hi, tv_lo)); subc = new_r_Const(irg, tarval_sub(tv_hi, tv_lo));
cmp = new_r_Cmp(block, sub, subc, rel_hi); cmp = new_r_Cmp(block, sub, subc, rel_hi);
return cmp; return cmp;
......
...@@ -2789,7 +2789,7 @@ static ir_node *transform_node_Eor_(ir_node *n) ...@@ -2789,7 +2789,7 @@ static ir_node *transform_node_Eor_(ir_node *n)
ir_tarval *tab = get_Const_tarval(ab); ir_tarval *tab = get_Const_tarval(ab);
ir_tarval *tc = tarval_sub(tb, tab); ir_tarval *tc = tarval_sub(tb, tab);
ir_node *c = new_rd_Const(dbgi, irg, tc); ir_node *c = new_rd_Const(dbgi, irg, tc);
return new_rd_Sub(dbgi, block, c, aa, mode); return new_rd_Sub(dbgi, block, c, aa);
} }
} else if (is_Sub(a)) { } else if (is_Sub(a)) {
ir_node *aa = get_Sub_left(a); ir_node *aa = get_Sub_left(a);
...@@ -3041,7 +3041,7 @@ static ir_node *transform_node_Add(ir_node *n) ...@@ -3041,7 +3041,7 @@ static ir_node *transform_node_Add(ir_node *n)
ir_node *block = get_nodes_block(n); ir_node *block = get_nodes_block(n);
ir_node *cnst = new_r_Const(irg, tv); ir_node *cnst = new_r_Const(irg, tv);
ir_node *sub_r = get_Sub_right(a); ir_node *sub_r = get_Sub_right(a);
return new_rd_Sub(dbgi, block, cnst, sub_r, mode); return new_rd_Sub(dbgi, block, cnst, sub_r);
} }
} }
} }
...@@ -3079,7 +3079,7 @@ static ir_node *transform_node_Add(ir_node *n) ...@@ -3079,7 +3079,7 @@ static ir_node *transform_node_Add(ir_node *n)
/* -a + b -> b - a */ /* -a + b -> b - a */
dbg_info *const dbgi = get_irn_dbg_info(n); dbg_info *const dbgi = get_irn_dbg_info(n);
ir_node *const block = get_nodes_block(n); ir_node *const block = get_nodes_block(n);
n = new_rd_Sub(dbgi, block, b, get_Minus_op(a), mode); n = new_rd_Sub(dbgi, block, b, get_Minus_op(a));
DBG_OPT_ALGSIM0(oldn, n); DBG_OPT_ALGSIM0(oldn, n);
return n; return n;
} }
...@@ -3087,7 +3087,7 @@ static ir_node *transform_node_Add(ir_node *n) ...@@ -3087,7 +3087,7 @@ static ir_node *transform_node_Add(ir_node *n)
/* a + -b -> a - b */ /* a + -b -> a - b */
dbg_info *const dbgi = get_irn_dbg_info(n); dbg_info *const dbgi = get_irn_dbg_info(n);
ir_node *const block = get_nodes_block(n); ir_node *const block = get_nodes_block(n);
n = new_rd_Sub(dbgi, block, a, get_Minus_op(b), mode); n = new_rd_Sub(dbgi, block, a, get_Minus_op(b));
DBG_OPT_ALGSIM0(oldn, n); DBG_OPT_ALGSIM0(oldn, n);
return n; return n;
} }
...@@ -3106,7 +3106,7 @@ static ir_node *transform_node_Add(ir_node *n) ...@@ -3106,7 +3106,7 @@ static ir_node *transform_node_Add(ir_node *n)
dbg_info *const dbgi = get_irn_dbg_info(n); dbg_info *const dbgi = get_irn_dbg_info(n);
ir_node *const block = get_nodes_block(n); ir_node *const block = get_nodes_block(n);
ir_node *const c = new_rd_Const(dbgi, irg, add); ir_node *const c = new_rd_Const(dbgi, irg, add);
n = new_rd_Sub(dbgi, block, c, op, mode); n = new_rd_Sub(dbgi, block, c, op);
DBG_OPT_ALGSIM0(oldn, n); DBG_OPT_ALGSIM0(oldn, n);
return n; return n;
} }
...@@ -3319,7 +3319,7 @@ static ir_node *transform_node_Sub(ir_node *n) ...@@ -3319,7 +3319,7 @@ static ir_node *transform_node_Sub(ir_node *n)
ir_node *block = get_nodes_block(n); ir_node *block = get_nodes_block(n);
ir_node *cnst = new_r_Const(irg, tv); ir_node *cnst = new_r_Const(irg, tv);
ir_node *add_l = get_Add_left(b); ir_node *add_l = get_Add_left(b);
return new_rd_Sub(dbgi, block, cnst, add_l, mode); return new_rd_Sub(dbgi, block, cnst, add_l);
} }
} }
} }
...@@ -3356,7 +3356,7 @@ static ir_node *transform_node_Sub(ir_node *n) ...@@ -3356,7 +3356,7 @@ static ir_node *transform_node_Sub(ir_node *n)
ir_mode *s_mode = get_irn_mode(b); ir_mode *s_mode = get_irn_mode(b);
if (mode_is_reference(s_mode)) { if (mode_is_reference(s_mode)) {
ir_node *lowest_block = get_nodes_block(n); /* a and b are live here */ ir_node *lowest_block = get_nodes_block(n); /* a and b are live here */
ir_node *sub = new_rd_Sub(s_dbg, lowest_block, a, s_left, mode); ir_node *sub = new_rd_Sub(s_dbg, lowest_block, a, s_left);
dbg_info *a_dbg = get_irn_dbg_info(n); dbg_info *a_dbg = get_irn_dbg_info(n);
if (s_mode != mode) if (s_mode != mode)
...@@ -3364,7 +3364,7 @@ static ir_node *transform_node_Sub(ir_node *n) ...@@ -3364,7 +3364,7 @@ static ir_node *transform_node_Sub(ir_node *n)
n = new_rd_Add(a_dbg, lowest_block, sub, s_right); n = new_rd_Add(a_dbg, lowest_block, sub, s_right);
} else { } else {
ir_node *s_block = get_nodes_block(b); ir_node *s_block = get_nodes_block(b);
ir_node *sub = new_rd_Sub(s_dbg, s_block, s_right, s_left, s_mode); ir_node *sub = new_rd_Sub(s_dbg, s_block, s_right, s_left);
dbg_info *a_dbg = get_irn_dbg_info(n); dbg_info *a_dbg = get_irn_dbg_info(n);
ir_node *a_block = get_nodes_block(n); ir_node *a_block = get_nodes_block(n);
...@@ -3435,12 +3435,11 @@ static ir_node *transform_node_Sub(ir_node *n) ...@@ -3435,12 +3435,11 @@ static ir_node *transform_node_Sub(ir_node *n)
unsigned const mode_size = get_mode_size_bits(mode); unsigned const mode_size = get_mode_size_bits(mode);
unsigned const ma_size = get_mode_size_bits(ma); unsigned const ma_size = get_mode_size_bits(ma);
if (ma_size == mode_size) { if (ma_size == mode_size) {
ir_mode *const offset_mode = get_reference_offset_mode(ma);
/* SubInt(ConvInt(aP), ConvInt(bP)) -> SubInt(aP,bP) */ /* SubInt(ConvInt(aP), ConvInt(bP)) -> SubInt(aP,bP) */
dbg_info *const dbgi = get_irn_dbg_info(n); dbg_info *const dbgi = get_irn_dbg_info(n);
ir_node *const block = get_nodes_block(n); ir_node *const block = get_nodes_block(n);
ir_node *const new_sub ir_node *const new_sub
= new_rd_Sub(dbgi, block, op_a, op_b, offset_mode); = new_rd_Sub(dbgi, block, op_a, op_b);
ir_node *const conv ir_node *const conv
= new_rd_Conv(dbgi, block, new_sub, mode); = new_rd_Conv(dbgi, block, new_sub, mode);
return conv; return conv;
...@@ -3457,7 +3456,7 @@ static ir_node *transform_node_Sub(ir_node *n) ...@@ -3457,7 +3456,7 @@ static ir_node *transform_node_Sub(ir_node *n)
ir_node *const blk = get_nodes_block(n); ir_node *const blk = get_nodes_block(n);
ir_graph *const irg = get_irn_irg(n); ir_graph *const irg = get_irn_irg(n);
ir_node *const one = new_r_Const_one(irg, mode); ir_node *const one = new_r_Const_one(irg, mode);
ir_node *const sub = new_rd_Sub(dbg, blk, y, one, mode); ir_node *const sub = new_rd_Sub(dbg, blk, y, one);
n = new_rd_Mul(dbg, blk, x, sub); n = new_rd_Mul(dbg, blk, x, sub);
DBG_OPT_ALGSIM0(oldn, n); DBG_OPT_ALGSIM0(oldn, n);
return n; return n;
...@@ -3469,7 +3468,7 @@ static ir_node *transform_node_Sub(ir_node *n) ...@@ -3469,7 +3468,7 @@ static ir_node *transform_node_Sub(ir_node *n)
ir_node *blk = get_nodes_block(n); ir_node *blk = get_nodes_block(n);
ir_node *add = new_r_Add(blk, y, b); ir_node *add = new_r_Add(blk, y, b);
n = new_rd_Sub(get_irn_dbg_info(n), blk, x, add, mode); n = new_rd_Sub(get_irn_dbg_info(n), blk, x, add);
DBG_OPT_ALGSIM0(oldn, n); DBG_OPT_ALGSIM0(oldn, n);
return n; return n;
} }
...@@ -3553,8 +3552,7 @@ static ir_node *transform_node_Sub(ir_node *n) ...@@ -3553,8 +3552,7 @@ static ir_node *transform_node_Sub(ir_node *n)
= get_reference_offset_mode(ref_mode); = get_reference_offset_mode(ref_mode);
ir_node *const conv_b = new_r_Conv(block, b, ir_node *const conv_b = new_r_Conv(block, b,
offset_mode); offset_mode);
ir_node *const new_sub = new_rd_Sub(dbgi, block, conv_op, ir_node *const new_sub = new_rd_Sub(dbgi, block, conv_op, conv_b);
conv_b, ref_mode);
ir_node *const conv = new_r_Conv(block, new_sub, mode); ir_node *const conv = new_r_Conv(block, new_sub, mode);
return conv; return conv;
} }
...@@ -3585,7 +3583,7 @@ static ir_node *can_negate_cheaply(dbg_info *const dbgi, ir_node *const node) ...@@ -3585,7 +3583,7 @@ static ir_node *can_negate_cheaply(dbg_info *const dbgi, ir_node *const node)
ir_node *block = get_nodes_block(node); ir_node *block = get_nodes_block(node);
ir_node *left = get_Sub_left(node); ir_node *left = get_Sub_left(node);
ir_node *right = get_Sub_right(node); ir_node *right = get_Sub_right(node);
return new_rd_Sub(dbgi, block, right, left, mode); return new_rd_Sub(dbgi, block, right, left);
} }
/* -(a*const) => a * -const */ /* -(a*const) => a * -const */
if (is_Mul(node)) { if (is_Mul(node)) {
...@@ -3610,7 +3608,7 @@ static ir_node *can_negate_cheaply(dbg_info *const dbgi, ir_node *const node) ...@@ -3610,7 +3608,7 @@ static ir_node *can_negate_cheaply(dbg_info *const dbgi, ir_node *const node)
ir_graph *irg = get_irn_irg(node); ir_graph *irg = get_irn_irg(node);
ir_node *newc = new_r_Const(irg, negtv); ir_node *newc = new_r_Const(irg, negtv);
ir_node *block = get_nodes_block(node); ir_node *block = get_nodes_block(node);
return new_rd_Sub(dbgi, block, newc, left, mode); return new_rd_Sub(dbgi, block, newc, left);
} }
} }
/* -(~x) => x+1 */ /* -(~x) => x+1 */
...@@ -3833,8 +3831,7 @@ transform_div_mul: ...@@ -3833,8 +3831,7 @@ transform_div_mul:
assert((int)pn_Div_X_except == (int)pn_Mod_X_except); assert((int)pn_Div_X_except == (int)pn_Mod_X_except);
exchange(div, mod); exchange(div, mod);
ir_node *block = get_nodes_block(n); ir_node *block = get_nodes_block(n);
return new_rd_Sub(dbgi, block, div_left, div_proj, return new_rd_Sub(dbgi, block, div_left, div_proj);
mode);
} }
} }
} }
...@@ -4031,7 +4028,7 @@ static ir_node *transform_node_Mod(ir_node *n) ...@@ -4031,7 +4028,7 @@ static ir_node *transform_node_Mod(ir_node *n)
ir_node *c = new_rd_Const(dbgi, irg, tv_mul); ir_node *c = new_rd_Const(dbgi, irg, tv_mul);
ir_node *block = get_nodes_block(n); ir_node *block = get_nodes_block(n);
value = new_rd_Sub(dbgi, block, a, c, mode); value = new_rd_Sub(dbgi, block, a, c);
goto make_tuple; goto make_tuple;
} }
} }
...@@ -4582,7 +4579,7 @@ static ir_node *transform_node_Not(ir_node *n) ...@@ -4582,7 +4579,7 @@ static ir_node *transform_node_Not(ir_node *n)
ir_node *block = get_nodes_block(a); ir_node *block = get_nodes_block(a);
ir_node *add_l = get_binop_left(a); ir_node *add_l = get_binop_left(a);
return new_rd_Sub(dbg, block, cnst, add_l, mode); return new_rd_Sub(dbg, block, cnst, add_l);
} }
} }
} else if (is_Sub(a)) { } else if (is_Sub(a)) {
...@@ -4639,15 +4636,13 @@ static ir_node *transform_node_Minus(ir_node *n) ...@@ -4639,15 +4636,13 @@ static ir_node *transform_node_Minus(ir_node *n)
if (negated_l != NULL) { if (negated_l != NULL) {
/* -((a - b) + c) -> (b - a) - c */ /* -((a - b) + c) -> (b - a) - c */
ir_node *block = get_nodes_block(n); ir_node *block = get_nodes_block(n);
ir_mode *mode = get_irn_mode(n); return new_rd_Sub(dbgi, block, negated_l, r);
return new_rd_Sub(dbgi, block, negated_l, r, mode);
} }
ir_node *negated_r = can_negate_cheaply(NULL, r); ir_node *negated_r = can_negate_cheaply(NULL, r);
if (negated_r != NULL) { if (negated_r != NULL) {
/* -(a + (b - c)) -> (c - b) - a */ /* -(a + (b - c)) -> (c - b) - a */
ir_node *block = get_nodes_block(n); ir_node *block = get_nodes_block(n);
ir_mode *mode = get_irn_mode(n); return new_rd_Sub(dbgi, block, negated_r, l);
return new_rd_Sub(dbgi, block, negated_r, l, mode);
} }
} }
if (is_And(op) && only_one_user(op)) { if (is_And(op) && only_one_user(op)) {
...@@ -6032,7 +6027,6 @@ static ir_node *transform_node_shift_modulo(ir_node *n, ...@@ -6032,7 +6027,6 @@ static ir_node *transform_node_shift_modulo(ir_node *n,
ir_graph *irg = get_irn_irg(n); ir_graph *irg = get_irn_irg(n);
ir_node *block = get_nodes_block(n); ir_node *block = get_nodes_block(n);
ir_node *right = get_binop_right(n); ir_node *right = get_binop_right(n);
ir_mode *mode_right = get_irn_mode(right);
ir_node *newop = NULL; ir_node *newop = NULL;
if (is_Const(right)) { if (is_Const(right)) {
ir_tarval *tv = get_Const_tarval(right); ir_tarval *tv = get_Const_tarval(right);
...@@ -6063,7 +6057,7 @@ static ir_node *transform_node_shift_modulo(ir_node *n, ...@@ -6063,7 +6057,7 @@ static ir_node *transform_node_shift_modulo(ir_node *n,
dbg_info *dbgi = get_irn_dbg_info(right); dbg_info *dbgi = get_irn_dbg_info(right);
ir_node *newconst = new_r_Const(irg, tv_mod); ir_node *newconst = new_r_Const(irg, tv_mod);
newop = new_rd_Sub(dbgi, block, newconst, get_Sub_right(right), mode_right); newop = new_rd_Sub(dbgi, block, newconst, get_Sub_right(right));
} }
} else { } else {
return n; return n;
...@@ -6779,7 +6773,7 @@ static ir_node *transform_Mux_set(ir_node *n, ir_relation relation) ...@@ -6779,7 +6773,7 @@ static ir_node *transform_Mux_set(ir_node *n, ir_relation relation)
calc_mode = dest_mode; calc_mode = dest_mode;
} }