aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2005-11-16 17:15:23 +0000
committerEric Botcazou <ebotcazou@adacore.com>2005-11-16 17:15:23 +0000
commita9677c1ccd0461e143e27368a6f6cccfef65e500 (patch)
tree6894347795260dbf98ccdad4e02632f18f90f9e7 /gcc/fold-const.c
parent6a087299084ff33dc71171e805268645e7465575 (diff)
* fold-const.c (const_binop): Don't constant fold the operation
if the result has overflowed and flag_trapping_math. * simplify-rtx.c (simplify_const_binary_operation): Likewise. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@107092 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 6f829adfa77..0e74391fe51 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -1537,6 +1537,16 @@ const_binop (enum tree_code code, tree arg1, tree arg2, int notrunc)
inexact = real_arithmetic (&value, code, &d1, &d2);
real_convert (&result, mode, &value);
+ /* Don't constant fold this floating point operation if
+ the result has overflowed and flag_trapping_math. */
+
+ if (flag_trapping_math
+ && MODE_HAS_INFINITIES (mode)
+ && REAL_VALUE_ISINF (result)
+ && !REAL_VALUE_ISINF (d1)
+ && !REAL_VALUE_ISINF (d2))
+ return NULL_TREE;
+
/* Don't constant fold this floating point operation if the
result may dependent upon the run-time rounding mode and
flag_rounding_math is set, or if GCC's software emulation