Commit 9bcf83b3 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

ir: Factor out 'is_Const(x) && is_Const_null(x)' into the new function 'is_irn_null()'.

parent 731a6fc9
......@@ -431,7 +431,7 @@ static bool is_non_null_Confirm(const ir_node *ptr)
if (get_Confirm_relation(ptr) == ir_relation_less_greater) {
ir_node *bound = get_Confirm_bound(ptr);
if (is_Const(bound) && is_Const_null(bound))
if (is_irn_null(bound))
return true;
}
ptr = get_Confirm_value(ptr);
......
......@@ -2066,7 +2066,7 @@ static ir_node *get_flags_node(ir_node *cmp, x86_condition_code_t *cc_out)
if (!(relation & ir_relation_equal) && relation & ir_relation_less_greater)
relation |= get_negated_relation(ir_get_possible_cmp_relations(l, r)) & ir_relation_less_greater;
bool const overflow_possible = !is_Const(r) || !is_Const_null(r);
bool const overflow_possible = !is_irn_null(r);
/* just do a normal transformation of the Cmp */
*cc_out = ir_relation_to_x86_condition_code(relation, mode,
......
......@@ -1262,13 +1262,13 @@ static bool mux_is_doz(ir_node *sel, ir_node *mux_true, ir_node *mux_false)
ir_node *cmp_right = get_Cmp_right(sel);
/* "move" zero constant to false input */
if (is_Const(mux_true) && is_Const_null(mux_true)) {
if (is_irn_null(mux_true)) {
ir_node *tmp = mux_false;
mux_false = mux_true;
mux_true = tmp;
relation = get_negated_relation(relation);
}
if (!is_Const(mux_false) || !is_Const_null(mux_false))
if (!is_irn_null(mux_false))
return false;
if (!is_Sub(mux_true))
return false;
......
......@@ -154,12 +154,6 @@ static ir_node *create_I2I_Conv(ir_mode *src_mode, dbg_info *dbgi, ir_node *bloc
static ir_node *nomem;
static ir_node *noreg_GP;
/** Return non-zero is a node represents the 0 constant. */
static bool is_Const_0(ir_node *node)
{
return is_Const(node) && is_Const_null(node);
}
/** Return non-zero is a node represents the 1 constant. */
static bool is_Const_1(ir_node *node)
{
......@@ -2146,7 +2140,7 @@ static ir_node *get_flags_node(ir_node *cmp, x86_condition_code_t *cc_out)
ra = tmp;
}
if (is_Shl(la)) {
if (is_Shl_1(la) && is_Const_0(r)) {
if (is_Shl_1(la) && is_irn_null(r)) {
/* (1 << n) & ra) */
ir_node *n = get_Shl_right(la);
ir_node *flags = gen_bt(cmp, ra, n);
......@@ -2178,7 +2172,7 @@ static ir_node *get_flags_node(ir_node *cmp, x86_condition_code_t *cc_out)
if (!(relation & ir_relation_equal) && relation & ir_relation_less_greater)
relation |= get_negated_relation(ir_get_possible_cmp_relations(l, r)) & ir_relation_less_greater;
bool const overflow_possible = !is_Const_0(r);
bool const overflow_possible = !is_irn_null(r);
/* just do a normal transformation of the Cmp */
*cc_out = ir_relation_to_x86_condition_code(relation, mode,
......@@ -2356,9 +2350,9 @@ static ir_node *try_create_SetMem(ir_node *node, ir_node *ptr, ir_node *mem)
bool negated;
ir_node *const mux_true = get_Mux_true(node);
ir_node *const mux_false = get_Mux_false(node);
if (is_Const_1(mux_true) && is_Const_0(mux_false)) {
if (is_Const_1(mux_true) && is_irn_null(mux_false)) {
negated = false;
} else if (is_Const_0(mux_true) && is_Const_1(mux_false)) {
} else if (is_irn_null(mux_true) && is_Const_1(mux_false)) {
negated = true;
} else {
return NULL;
......@@ -2870,7 +2864,7 @@ static ir_node *create_Fucom(ir_node *node)
new_right, 0);
set_ia32_commutative(new_node);
} else {
if (is_Const_0(right)) {
if (is_irn_null(right)) {
new_node = new_bd_ia32_FtstFnstsw(dbgi, new_block, new_left, 0);
} else {
ir_node *new_right = be_transform_node(right);
......@@ -3002,7 +2996,7 @@ static ir_node *gen_Cmp(ir_node *node)
ir_node *new_block = be_transform_node(block);
ir_node *right = get_Cmp_right(node);
ir_node *new_node;
if (is_Const_0(right) &&
if (is_irn_null(right) &&
is_And(left) &&
get_irn_n_edges(left) == 1) {
/* Test(and_left, and_right) */
......@@ -3503,13 +3497,13 @@ static ir_node *gen_Mux(ir_node *node)
ir_node *val_true = mux_true;
ir_node *val_false = mux_false;
if (is_Const_0(val_true)) {
if (is_irn_null(val_true)) {
ir_node *tmp = val_false;
val_false = val_true;
val_true = tmp;
relation = get_negated_relation(relation);
}
if (is_Const_0(val_false) && is_Sub(val_true)) {
if (is_irn_null(val_false) && is_Sub(val_true)) {
if ((relation & ~ir_relation_equal) == ir_relation_greater
&& get_Sub_left(val_true) == cmp_left
&& get_Sub_right(val_true) == cmp_right) {
......
......@@ -1292,7 +1292,7 @@ static ir_node *gen_Cmp(ir_node *node)
* the bitopcc variant.
* Currently we only do this when we're the only user of the node...
*/
if (bits == 32 && is_Const(op2) && is_Const_null(op2) && get_irn_n_edges(op1) == 1) {
if (bits == 32 && is_irn_null(op2) && get_irn_n_edges(op1) == 1) {
if (is_And(op1)) {
ir_node *new_node = gen_helper_bitop(op1,
new_bd_sparc_AndCCZero_reg,
......
......@@ -756,6 +756,12 @@ static inline ir_node const *get_block_const(ir_node const *const irn)
return is_Block(irn) ? irn : get_nodes_block(irn);
}
/** Return whether a node is the 0 constant. */
static inline bool is_irn_null(ir_node const *const irn)
{
return is_Const(irn) && is_Const_null(irn);
}
#define foreach_irn_in(irn, idx, pred) \
for (bool pred##__b = true; pred##__b;) \
for (ir_node const *const pred##__irn = (irn); pred##__b; pred##__b = false) \
......
......@@ -1073,7 +1073,7 @@ static bool is_equality_cmp(const ir_node *node)
return true;
/* Unsigned x > 0 behaves like !=. */
if (is_Const(right) && is_Const_null(right) && !mode_is_signed(mode))
if (is_irn_null(right) && !mode_is_signed(mode))
return relation == ir_relation_greater;
return false;
......
......@@ -300,7 +300,7 @@ int i_mapper_exp(ir_node *call)
{
ir_node *val = get_Call_param(call, 0);
if (is_Const(val) && is_Const_null(val)) {
if (is_irn_null(val)) {
/* exp(0.0) = 1.0 */
ir_graph *irg = get_irn_irg(val);
ir_mode *mode = get_irn_mode(val);
......@@ -330,7 +330,7 @@ static int i_mapper_zero_to_zero(ir_node *call)
{
ir_node *val = get_Call_param(call, 0);
if (is_Const(val) && is_Const_null(val)) {
if (is_irn_null(val)) {
/* f(0.0) = 0.0 */
ir_node *mem = get_Call_mem(call);
DBG_OPT_ALGSIM0(call, val);
......@@ -392,7 +392,7 @@ static int i_mapper_symmetric_zero_to_one(ir_node *call)
changed = 1;
}
if (is_Const(val) && is_Const_null(val)) {
if (is_irn_null(val)) {
/* f(0.0) = 1.0 */
ir_graph *irg = get_irn_irg(val);
ir_mode *mode = get_irn_mode(val);
......@@ -823,7 +823,7 @@ int i_mapper_strncmp(ir_node *call)
ir_node *len = get_Call_param(call, 2);
ir_node *irn;
if (left == right || (is_Const(len) && is_Const_null(len))) {
if (left == right || is_irn_null(len)) {
/* a strncmp(s, s, len) ==> 0 OR
a strncmp(a, b, 0) ==> 0 */
ir_graph *irg = get_irn_irg(call);
......@@ -865,7 +865,7 @@ int i_mapper_memcpy(ir_node *call)
ir_node *src = get_Call_param(call, 1);
ir_node *len = get_Call_param(call, 2);
if (dst == src || (is_Const(len) && is_Const_null(len))) {
if (dst == src || is_irn_null(len)) {
/* a memcpy(d, d, len) ==> d OR
a memcpy(d, s, 0) ==> d */
ir_node *mem = get_Call_mem(call);
......@@ -883,7 +883,7 @@ int i_mapper_memmove(ir_node *call)
ir_node *src = get_Call_param(call, 1);
ir_node *len = get_Call_param(call, 2);
if (dst == src || (is_Const(len) && is_Const_null(len))) {
if (dst == src || is_irn_null(len)) {
/* a memmove(d, d, len) ==> d OR
a memmove(d, s, 0) ==> d */
ir_node *mem = get_Call_mem(call);
......@@ -899,7 +899,7 @@ int i_mapper_memset(ir_node *call)
{
ir_node *len = get_Call_param(call, 2);
if (is_Const(len) && is_Const_null(len)) {
if (is_irn_null(len)) {
/* a memset(d, C, 0) ==> d */
ir_node *mem = get_Call_mem(call);
ir_node *dst = get_Call_param(call, 0);
......@@ -918,7 +918,7 @@ int i_mapper_memcmp(ir_node *call)
ir_node *len = get_Call_param(call, 2);
ir_node *irn;
if (left == right || (is_Const(len) && is_Const_null(len))) {
if (left == right || is_irn_null(len)) {
/* a memcmp(s, s, len) ==> 0 OR
a memcmp(a, b, 0) ==> 0 */
ir_graph *irg = get_irn_irg(call);
......
......@@ -52,8 +52,7 @@ static bool find_cond_pair(ir_node *const l, ir_node *const r, cond_pair *const
ir_relation const pnc_l = get_Cmp_relation(l);
ir_relation const pnc_r = get_Cmp_relation(r);
if (is_Const(lor) && is_Const_null(lor) &&
is_Const(ror) && is_Const_null(ror) &&
if (is_irn_null(lor) && is_irn_null(ror) &&
pnc_l == pnc_r &&
(pnc_l == ir_relation_less_greater || pnc_l == ir_relation_equal)) {
/* l == (lol !=|== NULL) && r == (rol !=|== NULL) */
......
......@@ -805,7 +805,7 @@ static ir_tarval *computed_value_Cmp(const ir_node *cmp)
/* we have some special rules for == 0 and != 0 */
ir_relation const rel_eq = get_complementary_relations(ir_relation_equal, relation, possible);
if (rel_eq != ir_relation_false && is_Const(right) && is_Const_null(right) && value_not_null(left, NULL))
if (rel_eq != ir_relation_false && is_irn_null(right) && value_not_null(left, NULL))
return rel_eq != ir_relation_equal ? tarval_b_true : tarval_b_false;
return computed_value_Cmp_Confirm(left, right, relation);
......@@ -1673,7 +1673,7 @@ static ir_node *equivalent_node_Mux(ir_node *n)
* Note: normalization puts the constant on the right side,
* so we check only one case.
*/
if (is_Const(f) && is_Const_null(f) && is_relation_less_greater &&
if (is_irn_null(f) && is_relation_less_greater &&
get_mode_arithmetic(get_irn_mode(cmp_l)) == irma_twos_complement &&
(is_Eor(t) || is_Sub(t))) {
ir_node *t_l = get_binop_left(t);
......@@ -2174,7 +2174,7 @@ static bool is_cmp_unequal(const ir_node *node)
*/
static bool is_cmp_equality_zero(const ir_node *left, const ir_node *right, ir_relation relation)
{
if (!is_Const(right) || !is_Const_null(right))
if (!is_irn_null(right))
return false;
ir_relation possible = ir_get_possible_cmp_relations(left, right);
......@@ -3025,7 +3025,7 @@ static ir_node *transform_node_Add(ir_node *n)
if (mode_is_reference(mode)) {
const ir_mode *lmode = get_irn_mode(a);
if (is_Const(b) && is_Const_null(b) && mode_is_int(lmode)) {
if (is_irn_null(b) && mode_is_int(lmode)) {
/* an Add(a, NULL) is a hidden Conv */
dbg_info *dbg = get_irn_dbg_info(n);
return new_rd_Conv(dbg, get_nodes_block(n), a, mode);
......@@ -3258,7 +3258,7 @@ static ir_node *transform_node_Sub(ir_node *n)
if (mode_is_int(mode)) {
const ir_mode *lmode = get_irn_mode(a);
if (is_Const(b) && is_Const_null(b) && mode_is_reference(lmode)) {
if (is_irn_null(b) && mode_is_reference(lmode)) {
/* a Sub(a, NULL) is a hidden Conv */
dbg_info *dbg = get_irn_dbg_info(n);
n = new_rd_Conv(dbg, get_nodes_block(n), a, mode);
......@@ -3381,7 +3381,7 @@ static ir_node *transform_node_Sub(ir_node *n)
}
/* Beware of Sub(P, P) which cannot be optimized into a simple Minus ... */
if (mode_is_num(mode) && mode == get_irn_mode(a) && is_Const(a) && is_Const_null(a)) {
if (mode_is_num(mode) && mode == get_irn_mode(a) && is_irn_null(a)) {
n = new_rd_Minus(get_irn_dbg_info(n), get_nodes_block(n), b);
DBG_OPT_ALGSIM0(oldn, n);
return n;
......@@ -5189,7 +5189,7 @@ cmp_x_eq_0:
}
}
if (is_Proj(left) && is_Const(right) && is_Const_null(right) && rel_eq != ir_relation_false) {
if (is_Proj(left) && is_irn_null(right) && rel_eq != ir_relation_false) {
ir_node *op = get_Proj_pred(left);
if (is_Mod(op) && get_Proj_num(left) == pn_Mod_res) {
......@@ -5269,7 +5269,7 @@ cmp_x_eq_0:
goto restart;
}
if (is_Const(right) && is_Const_null(right)) {
if (is_irn_null(right)) {
/* instead of flipping the bit before the bit-test operation negate
* pnc */
ir_node *and0 = get_And_left(left);
......@@ -6481,7 +6481,7 @@ int ir_mux_is_abs(const ir_node *sel, const ir_node *mux_false,
/* must be x cmp 0 */
ir_node *cmp_right = get_Cmp_right(sel);
if (!is_Const(cmp_right) || !is_Const_null(cmp_right))
if (!is_irn_null(cmp_right))
return 0;
ir_node *cmp_left = get_Cmp_left(sel);
......@@ -6539,7 +6539,7 @@ static bool ir_is_optimizable_mux_set(const ir_node *cond, ir_relation relation,
}
}
}
if (is_Const(right) && is_Const_null(right) && is_And(left)) {
if (is_irn_null(right) && is_And(left)) {
ir_node *and_right = get_And_right(left);
if (is_Const(and_right)) {
ir_tarval *tv = get_Const_tarval(and_right);
......@@ -6612,14 +6612,14 @@ bool ir_is_optimizable_mux(const ir_node *sel, const ir_node *mux_false,
}
ir_mode *cmp_mode = get_irn_mode(cmp_l);
if (is_Const(f) && is_Const_null(f) &&
if (is_irn_null(f) &&
get_mode_arithmetic(mode) == irma_twos_complement &&
get_mode_arithmetic(cmp_mode) == irma_twos_complement) {
if (is_Const(t)) {
if (is_Const_one(t)) {
if (ir_is_optimizable_mux_set(sel, relation, mode))
return true;
} else if (is_Const_all_one(t) && is_Const(cmp_r) && is_Const_null(cmp_r)) {
} else if (is_Const_all_one(t) && is_irn_null(cmp_r)) {
ir_relation possible = ir_get_possible_cmp_relations(cmp_l, cmp_r);
if (get_complementary_relations(ir_relation_less, relation, possible) != ir_relation_false) {
/* Mux(a >= 0, 0, 0xFFFFFFFF) => ~a >>s 31 */
......@@ -6716,7 +6716,7 @@ static ir_node *transform_Mux_set(ir_node *n, ir_relation relation)
}
}
if (is_Const(right) && is_Const_null(right) && is_And(left)) {
if (is_irn_null(right) && is_And(left)) {
ir_node *and_right = get_And_right(left);
if (is_Const(and_right)) {
ir_tarval *tv = get_Const_tarval(and_right);
......@@ -6860,7 +6860,7 @@ static ir_node *transform_node_Mux(ir_node *n)
}
ir_mode *cmp_mode = get_irn_mode(cmp_l);
if (is_Const(f) && is_Const_null(f) &&
if (is_irn_null(f) &&
get_mode_arithmetic(mode) == irma_twos_complement &&
get_mode_arithmetic(cmp_mode) == irma_twos_complement) {
if (is_Const(t)) {
......@@ -6868,7 +6868,7 @@ static ir_node *transform_node_Mux(ir_node *n)
n = transform_Mux_set(n, relation);
if (n != oldn)
return n;
} else if (is_Const_all_one(t) && is_Const(cmp_r) && is_Const_null(cmp_r) && mode_is_signed(cmp_mode)) {
} else if (is_Const_all_one(t) && is_irn_null(cmp_r) && mode_is_signed(cmp_mode)) {
ir_relation const possible = ir_get_possible_cmp_relations(cmp_l, cmp_r);
ir_relation const rel_lt = get_complementary_relations(ir_relation_less, relation, possible);
if (rel_lt != ir_relation_false) {
......@@ -6921,7 +6921,7 @@ static ir_node *transform_node_Mux(ir_node *n)
ir_relation const possible = ir_get_possible_cmp_relations(cmp_l, cmp_r);
ir_relation const rel_eq = get_complementary_relations(ir_relation_equal, relation, possible);
if (rel_eq != ir_relation_false && is_Const(cmp_r) && is_Const_null(cmp_r) && is_And(cmp_l) && f == cmp_r) {
if (rel_eq != ir_relation_false && is_irn_null(cmp_r) && is_And(cmp_l) && f == cmp_r) {
ir_node *and_l = get_And_left(cmp_l);
ir_node *and_r = get_And_right(cmp_l);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment