X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Firopt.c;h=ceb7522bdb0d0f21c93058c853d8c7c59449da5e;hb=672b5c243e900427b5dcae01441d4fa3327d692c;hp=75b7fe1c43677b77e875f474dc1ca1e25999cbdd;hpb=9ec98298a0bf99ccb9533365dd7245e0a380f3df;p=libfirm diff --git a/ir/ir/iropt.c b/ir/ir/iropt.c index 75b7fe1c4..ceb7522bd 100644 --- a/ir/ir/iropt.c +++ b/ir/ir/iropt.c @@ -868,7 +868,53 @@ static ir_node *equivalent_node_neutral_zero(ir_node *n) /** * Eor is commutative and has neutral 0. */ -#define equivalent_node_Eor equivalent_node_neutral_zero +static ir_node *equivalent_node_Eor(ir_node *n) +{ + ir_node *oldn = n; + ir_node *a; + ir_node *b; + + n = equivalent_node_neutral_zero(n); + if (n != oldn) return n; + + a = get_Eor_left(n); + b = get_Eor_right(n); + + if (is_Eor(a)) { + ir_node *aa = get_Eor_left(a); + ir_node *ab = get_Eor_right(a); + + if (aa == b) { + /* (a ^ b) ^ a -> b */ + n = ab; + DBG_OPT_ALGSIM1(oldn, a, b, n, FS_OPT_EOR_A_B_A); + return n; + } else if (ab == b) { + /* (a ^ b) ^ b -> a */ + n = aa; + DBG_OPT_ALGSIM1(oldn, a, b, n, FS_OPT_EOR_A_B_A); + return n; + } + } + if (is_Eor(b)) { + ir_node *ba = get_Eor_left(b); + ir_node *bb = get_Eor_right(b); + + if (ba == a) { + /* a ^ (a ^ b) -> b */ + n = bb; + DBG_OPT_ALGSIM1(oldn, a, b, n, FS_OPT_EOR_A_B_A); + return n; + } else if (bb == a) { + /* a ^ (b ^ a) -> b */ + n = ba; + DBG_OPT_ALGSIM1(oldn, a, b, n, FS_OPT_EOR_A_B_A); + return n; + } + } + + return n; +} /* * Optimize a - 0 and (a - x) + x (for modes with wrap-around). @@ -2804,8 +2850,17 @@ static ir_node *transform_node_Quot(ir_node *n) { if (is_Const(b)) { tarval *tv = get_Const_tarval(b); + int rem; + /* + * Floating point constant folding might be disabled here to + * prevent rounding. + * However, as we check for exact result, doing it is safe. + * Switch it on. + */ + rem = tarval_enable_fp_ops(1); tv = tarval_quo(get_mode_one(mode), tv); + (void)tarval_enable_fp_ops(rem); /* Do the transformation if the result is either exact or we are not using strict rules. */