2004-06-11 Jakub Jelinek PR middle-end/15945 * simplify-rtx.c (simplify_binary_operation): Don't optimize out Inf + -Inf, Inf - Inf, Inf / Inf and 0 * Inf if flag_trapping_math. --- gcc/simplify-rtx.c.jj 2004-01-24 12:04:21.000000000 +0100 +++ gcc/simplify-rtx.c 2004-06-11 19:45:26.727675196 +0200 @@ -1234,6 +1234,40 @@ simplify_binary_operation (enum rtx_code && (flag_trapping_math || ! MODE_HAS_INFINITIES (mode))) return 0; + if (MODE_HAS_INFINITIES (mode) && HONOR_NANS (mode) + && flag_trapping_math + && REAL_VALUE_ISINF (f0) && REAL_VALUE_ISINF (f1)) + { + int s0 = REAL_VALUE_NEGATIVE (f0); + int s1 = REAL_VALUE_NEGATIVE (f1); + + switch (code) + { + case PLUS: + /* Inf + -Inf = NaN plus exception. */ + if (s0 != s1) + return 0; + break; + case MINUS: + /* Inf - Inf = NaN plus exception. */ + if (s0 == s1) + return 0; + break; + case DIV: + /* Inf / Inf = NaN plus exception. */ + return 0; + default: + break; + } + } + + if (code == MULT && MODE_HAS_INFINITIES (mode) && HONOR_NANS (mode) + && flag_trapping_math + && ((REAL_VALUE_ISINF (f0) && REAL_VALUES_EQUAL (f1, dconst0)) + || (REAL_VALUE_ISINF (f1) && REAL_VALUES_EQUAL (f0, dconst0)))) + /* Inf * 0 = NaN plus exception. */ + return 0; + REAL_ARITHMETIC (value, rtx_to_tree_code (code), f0, f1); value = real_value_truncate (mode, value);