X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Firopt.c;h=feee76bd6a6815ec98a4b91cbbce1014e6f7940a;hb=11a2eb0c1ea4073251827dc7e2b34c5e1e04a4bc;hp=eb232817c1341a93daede8d1cd8e7040e7d539a5;hpb=dbf90733512cb40bf418d0c5e48aa29d280961d4;p=libfirm diff --git a/ir/ir/iropt.c b/ir/ir/iropt.c index eb232817c..feee76bd6 100644 --- a/ir/ir/iropt.c +++ b/ir/ir/iropt.c @@ -3538,15 +3538,6 @@ static ir_node *transform_node_Eor(ir_node *n) { n = new_rd_Const(get_irn_dbg_info(n), current_ir_graph, get_mode_null(mode)); DBG_OPT_ALGSIM0(oldn, n, FS_OPT_EOR_A_A); - } else if (mode == mode_b && - is_Proj(a) && - is_Const(b) && is_Const_one(b) && - is_Cmp(get_Proj_pred(a))) { - /* The Eor negates a Cmp. The Cmp has the negated result anyways! */ - n = new_r_Proj(get_nodes_block(n), get_Proj_pred(a), - mode_b, get_negated_pnc(get_Proj_proj(a), mode)); - - DBG_OPT_ALGSIM0(oldn, n, FS_OPT_EOR_TO_NOT_BOOL); } else if (is_Const(b)) { if (is_Not(a)) { /* ~x ^ const -> x ^ ~const */ ir_node *cnst = new_Const(tarval_not(get_Const_tarval(b))); @@ -4291,10 +4282,13 @@ static ir_node *transform_node_Proj_Cmp(ir_node *proj) { /* * UpConv(x) REL 0 ==> x REL 0 + * Don't do this for float values as it's unclear whether it is a + * win. (on the other side it makes detection/creation of fabs hard) */ if (get_mode_size_bits(mode) > get_mode_size_bits(op_mode) && ((proj_nr == pn_Cmp_Eq || proj_nr == pn_Cmp_Lg) || - mode_is_signed(mode) || !mode_is_signed(op_mode))) { + mode_is_signed(mode) || !mode_is_signed(op_mode)) && + !mode_is_float(mode)) { tv = get_mode_null(op_mode); left = op; mode = op_mode; @@ -4825,7 +4819,7 @@ static ir_node *transform_node_Or_bf_store(ir_node *or) { ir_node *new_and, *new_const, *block; ir_mode *mode = get_irn_mode(or); - tarval *tv1, *tv2, *tv3, *tv4, *tv, *n_tv4, *n_tv2; + tarval *tv1, *tv2, *tv3, *tv4, *tv; while (1) { get_comm_Binop_Ops(or, &and, &c1); @@ -4874,14 +4868,12 @@ static ir_node *transform_node_Or_bf_store(ir_node *or) { return or; } - n_tv4 = tarval_not(tv4); - if (tv3 != tarval_and(tv3, n_tv4)) { + if (tv3 != tarval_andnot(tv3, tv4)) { /* bit in the or_mask is outside the and_mask */ return or; } - n_tv2 = tarval_not(tv2); - if (tv1 != tarval_and(tv1, n_tv2)) { + if (tv1 != tarval_andnot(tv1, tv2)) { /* bit in the or_mask is outside the and_mask */ return or; } @@ -5453,12 +5445,12 @@ static ir_node *transform_node_End(ir_node *n) { return n; } /* transform_node_End */ -/** returns 1 if a == -b */ -static int is_negated_value(ir_node *a, ir_node *b) { +bool is_negated_value(ir_node *a, ir_node *b) +{ if (is_Minus(a) && get_Minus_op(a) == b) - return 1; + return true; if (is_Minus(b) && get_Minus_op(b) == a) - return 1; + return true; if (is_Sub(a) && is_Sub(b)) { ir_node *a_left = get_Sub_left(a); ir_node *a_right = get_Sub_right(a); @@ -5466,10 +5458,10 @@ static int is_negated_value(ir_node *a, ir_node *b) { ir_node *b_right = get_Sub_right(b); if (a_left == b_right && a_right == b_left) - return 1; + return true; } - return 0; + return false; } /** @@ -5796,7 +5788,7 @@ static ir_node *transform_node_Call(ir_node *call) { ir_node *callee = get_Call_ptr(call); ir_node *adr, *mem, *res, *bl, **in; ir_type *ctp, *mtp, *tp; - ident *id; + type_dbg_info *tdb; dbg_info *db; int i, n_res, n_param; ir_variadicity var; @@ -5818,13 +5810,11 @@ static ir_node *transform_node_Call(ir_node *call) { /* build a new call type */ mtp = get_Call_type(call); - id = get_type_ident(mtp); - id = id_mangle(new_id_from_chars("T_", 2), id); - db = get_type_dbg_info(mtp); + tdb = get_type_dbg_info(mtp); n_res = get_method_n_ress(mtp); n_param = get_method_n_params(mtp); - ctp = new_d_type_method(id, n_param + 1, n_res, db); + ctp = new_d_type_method(n_param + 1, n_res, tdb); for (i = 0; i < n_res; ++i) set_method_res_type(ctp, i, get_method_res_type(mtp, i)); @@ -5833,8 +5823,7 @@ static ir_node *transform_node_Call(ir_node *call) { /* FIXME: we don't need a new pointer type in every step */ tp = get_irg_frame_type(current_ir_graph); - id = id_mangle(get_type_ident(tp), new_id_from_chars("_ptr", 4)); - tp = new_type_pointer(id, tp, mode_P_data); + tp = new_type_pointer(tp); set_method_param_type(ctp, 0, tp); in[0] = get_Builtin_param(callee, 2); @@ -6259,9 +6248,15 @@ int identities_cmp(const void *elt, const void *key) { } /* compare a->in[0..ins] with b->in[0..ins] */ - for (i = 0; i < irn_arity_a; i++) - if (get_irn_intra_n(a, i) != get_irn_intra_n(b, i)) - return 1; + for (i = 0; i < irn_arity_a; ++i) { + ir_node *pred_a = get_irn_intra_n(a, i); + ir_node *pred_b = get_irn_intra_n(b, i); + if (pred_a != pred_b) { + /* if both predecessors are CSE neutral they might be different */ + if (!is_irn_cse_neutral(pred_a) || !is_irn_cse_neutral(pred_b)) + return 1; + } + } /* * here, we already now that the nodes are identical except their @@ -6370,19 +6365,22 @@ static void update_known_irn(ir_node *known_irn, const ir_node *new_ir_node) { * node could be found */ ir_node *identify_remember(pset *value_table, ir_node *n) { - ir_node *o = NULL; + ir_node *nn = NULL; if (!value_table) return n; ir_normalize_node(n); /* lookup or insert in hash table with given hash key. */ - o = pset_insert(value_table, n, ir_node_hash(n)); + nn = pset_insert(value_table, n, ir_node_hash(n)); + + if (nn != n) { + update_known_irn(nn, n); - if (o != n) { - update_known_irn(o, n); + /* n is reachable again */ + edges_node_revival(nn, get_irn_irg(nn)); } - return o; + return nn; } /* identify_remember */ /**