From: Michael Beck Date: Thu, 27 Sep 2007 13:19:07 +0000 (+0000) Subject: extend the x % 2 CMP 0 into x % 2^n CMP 0 X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=fc5f7e1fbd10124c19b2583d74ab9472bfb95ebf;p=libfirm extend the x % 2 CMP 0 into x % 2^n CMP 0 [r15944] --- diff --git a/ir/ir/iropt.c b/ir/ir/iropt.c index 6b8ca056a..94c3bfdaa 100644 --- a/ir/ir/iropt.c +++ b/ir/ir/iropt.c @@ -3787,13 +3787,14 @@ static ir_node *transform_node_Proj_Cmp(ir_node *proj) { if (is_Const(c)) { tarval *tv = get_Const_tarval(c); - if (tarval_is_long(tv) && get_tarval_long(tv) == 2) { - /* special case: (x % 2) CMP 0 ==> x & 1 CMP 0 */ + if (tarval_is_single_bit(tv)) { + /* special case: (x % 2^n) CMP 0 ==> x & (2^n-1) CMP 0 */ ir_node *v = get_binop_left(op); ir_node *blk = get_irn_n(op, -1); ir_mode *mode = get_irn_mode(v); - left = new_rd_And(get_irn_dbg_info(op), current_ir_graph, blk, v, new_Const(mode, get_mode_one(mode)), mode); + tv = tarval_sub(tv, get_mode_one(mode)); + left = new_rd_And(get_irn_dbg_info(op), current_ir_graph, blk, v, new_Const(mode, tv), mode); changed |= 1; } }