Commit 4a810252 authored by Matthias Braun's avatar Matthias Braun
Browse files

iropt: Cleanup

parent b2194941
...@@ -64,10 +64,9 @@ static bool is_Or_Eor_Add(const ir_node *node) ...@@ -64,10 +64,9 @@ static bool is_Or_Eor_Add(const ir_node *node)
/* if each bit is guaranteed to be zero on either the left or right /* if each bit is guaranteed to be zero on either the left or right
* then an Add will have the same effect as the Eor/Or. * then an Add will have the same effect as the Eor/Or.
*/ */
if (bl && br && tarval_is_null(tarval_and(bl->z, br->z))) { if (bl && br && tarval_is_null(tarval_and(bl->z, br->z)))
return true; return true;
} }
}
return false; return false;
} }
...@@ -676,9 +675,8 @@ ir_relation ir_get_possible_cmp_relations(const ir_node *left, ...@@ -676,9 +675,8 @@ ir_relation ir_get_possible_cmp_relations(const ir_node *left,
} }
/* NaN never compares successfully to anything */ /* NaN never compares successfully to anything */
if (tarval_is_nan(tv_l) || tarval_is_nan(tv_r)) { if (tarval_is_nan(tv_l) || tarval_is_nan(tv_r))
return ir_relation_unordered; return ir_relation_unordered;
}
/* a == a is never less or greater (but might be equal or unordered) */ /* a == a is never less or greater (but might be equal or unordered) */
if (left == right) if (left == right)
...@@ -715,13 +713,11 @@ ir_relation ir_get_possible_cmp_relations(const ir_node *left, ...@@ -715,13 +713,11 @@ ir_relation ir_get_possible_cmp_relations(const ir_node *left,
ir_tarval *r_max = tarval_and(r_z, tarval_ornot(r_o, min)); ir_tarval *r_max = tarval_and(r_z, tarval_ornot(r_o, min));
ir_tarval *r_min = tarval_or(r_o, tarval_and(r_z, min)); ir_tarval *r_min = tarval_or(r_o, tarval_and(r_z, min));
if (!(tarval_cmp(l_max, r_min) & ir_relation_greater)) { if (!(tarval_cmp(l_max, r_min) & ir_relation_greater))
possible &= ~ir_relation_greater; possible &= ~ir_relation_greater;
} if (!(tarval_cmp(l_min, r_max) & ir_relation_less))
if (!(tarval_cmp(l_min, r_max) & ir_relation_less)) {
possible &= ~ir_relation_less; possible &= ~ir_relation_less;
} }
}
if (!tarval_is_null(tarval_andnot(l_o, r_z)) if (!tarval_is_null(tarval_andnot(l_o, r_z))
|| !tarval_is_null(tarval_andnot(r_o, l_z))) { || !tarval_is_null(tarval_andnot(r_o, l_z))) {
...@@ -739,9 +735,8 @@ ir_relation ir_get_possible_cmp_relations(const ir_node *left, ...@@ -739,9 +735,8 @@ ir_relation ir_get_possible_cmp_relations(const ir_node *left,
if (is_And(right) && !mode_is_signed(mode) && get_commutative_other_op(right, left)) if (is_And(right) && !mode_is_signed(mode) && get_commutative_other_op(right, left))
possible &= ~ir_relation_less; possible &= ~ir_relation_less;
/* stuff known through confirm nodes */ /* stuff known through confirm nodes */
if (is_Confirm(left) && get_Confirm_bound(left) == right) { if (is_Confirm(left) && get_Confirm_bound(left) == right)
possible &= get_Confirm_relation(left); possible &= get_Confirm_relation(left);
}
if (is_Confirm(right) && get_Confirm_bound(right) == left) { if (is_Confirm(right) && get_Confirm_bound(right) == left) {
ir_relation relation = get_Confirm_relation(right); ir_relation relation = get_Confirm_relation(right);
relation = get_inversed_relation(relation); relation = get_inversed_relation(relation);
...@@ -865,8 +860,7 @@ static ir_tarval *do_computed_value_Mod(const ir_node *a, const ir_node *b) ...@@ -865,8 +860,7 @@ static ir_tarval *do_computed_value_Mod(const ir_node *a, const ir_node *b)
/* a % 1 == 0 */ /* a % 1 == 0 */
/* a % -1 == 0 */ /* a % -1 == 0 */
ir_mode *mode = get_irn_mode(a); ir_mode *mode = get_irn_mode(a);
if (tarval_is_one(tb) if (tarval_is_one(tb) || (mode_is_signed(mode) && tarval_is_all_one(tb)))
|| (mode_is_signed(mode) && tarval_is_all_one(tb)))
return get_mode_null(mode); return get_mode_null(mode);
/* constant folding */ /* constant folding */
...@@ -1483,8 +1477,7 @@ static ir_node *equivalent_node_Proj_Store(ir_node *proj) ...@@ -1483,8 +1477,7 @@ static ir_node *equivalent_node_Proj_Store(ir_node *proj)
if (is_Proj(store_mem) && is_Proj(store_value)) { if (is_Proj(store_mem) && is_Proj(store_value)) {
const ir_node *load = get_Proj_pred(store_mem); const ir_node *load = get_Proj_pred(store_mem);
if (is_Load(load) && if (is_Load(load) && get_Proj_pred(store_value) == load &&
get_Proj_pred(store_value) == load &&
get_Load_ptr(load) == store_ptr) { get_Load_ptr(load) == store_ptr) {
return store_mem; return store_mem;
} }
...@@ -1541,11 +1534,10 @@ static ir_node *equivalent_node_Mux(ir_node *n) ...@@ -1541,11 +1534,10 @@ static ir_node *equivalent_node_Mux(ir_node *n)
const ir_node *sel = get_Mux_sel(n); const ir_node *sel = get_Mux_sel(n);
const ir_tarval *ts = value_of(sel); const ir_tarval *ts = value_of(sel);
if (!tarval_is_constant(ts) && is_Cmp(sel)) {
/* try again with a direct call to compute_cmp, as we don't care /* try again with a direct call to compute_cmp, as we don't care
* about the MODEB_LOWERED flag here */ * about the MODEB_LOWERED flag here */
if (!tarval_is_constant(ts) && is_Cmp(sel))
ts = compute_cmp_ext(sel); ts = compute_cmp_ext(sel);
}
/* Mux(true, f, t) == t */ /* Mux(true, f, t) == t */
if (ts == tarval_b_true) { if (ts == tarval_b_true) {
...@@ -1699,7 +1691,7 @@ static bool only_one_user(const ir_node *node) ...@@ -1699,7 +1691,7 @@ static bool only_one_user(const ir_node *node)
*/ */
static bool is_const_Phi(ir_node *n) static bool is_const_Phi(ir_node *n)
{ {
if (! is_Phi(n) || get_irn_arity(n) == 0) if (!is_Phi(n) || get_irn_arity(n) == 0)
return false; return false;
foreach_irn_in_r(n, i, pred) { foreach_irn_in_r(n, i, pred) {
if (!is_Const(pred)) if (!is_Const(pred))
...@@ -1714,9 +1706,7 @@ static bool is_const_Phi(ir_node *n) ...@@ -1714,9 +1706,7 @@ static bool is_const_Phi(ir_node *n)
*/ */
static int is_const_Mux(ir_node *n) static int is_const_Mux(ir_node *n)
{ {
return is_Mux(n) && return is_Mux(n) && is_Const(get_Mux_false(n)) && is_Const(get_Mux_true(n));
is_Const(get_Mux_false(n)) &&
is_Const(get_Mux_true(n));
} }
typedef ir_tarval *(*tarval_binop_type)(ir_tarval *a, ir_tarval *b); typedef ir_tarval *(*tarval_binop_type)(ir_tarval *a, ir_tarval *b);
...@@ -1741,10 +1731,9 @@ static ir_node *apply_binop_on_phi(ir_node *phi, ir_tarval *other, tarval_binop_ ...@@ -1741,10 +1731,9 @@ static ir_node *apply_binop_on_phi(ir_node *phi, ir_tarval *other, tarval_binop_
ir_tarval *tv = get_Const_tarval(pred); ir_tarval *tv = get_Const_tarval(pred);
ir_tarval *evaluated = eval(other, tv); ir_tarval *evaluated = eval(other, tv);
if (!tarval_is_constant(evaluated)) { /* abort if folding failed */
/* folding failed, abort */ if (!tarval_is_constant(evaluated))
return NULL; return NULL;
}
tvs[i] = evaluated; tvs[i] = evaluated;
} }
} else { } else {
...@@ -1752,10 +1741,9 @@ static ir_node *apply_binop_on_phi(ir_node *phi, ir_tarval *other, tarval_binop_ ...@@ -1752,10 +1741,9 @@ static ir_node *apply_binop_on_phi(ir_node *phi, ir_tarval *other, tarval_binop_
ir_tarval *tv = get_Const_tarval(pred); ir_tarval *tv = get_Const_tarval(pred);
ir_tarval *evaluated = eval(tv, other); ir_tarval *evaluated = eval(tv, other);
if (!tarval_is_constant(evaluated)) { /* abort if folding failed */
/* folding failed, abort */ if (!tarval_is_constant(evaluated))
return NULL; return NULL;
}
tvs[i] = evaluated; tvs[i] = evaluated;
} }
} }
...@@ -1792,10 +1780,9 @@ static ir_node *apply_binop_on_2_phis(ir_node *a, ir_node *b, tarval_binop_type ...@@ -1792,10 +1780,9 @@ static ir_node *apply_binop_on_2_phis(ir_node *a, ir_node *b, tarval_binop_type
ir_tarval *tv_r = get_Const_tarval(pred_b); ir_tarval *tv_r = get_Const_tarval(pred_b);
ir_tarval *tv = eval(tv_l, tv_r); ir_tarval *tv = eval(tv_l, tv_r);
if (!tarval_is_constant(tv)) { /* abort if folding failed */
/* folding failed, bad */ if (!tarval_is_constant(tv))
return NULL; return NULL;
}
tvs[i] = tv; tvs[i] = tv;
} }
ir_graph *irg = get_irn_irg(a); ir_graph *irg = get_irn_irg(a);
...@@ -1823,10 +1810,9 @@ static ir_node *apply_unop_on_phi(ir_node *phi, ir_tarval *(*eval)(ir_tarval *)) ...@@ -1823,10 +1810,9 @@ static ir_node *apply_unop_on_phi(ir_node *phi, ir_tarval *(*eval)(ir_tarval *))
ir_tarval *tv = get_Const_tarval(pred); ir_tarval *tv = get_Const_tarval(pred);
tv = eval(tv); tv = eval(tv);
if (!tarval_is_constant(tv)) { /* abort if folding failed */
/* folding failed, abort */ if (!tarval_is_constant(tv))
return NULL; return NULL;
}
tvs[i] = tv; tvs[i] = tv;
} }
ir_graph *irg = get_irn_irg(phi); ir_graph *irg = get_irn_irg(phi);
...@@ -1854,10 +1840,9 @@ static ir_node *apply_conv_on_phi(ir_node *phi, ir_mode *mode) ...@@ -1854,10 +1840,9 @@ static ir_node *apply_conv_on_phi(ir_node *phi, ir_mode *mode)
ir_tarval *tv = get_Const_tarval(pred); ir_tarval *tv = get_Const_tarval(pred);
tv = tarval_convert_to(tv, mode); tv = tarval_convert_to(tv, mode);
if (!tarval_is_constant(tv)) { /* abort if folding failed */
/* folding failed, abort */ if (!tarval_is_constant(tv))
return NULL; return NULL;
}
tvs[i] = tv; tvs[i] = tv;
} }
ir_graph *irg = get_irn_irg(phi); ir_graph *irg = get_irn_irg(phi);
...@@ -1882,9 +1867,8 @@ static ir_node *apply_conv_on_phi(ir_node *phi, ir_mode *mode) ...@@ -1882,9 +1867,8 @@ static ir_node *apply_conv_on_phi(ir_node *phi, ir_mode *mode)
*/ */
static ir_node *apply_binop_on_mux(ir_node *mux, ir_tarval *other, tarval_binop_type eval, ir_mode *mode, bool left) static ir_node *apply_binop_on_mux(ir_node *mux, ir_tarval *other, tarval_binop_type eval, ir_mode *mode, bool left)
{ {
if (!only_one_user(mux)) { if (!only_one_user(mux))
return NULL; return NULL;
}
ir_tarval *true_val = get_Const_tarval(get_Mux_true(mux)); ir_tarval *true_val = get_Const_tarval(get_Mux_true(mux));
ir_tarval *false_val = get_Const_tarval(get_Mux_false(mux)); ir_tarval *false_val = get_Const_tarval(get_Mux_false(mux));
...@@ -1898,9 +1882,8 @@ static ir_node *apply_binop_on_mux(ir_node *mux, ir_tarval *other, tarval_binop_ ...@@ -1898,9 +1882,8 @@ static ir_node *apply_binop_on_mux(ir_node *mux, ir_tarval *other, tarval_binop_
new_false = eval(false_val, other); new_false = eval(false_val, other);
} }
if (!tarval_is_constant(new_true) || !tarval_is_constant(new_false)) { if (!tarval_is_constant(new_true) || !tarval_is_constant(new_false))
return NULL; return NULL;
}
ir_node *sel = get_Mux_sel(mux); ir_node *sel = get_Mux_sel(mux);
ir_graph *irg = get_irn_irg(mux); ir_graph *irg = get_irn_irg(mux);
...@@ -1922,12 +1905,10 @@ static ir_node *apply_binop_on_mux(ir_node *mux, ir_tarval *other, tarval_binop_ ...@@ -1922,12 +1905,10 @@ static ir_node *apply_binop_on_mux(ir_node *mux, ir_tarval *other, tarval_binop_
*/ */
static ir_node *apply_binop_on_2_muxs(ir_node *a, ir_node *b, tarval_binop_type eval, ir_mode *mode) static ir_node *apply_binop_on_2_muxs(ir_node *a, ir_node *b, tarval_binop_type eval, ir_mode *mode)
{ {
if (!only_one_user(a) || !only_one_user(b)) { if (!only_one_user(a) || !only_one_user(b))
return NULL; return NULL;
} if (get_nodes_block(a) != get_nodes_block(b))
if (get_nodes_block(a) != get_nodes_block(b)) {
return NULL; return NULL;
}
ir_node *sel_a = get_Mux_sel(a); ir_node *sel_a = get_Mux_sel(a);
ir_node *sel_b = get_Mux_sel(b); ir_node *sel_b = get_Mux_sel(b);
...@@ -1944,9 +1925,8 @@ static ir_node *apply_binop_on_2_muxs(ir_node *a, ir_node *b, tarval_binop_type ...@@ -1944,9 +1925,8 @@ static ir_node *apply_binop_on_2_muxs(ir_node *a, ir_node *b, tarval_binop_type
ir_tarval *new_false = eval(false_a, false_b); ir_tarval *new_false = eval(false_a, false_b);
ir_tarval *new_true = eval(true_a, true_b); ir_tarval *new_true = eval(true_a, true_b);
if (!tarval_is_constant(new_true) || !tarval_is_constant(new_false)) { if (!tarval_is_constant(new_true) || !tarval_is_constant(new_false))
return NULL; return NULL;
}
ir_graph *irg = get_irn_irg(a); ir_graph *irg = get_irn_irg(a);
ir_node *irn_false = new_r_Const(irg, new_false); ir_node *irn_false = new_r_Const(irg, new_false);
...@@ -1968,9 +1948,8 @@ static ir_node *apply_binop_on_2_muxs(ir_node *a, ir_node *b, tarval_binop_type ...@@ -1968,9 +1948,8 @@ static ir_node *apply_binop_on_2_muxs(ir_node *a, ir_node *b, tarval_binop_type
*/ */
static ir_node *apply_unop_on_mux(ir_node *mux, ir_tarval *(*eval)(ir_tarval *)) static ir_node *apply_unop_on_mux(ir_node *mux, ir_tarval *(*eval)(ir_tarval *))
{ {
if (!only_one_user(mux)) { if (!only_one_user(mux))
return NULL; return NULL;
}
ir_tarval *true_val = get_Const_tarval(get_Mux_true(mux)); ir_tarval *true_val = get_Const_tarval(get_Mux_true(mux));
ir_tarval *false_val = get_Const_tarval(get_Mux_false(mux)); ir_tarval *false_val = get_Const_tarval(get_Mux_false(mux));
...@@ -1978,9 +1957,8 @@ static ir_node *apply_unop_on_mux(ir_node *mux, ir_tarval *(*eval)(ir_tarval *)) ...@@ -1978,9 +1957,8 @@ static ir_node *apply_unop_on_mux(ir_node *mux, ir_tarval *(*eval)(ir_tarval *))
ir_tarval *new_true = eval(true_val); ir_tarval *new_true = eval(true_val);
ir_tarval *new_false = eval(false_val); ir_tarval *new_false = eval(false_val);
if (!tarval_is_constant(new_true) || !tarval_is_constant(new_false)) { if (!tarval_is_constant(new_true) || !tarval_is_constant(new_false))
return NULL; return NULL;
}
ir_node *sel = get_Mux_sel(mux); ir_node *sel = get_Mux_sel(mux);
ir_graph *irg = get_irn_irg(mux); ir_graph *irg = get_irn_irg(mux);
...@@ -2000,9 +1978,8 @@ static ir_node *apply_unop_on_mux(ir_node *mux, ir_tarval *(*eval)(ir_tarval *)) ...@@ -2000,9 +1978,8 @@ static ir_node *apply_unop_on_mux(ir_node *mux, ir_tarval *(*eval)(ir_tarval *))
*/ */
static ir_node *apply_conv_on_mux(ir_node *mux, ir_mode *mode) static ir_node *apply_conv_on_mux(ir_node *mux, ir_mode *mode)
{ {
if (!only_one_user(mux)) { if (!only_one_user(mux))
return NULL; return NULL;
}
ir_tarval *true_val = get_Const_tarval(get_Mux_true(mux)); ir_tarval *true_val = get_Const_tarval(get_Mux_true(mux));
ir_tarval *false_val = get_Const_tarval(get_Mux_false(mux)); ir_tarval *false_val = get_Const_tarval(get_Mux_false(mux));
...@@ -2010,9 +1987,8 @@ static ir_node *apply_conv_on_mux(ir_node *mux, ir_mode *mode) ...@@ -2010,9 +1987,8 @@ static ir_node *apply_conv_on_mux(ir_node *mux, ir_mode *mode)
ir_tarval *new_true = tarval_convert_to(true_val, mode); ir_tarval *new_true = tarval_convert_to(true_val, mode);
ir_tarval *new_false = tarval_convert_to(false_val, mode); ir_tarval *new_false = tarval_convert_to(false_val, mode);
if (!tarval_is_constant(new_true) || !tarval_is_constant(new_false)) { if (!tarval_is_constant(new_true) || !tarval_is_constant(new_false))
return NULL; return NULL;
}
ir_node *sel = get_Mux_sel(mux); ir_node *sel = get_Mux_sel(mux);
ir_graph *irg = get_irn_irg(mux); ir_graph *irg = get_irn_irg(mux);
...@@ -2104,9 +2080,8 @@ static bool operands_are_normalized(const ir_node *l, const ir_node *r) ...@@ -2104,9 +2080,8 @@ static bool operands_are_normalized(const ir_node *l, const ir_node *r)
{ {
const const_class l_order = classify_const(l); const const_class l_order = classify_const(l);
const const_class r_order = classify_const(r); const const_class r_order = classify_const(r);
return return l_order > r_order
l_order > r_order || || (l_order == r_order && get_irn_idx(l) <= get_irn_idx(r));
(l_order == r_order && get_irn_idx(l) <= get_irn_idx(r));
} }
static bool is_cmp_unequal(const ir_node *node) static bool is_cmp_unequal(const ir_node *node)
...@@ -2313,10 +2288,8 @@ static ir_node *transform_bitwise_distributive(ir_node *n) ...@@ -2313,10 +2288,8 @@ static ir_node *transform_bitwise_distributive(ir_node *n)
} }
} }
if (op == op_Eor) { if (op == op_Eor)
/* nothing to gain here */ return n; /* nothing to gain here */
return n;
}
if (op == op_Shrs || op == op_Shr || op == op_Shl if (op == op_Shrs || op == op_Shr || op == op_Shl
|| op == op_And || op == op_Or || op == op_Eor) { || op == op_And || op == op_Or || op == op_Eor) {
...@@ -2401,10 +2374,9 @@ static ir_node *transform_node_bitop_shift(ir_node *n) ...@@ -2401,10 +2374,9 @@ static ir_node *transform_node_bitop_shift(ir_node *n)
return n; return n;
/* doing it with Shrs is not legal if the Or/Eor affects the topmost bit */ /* doing it with Shrs is not legal if the Or/Eor affects the topmost bit */
if (is_Shrs(left)) {
/* TODO this could be improved */ /* TODO this could be improved */
if (is_Shrs(left))
return n; return n;
}
ir_node *shift_left = get_binop_left(left); ir_node *shift_left = get_binop_left(left);
ir_node *block = get_nodes_block(n); ir_node *block = get_nodes_block(n);
...@@ -2428,13 +2400,10 @@ static ir_node *transform_node_bitop_shift(ir_node *n) ...@@ -2428,13 +2400,10 @@ static ir_node *transform_node_bitop_shift(ir_node *n)
} }
} else { } else {
assert(is_Shr(left)); assert(is_Shr(left));
if (!is_And(n)) { /* TODO this can be improved by checking whether
/* * the left shift produces an overflow */
* TODO this can be improved by checking whether if (!is_And(n))
* the left shift produces an overflow
*/
return n; return n;
}
tv_bitop = tarval_shl(tv2, tv1); tv_bitop = tarval_shl(tv2, tv1);
} }
ir_node *new_bitop; ir_node *new_bitop;
...@@ -2903,9 +2872,8 @@ static ir_node *transform_node_Eor_(ir_node *n) ...@@ -2903,9 +2872,8 @@ static ir_node *transform_node_Eor_(ir_node *n)
assert(is_Or(tb)); assert(is_Or(tb));
t = new_rd_And(dbgi, block, new_rd_Not(dbgi, block, l, mode), r, mode); t = new_rd_And(dbgi, block, new_rd_Not(dbgi, block, l, mode), r, mode);
} }
if (nots) { if (nots)
t = new_rd_Not(dbgi, block, t, mode); t = new_rd_Not(dbgi, block, t, mode);
}
return t; return t;
} }
} }
...@@ -2937,9 +2905,8 @@ static ir_node *transform_node_Eor_(ir_node *n) ...@@ -2937,9 +2905,8 @@ static ir_node *transform_node_Eor_(ir_node *n)
assert(is_Or(ta)); assert(is_Or(ta));
t = new_rd_And(dbgi, block, new_rd_Not(dbgi, block, l, mode), r, mode); t = new_rd_And(dbgi, block, new_rd_Not(dbgi, block, l, mode), r, mode);
} }
if (nots) { if (nots)
t = new_rd_Not(dbgi, block, t, mode); t = new_rd_Not(dbgi, block, t, mode);
}
return t; return t;
} }
} }
...@@ -3326,18 +3293,16 @@ static ir_node *transform_node_Sub(ir_node *n) ...@@ -3326,18 +3293,16 @@ static ir_node *transform_node_Sub(ir_node *n)
/* FIXME: Does the Conv's work only for two complement or generally? */ /* FIXME: Does the Conv's work only for two complement or generally? */
if (left == b) { if (left == b) {
if (mode != get_irn_mode(right)) {
/* This Sub is an effective Cast */ /* This Sub is an effective Cast */
if (mode != get_irn_mode(right))
right = new_r_Conv(get_nodes_block(n), right, mode); right = new_r_Conv(get_nodes_block(n), right, mode);
}
n = right; n = right;
DBG_OPT_ALGSIM1(oldn, a, b, n); DBG_OPT_ALGSIM1(oldn, a, b, n);
return n; return n;
} else if (right == b) { } else if (right == b) {
if (mode != get_irn_mode(left)) {
/* This Sub is an effective Cast */ /* This Sub is an effective Cast */
if (mode != get_irn_mode(left))
left = new_r_Conv(get_nodes_block(n), left, mode); left = new_r_Conv(get_nodes_block(n), left, mode);
}
n = left; n = left;
DBG_OPT_ALGSIM1(oldn, a, b, n); DBG_OPT_ALGSIM1(oldn, a, b, n);
return n; return n;
...@@ -3352,20 +3317,18 @@ static ir_node *transform_node_Sub(ir_node *n) ...@@ -3352,20 +3317,18 @@ static ir_node *transform_node_Sub(ir_node *n)
ir_mode *r_mode = get_irn_mode(right); ir_mode *r_mode = get_irn_mode(right);
n = new_r_Minus(get_nodes_block(n), right, r_mode); n = new_r_Minus(get_nodes_block(n), right, r_mode);
if (mode != r_mode) {
/* This Sub is an effective Cast */ /* This Sub is an effective Cast */
if (mode != r_mode)
n = new_r_Conv(get_nodes_block(n), n, mode); n = new_r_Conv(get_nodes_block(n), n, mode);
}
DBG_OPT_ALGSIM1(oldn, a, b, n); DBG_OPT_ALGSIM1(oldn, a, b, n);
return n; return n;
} else if (right == a) { } else if (right == a) {
ir_mode *l_mode = get_irn_mode(left); ir_mode *l_mode = get_irn_mode(left);
n = new_r_Minus(get_nodes_block(n), left, l_mode); n = new_r_Minus(get_nodes_block(n), left, l_mode);
if (mode != l_mode) {
/* This Sub is an effective Cast */ /* This Sub is an effective Cast */
if (mode != l_mode)
n = new_r_Conv(get_nodes_block(n), n, mode); n = new_r_Conv(get_nodes_block(n), n, mode);
}
DBG_OPT_ALGSIM1(oldn, a, b, n); DBG_OPT_ALGSIM1(oldn, a, b, n);
return n; return n;
} }
...@@ -3535,9 +3498,8 @@ static ir_node *can_negate_cheaply(dbg_info *const dbgi, ir_node *const node) ...@@ -3535,9 +3498,8 @@ static ir_node *can_negate_cheaply(dbg_info *const dbgi, ir_node *const node)
return new_r_Const(irg, negtv); return new_r_Const(irg, negtv);
} }
/* -(-X) => X */ /* -(-X) => X */
if (is_Minus(node)) { if (is_Minus(node))
return get_Minus_op(node); return get_Minus_op(node);
}
/* -(a-b) => b-a */ /* -(a-b) => b-a */
ir_mode *mode = get_irn_mode(node); ir_mode *mode = get_irn_mode(node);
if (is_Sub(node)) { if (is_Sub(node)) {
...@@ -3763,11 +3725,10 @@ static ir_node *transform_node_Mul(ir_node *n) ...@@ -3763,11 +3725,10 @@ static ir_node *transform_node_Mul(ir_node *n)
div = get_Proj_pred(div_proj); div = get_Proj_pred(div_proj);
if (is_Div(div)) { if (is_Div(div)) {
div_right = get_Div_right(div); div_right = get_Div_right(div);
if (div_right == b) { if (div_right == b)
goto transform_div_mul; goto transform_div_mul;
} }
} }
}
if (is_Proj(b)) { if (is_Proj(b)) {
div_proj = b; div_proj = b;
div = get_Proj_pred(div_proj); div = get_Proj_pred(div_proj);
...@@ -4023,11 +3984,10 @@ static ir_node *transform_node_Cond(ir_node *n) ...@@ -4023,11 +3984,10 @@ static ir_node *transform_node_Cond(ir_node *n)
ir_node *a = get_Cond_selector(n); ir_node *a = get_Cond_selector(n);
ir_tarval *ta = value_of(a); ir_tarval *ta = value_of(a);
if (!tarval_is_constant(ta) && is_Cmp(a)) {
/* try again with a direct call to compute_cmp, as we don't care /* try again with a direct call to compute_cmp, as we don't care
* about the MODEB_LOWERED flag here */ * about the MODEB_LOWERED flag here */
if (!tarval_is_constant(ta) && is_Cmp(a))
ta = compute_cmp_ext(a); ta = compute_cmp_ext(a);
}
if (tarval_is_constant(ta)) { if (tarval_is_constant(ta)) {
/* It's branching on a boolean constant. /* It's branching on a boolean constant.
...@@ -4146,10 +4106,9 @@ static ir_node *transform_node_shift_bitop(ir_node *n) ...@@ -4146,10 +4106,9 @@ static ir_node *transform_node_shift_bitop(ir_node *n)
return n; return n;
/* doing it with Shrs is not legal if the Or/Eor affects the topmost bit */ /* doing it with Shrs is not legal if the Or/Eor affects the topmost bit */
if (is_Shrs(n) && (op_left == op_Or || op_left == op_Eor)) {
/* TODO: test if sign bit is affected */ /* TODO: test if sign bit is affected */
if (is_Shrs(n) && (op_left == op_Or || op_left == op_Eor))
return n; return n;
}
ir_node *bitop_right = get_binop_right(left); ir_node *bitop_right = get_binop_right(left);
if (!is_Const(bitop_right)) if (!is_Const(bitop_right))
...@@ -4776,10 +4735,10 @@ static ir_node *transform_node_Proj_Div(ir_node *proj) ...@@ -4776,10 +4735,10 @@ static ir_node *transform_node_Proj_Div(ir_node *proj)
ir_node *res = get_Div_mem(div); ir_node *res = get_Div_mem(div);
ir_node *new_mem = get_irg_no_mem(irg);