From afea0c3c8a80302667efb05786585144327704b8 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Thu, 9 Jun 2011 17:03:29 +0200 Subject: [PATCH] Better fix for wrong tarval computation of -(infinity). Restores the support for no infity, fixed handling of denormals. --- ir/tv/tv.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ir/tv/tv.c b/ir/tv/tv.c index d437c4527..b0e9d8e20 100644 --- a/ir/tv/tv.c +++ b/ir/tv/tv.c @@ -64,6 +64,9 @@ typedef enum float_to_int_mode { static float_to_int_mode current_float_to_int_mode = TRUNCATE; +/* set this to true if infinity should be clipped to +/- MAX_FLOAT */ +#define SWITCH_NOINFINITY 0 +/* set this to true if denormals should be clipped to zero */ #define SWITCH_NODENORMALS 0 /**************************************************************************** @@ -265,7 +268,13 @@ static ir_tarval *get_tarval_overflow(const void *value, size_t length, ir_mode break; case irms_float_number: -#ifdef SWITCH_NODENORMALS +#if SWITCH_NOINFINITY + if (fc_is_inf((const fp_value*) value)) { + /* clip infinity to maximum value */ + return fc_is_negative((const fp_value*) value) ? get_mode_min(mode) : get_mode_max(mode); + } +#endif +#if SWITCH_NODENORMALS if (fc_is_subnormal((const fp_value*) value)) { /* clip denormals to zero */ return get_mode_null(mode); -- 2.20.1