aboutsummaryrefslogtreecommitdiff
path: root/gcc/simplify-rtx.c
diff options
context:
space:
mode:
authorRoger Sayle <roger@eyesopen.com>2003-07-18 00:26:51 +0000
committerRoger Sayle <sayle@gcc.gnu.org>2003-07-18 00:26:51 +0000
commit3e4093b64f2e2623bba32e733e7e8f08efc700ac (patch)
tree3875a0446ee77a593d30fb10e6a14b62fcc0f4ec /gcc/simplify-rtx.c
parent35c77862c921a82a9d2bc4175dc041bd1e99e2bd (diff)
downloadgcc-3e4093b64f2e2623bba32e733e7e8f08efc700ac.zip
gcc-3e4093b64f2e2623bba32e733e7e8f08efc700ac.tar.gz
gcc-3e4093b64f2e2623bba32e733e7e8f08efc700ac.tar.bz2
fold-const.c (const_binop): Avoid performing the FP operation at compile-time...
* fold-const.c (const_binop): Avoid performing the FP operation at compile-time, if either operand is NaN and we honor signaling NaNs, or if we're dividing by zero and either flag_trapping_math is set or the desired mode doesn't support infinities. (fold_initializer): New function to fold an expression ignoring any potential run-time exceptions or traps. * tree.h (fold_initializer): Prototype here. * c-typeck.c (build_binary_op): Move to the end of the file so that intializer_stack is in scope. If constructing an initializer, i.e. when initializer_stack is not NULL, use fold_initializer to fold expressions. * simplify-rtx.c (simplify_binary_operation): Likewise, avoid performing FP operations at compile-time, if they would raise an exception at run-time. From-SVN: r69533
Diffstat (limited to 'gcc/simplify-rtx.c')
-rw-r--r--gcc/simplify-rtx.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index 3b85767..8568529 100644
--- a/gcc/simplify-rtx.c
+++ b/gcc/simplify-rtx.c
@@ -929,9 +929,13 @@ simplify_binary_operation (enum rtx_code code, enum machine_mode mode,
f0 = real_value_truncate (mode, f0);
f1 = real_value_truncate (mode, f1);
+ if (HONOR_SNANS (mode)
+ && (REAL_VALUE_ISNAN (f0) || REAL_VALUE_ISNAN (f1)))
+ return 0;
+
if (code == DIV
- && !MODE_HAS_INFINITIES (mode)
- && REAL_VALUES_EQUAL (f1, dconst0))
+ && REAL_VALUES_EQUAL (f1, dconst0)
+ && (flag_trapping_math || ! MODE_HAS_INFINITIES (mode)))
return 0;
REAL_ARITHMETIC (value, rtx_to_tree_code (code), f0, f1);