remove support to disable floatingpoint constant folding
authorMatthias Braun <matze@braunis.de>
Tue, 4 Dec 2012 01:20:47 +0000 (02:20 +0100)
committerMatthias Braun <matze@braunis.de>
Tue, 4 Dec 2012 17:15:03 +0000 (18:15 +0100)
include/libfirm/tv.h
ir/ir/iropt.c
ir/tv/tv.c

index 9db898d..1b6e98d 100644 (file)
@@ -799,14 +799,6 @@ FIRM_API int tarval_ieee754_can_conv_lossless(ir_tarval *tv, ir_mode *mode);
  */
 FIRM_API unsigned tarval_ieee754_get_exact(void);
 
-/**
- * Enable/Disable floating point constant folding.
- */
-FIRM_API void tarval_enable_fp_ops(int enable);
-
-/** returns 0/1 if floating point folding is enable/disabled */
-FIRM_API int tarval_fp_ops_enabled(void);
-
 /**
  * Check if its the a floating point NaN.
  *
index 738f745..5ef18d2 100644 (file)
@@ -3148,17 +3148,7 @@ static ir_node *transform_node_Div(ir_node *n)
                ir_tarval *tv = value_of(b);
 
                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. */
index 17ef053..42bac4f 100644 (file)
@@ -91,9 +91,6 @@ static int carry_flag = -1;
 /** The integer overflow mode. */
 static tarval_int_overflow_mode_t int_overflow_mode = TV_OVERFLOW_WRAP;
 
-/** if this is set non-zero, the constant folding for floating point is OFF */
-static int no_float = 0;
-
 /****************************************************************************
  *   private functions
  ****************************************************************************/
@@ -938,10 +935,6 @@ ir_tarval *tarval_neg(ir_tarval *a)
                return get_tarval_overflow(buffer, a->length, a->mode);
 
        case irms_float_number:
-               /* it should be safe to enable this even if other arithmetic is disabled */
-               /*if (no_float)
-                       return tarval_bad;*/
-
                fc_neg((const fp_value*) a->value, NULL);
                return get_tarval_overflow(fc_get_buffer(), fc_get_buffer_length(), a->mode);
 
@@ -977,9 +970,6 @@ ir_tarval *tarval_add(ir_tarval *a, ir_tarval *b)
                return get_tarval_overflow(buffer, a->length, a->mode);
 
        case irms_float_number:
-               if (no_float)
-                       return tarval_bad;
-
                fc_add((const fp_value*) a->value, (const fp_value*) b->value, NULL);
                return get_tarval_overflow(fc_get_buffer(), fc_get_buffer_length(), a->mode);
 
@@ -1015,9 +1005,6 @@ ir_tarval *tarval_sub(ir_tarval *a, ir_tarval *b, ir_mode *dst_mode)
                return get_tarval_overflow(buffer, a->length, a->mode);
 
        case irms_float_number:
-               if (no_float)
-                       return tarval_bad;
-
                fc_sub((const fp_value*) a->value, (const fp_value*) b->value, NULL);
                return get_tarval_overflow(fc_get_buffer(), fc_get_buffer_length(), a->mode);
 
@@ -1045,9 +1032,6 @@ ir_tarval *tarval_mul(ir_tarval *a, ir_tarval *b)
                return get_tarval_overflow(buffer, a->length, a->mode);
 
        case irms_float_number:
-               if (no_float)
-                       return tarval_bad;
-
                fc_mul((const fp_value*) a->value, (const fp_value*) b->value, NULL);
                return get_tarval_overflow(fc_get_buffer(), fc_get_buffer_length(), a->mode);
 
@@ -1141,10 +1125,6 @@ ir_tarval *tarval_abs(ir_tarval *a)
                return a;
 
        case irms_float_number:
-               /* it should be safe to enable this even if other arithmetic is disabled */
-               /*if (no_float)
-                       return tarval_bad;*/
-
                if (fc_comp((const fp_value*) a->value,
                    (const fp_value*) get_mode_null(a->mode)->value) == -1) {
                        fc_neg((const fp_value*) a->value, NULL);
@@ -1702,17 +1682,6 @@ tarval_int_overflow_mode_t tarval_get_integer_overflow_mode(void)
        return int_overflow_mode;
 }
 
-/* Enable/Disable floating point constant folding. */
-void tarval_enable_fp_ops(int enable)
-{
-       no_float = !enable;
-}
-
-int tarval_fp_ops_enabled(void)
-{
-       return !no_float;
-}
-
 /**
  * default mode_info for output as HEX
  */