Allow safe x/y = x * (1.0/y) for exact 1.0/y even if floating point constant folding...
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Sun, 18 May 2008 14:39:10 +0000 (14:39 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Sun, 18 May 2008 14:39:10 +0000 (14:39 +0000)
[r19653]

ir/ir/iropt.c

index 75b7fe1..286b540 100644 (file)
@@ -2804,8 +2804,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. */