diff options
author | Jakub Jelinek <jakub@redhat.com> | 2004-06-14 19:45:08 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2004-06-14 19:45:08 +0200 |
commit | 6355b2d5bb6870b770e00f7dc2b9ab275e3d6a9e (patch) | |
tree | 84ea37e94f5eeb0a03216869549b532c423766c4 /gcc | |
parent | 44930935245c606dc826b43040603a71ad431e54 (diff) | |
download | gcc-6355b2d5bb6870b770e00f7dc2b9ab275e3d6a9e.zip gcc-6355b2d5bb6870b770e00f7dc2b9ab275e3d6a9e.tar.gz gcc-6355b2d5bb6870b770e00f7dc2b9ab275e3d6a9e.tar.bz2 |
re PR middle-end/15945 (Incorrect floating point optimization)
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.
From-SVN: r83121
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/simplify-rtx.c | 35 |
2 files changed, 41 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 6444b06..d7faa5d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2004-06-14 Jakub Jelinek <jakub@redhat.com> + + 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. + 2004-06-14 Zdenek Dvorak <rakdver@atrey.karlin.mff.cuni.cz> * opts.sh (var_args): Fix regexp. diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index fb80219..0d3b2bd 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -1277,6 +1277,41 @@ simplify_binary_operation (enum rtx_code code, enum machine_mode mode, && (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); |