summaryrefslogtreecommitdiff
path: root/gcc/simplify-rtx.c
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2004-06-14 17:45:08 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2004-06-14 17:45:08 +0000
commit80f858b652566fffcf46e027ee6740bcae0f68e1 (patch)
tree84ea37e94f5eeb0a03216869549b532c423766c4 /gcc/simplify-rtx.c
parent4f5f8bf096b32be2f0f9cab47ec4306fae204f93 (diff)
downloadgcc-80f858b652566fffcf46e027ee6740bcae0f68e1.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@83121 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/simplify-rtx.c')
-rw-r--r--gcc/simplify-rtx.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c
index fb80219155c..0d3b2bde45f 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);