X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Ffp-vrp.c;h=8f286223faef3ddb92cecff9e44460b9cc9985b4;hb=4e0288d4c454f3cded36e0b81e97be03dca528db;hp=cf2595b8ca8bc0f7e6158067fcc06bcd4fcef778;hpb=7a483ab981d403222150c320242adaad13d60af9;p=libfirm diff --git a/ir/opt/fp-vrp.c b/ir/opt/fp-vrp.c index cf2595b8c..8f286223f 100644 --- a/ir/opt/fp-vrp.c +++ b/ir/opt/fp-vrp.c @@ -1,20 +1,6 @@ /* - * Copyright (C) 1995-2010 University of Karlsruhe. All right reserved. - * * This file is part of libFirm. - * - * This file may be distributed and/or modified under the terms of the - * GNU General Public License version 2 as published by the Free Software - * Foundation and appearing in the file LICENSE.GPL included in the - * packaging of this file. - * - * Licensees holding valid libFirm Professional Edition licenses may use - * this file in accordance with the libFirm Commercial License. - * Agreement provided with the Software. - * - * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE - * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE. + * Copyright (C) 2012 University of Karlsruhe. */ /** @@ -435,9 +421,9 @@ undefined: ir_tarval* const rzn = tarval_or(rz, tarval_neg(rz)); // Concatenate safe lower zeroes. if (tarval_cmp(lzn, rzn) == ir_relation_less) { - z = tarval_mul(tarval_eor(lzn, tarval_shl(lzn, get_tarval_one(m))), rzn); + z = tarval_mul(tarval_eor(lzn, tarval_shl_unsigned(lzn, 1)), rzn); } else { - z = tarval_mul(tarval_eor(rzn, tarval_shl(rzn, get_tarval_one(m))), lzn); + z = tarval_mul(tarval_eor(rzn, tarval_shl_unsigned(rzn, 1)), lzn); } o = get_tarval_null(m); } @@ -690,8 +676,6 @@ static void apply_result(ir_node* const irn, void* ctx) } else if (m == mode_X) { ir_graph* const irg = get_Block_irg(block); if (z == get_tarval_b_true()) { - // Might produce an endless loop, so keep the block. - add_End_keepalive(get_irg_end(irg), block); n = new_r_Jmp(block); } else { n = new_r_Bad(irg, mode_X); @@ -714,18 +698,14 @@ exchange_only: ir_node* const r = get_And_right(irn); bitinfo const* const bl = get_bitinfo(l); bitinfo const* const br = get_bitinfo(r); - if (bl->z == bl->o) { - if (tarval_is_null(tarval_andnot(br->z, bl->z))) { - DB((dbg, LEVEL_2, "%+F(%+F, %+F) is superfluous\n", irn, l, r)); - exchange(irn, r); - env->modified = 1; - } - } else if (br->z == br->o) { - if (tarval_is_null(tarval_andnot(bl->z, br->z))) { - DB((dbg, LEVEL_2, "%+F(%+F, %+F) is superfluous\n", irn, l, r)); - exchange(irn, l); - env->modified = 1; - } + if (tarval_is_null(tarval_andnot(br->z, bl->o))) { + DB((dbg, LEVEL_2, "%+F(%+F, %+F) is superfluous\n", irn, l, r)); + exchange(irn, r); + env->modified = 1; + } else if (tarval_is_null(tarval_andnot(bl->z, br->o))) { + DB((dbg, LEVEL_2, "%+F(%+F, %+F) is superfluous\n", irn, l, r)); + exchange(irn, l); + env->modified = 1; } break; } @@ -752,23 +732,37 @@ exchange_only: break; } + case iro_Minus: { + ir_mode *mode = get_irn_mode(irn); + + /* If all bits except the highest bit are zero the Minus is superfluous. */ + if (get_mode_arithmetic(mode) == irma_twos_complement) { + ir_node *const op = get_Minus_op(irn); + bitinfo const *const b = get_bitinfo(op); + ir_tarval *const min = get_mode_min(mode); + + if (b->z == min) { + DB((dbg, LEVEL_2, "%+F(%+F) is superfluous\n", irn, op)); + exchange(irn, op); + env->modified = 1; + } + } + break; + } + case iro_Or: { ir_node* const l = get_Or_left(irn); ir_node* const r = get_Or_right(irn); bitinfo const* const bl = get_bitinfo(l); bitinfo const* const br = get_bitinfo(r); - if (bl->z == bl->o) { - if (tarval_is_null(tarval_andnot(bl->o, br->o))) { - DB((dbg, LEVEL_2, "%+F(%+F, %+F) is superfluous\n", irn, l, r)); - exchange(irn, r); - env->modified = 1; - } - } else if (br->z == br->o) { - if (tarval_is_null(tarval_andnot(br->o, bl->o))) { - DB((dbg, LEVEL_2, "%+F(%+F, %+F) is superfluous\n", irn, l, r)); - exchange(irn, l); - env->modified = 1; - } + if (tarval_is_null(tarval_andnot(bl->z, br->o))) { + DB((dbg, LEVEL_2, "%+F(%+F, %+F) is superfluous\n", irn, l, r)); + exchange(irn, r); + env->modified = 1; + } else if (tarval_is_null(tarval_andnot(br->z, bl->o))) { + DB((dbg, LEVEL_2, "%+F(%+F, %+F) is superfluous\n", irn, l, r)); + exchange(irn, l); + env->modified = 1; } /* if each bit is guaranteed to be zero on either the left or right @@ -797,7 +791,6 @@ static void queue_users(pdeq* const q, ir_node* const n) /* When the state of a control flow node changes, not only queue its * successor blocks, but also the Phis in these blocks, because the Phis * must reconsider this input path. */ - ir_edge_t const* e; foreach_out_edge(n, e) { ir_node* const src = get_edge_src_irn(e); pdeq_putr(q, src); @@ -809,7 +802,6 @@ static void queue_users(pdeq* const q, ir_node* const n) } } } else { - ir_edge_t const* e; foreach_out_edge(n, e) { ir_node* const src = get_edge_src_irn(e); if (get_irn_mode(src) == mode_T) {