From: Matthias Braun Date: Mon, 3 Dec 2012 00:19:21 +0000 (+0100) Subject: the 1/c -> 1*c optimisation is fine for x86 floats too X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=4862eaa326d4547f67c4ce8bbdfbe25659dd15c9;p=libfirm the 1/c -> 1*c optimisation is fine for x86 floats too --- diff --git a/ir/ir/iropt.c b/ir/ir/iropt.c index 3164c615b..7b5c9397b 100644 --- a/ir/ir/iropt.c +++ b/ir/ir/iropt.c @@ -3165,34 +3165,32 @@ static ir_node *transform_node_Div(ir_node *n) assert(mode_is_float(mode)); /* Optimize x/c to x*(1/c) */ - if (get_mode_arithmetic(mode) == irma_ieee754) { - ir_tarval *tv = value_of(b); + ir_tarval *tv = value_of(b); - if (tv != tarval_bad) { - int rem = tarval_fp_ops_enabled(); + if (tv != tarval_bad) { + int rem = tarval_fp_ops_enabled(); - /* - * 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. - */ - tarval_enable_fp_ops(1); - tv = tarval_div(get_mode_one(mode), tv); - tarval_enable_fp_ops(rem); - - /* Do the transformation if the result is either exact or we are - not using strict rules. */ - if (tv != tarval_bad && - (tarval_ieee754_get_exact() || (get_irg_fp_model(get_irn_irg(n)) & fp_strict_algebraic) == 0)) { - ir_node *block = get_nodes_block(n); - ir_graph *irg = get_irn_irg(block); - ir_node *c = new_r_Const(irg, tv); - dbg_info *dbgi = get_irn_dbg_info(n); - value = new_rd_Mul(dbgi, block, a, c, mode); + /* + * 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. + */ + tarval_enable_fp_ops(1); + tv = tarval_div(get_mode_one(mode), tv); + tarval_enable_fp_ops(rem); + + /* Do the transformation if the result is either exact or we are + not using strict rules. */ + if (tv != tarval_bad && + (tarval_ieee754_get_exact() || (get_irg_fp_model(get_irn_irg(n)) & fp_strict_algebraic) == 0)) { + ir_node *block = get_nodes_block(n); + ir_graph *irg = get_irn_irg(block); + ir_node *c = new_r_Const(irg, tv); + dbg_info *dbgi = get_irn_dbg_info(n); + value = new_rd_Mul(dbgi, block, a, c, mode); - goto make_tuple; - } + goto make_tuple; } } }