From b5c525860dc6e776b1ae2593bb9ed1a1b4fd42d8 Mon Sep 17 00:00:00 2001 From: Richard Stallman Date: Tue, 11 Aug 1992 08:33:24 +0000 Subject: [PATCH] (fold): Don't fold (A op B ? A : C) if A is IEEE floating point, because A might be -0.0 or NaN. From-SVN: r1793 --- gcc/fold-const.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 207c75a8e17..6a1297097ad 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -4007,9 +4007,12 @@ fold (expr) /* If we have A op B ? A : C, we may be able to convert this to a simpler expression, depending on the operation and the values - of B and C. */ + of B and C. IEEE floating point prevents this though, + because A or B might be -0.0 or a NaN. */ if (TREE_CODE_CLASS (TREE_CODE (arg0)) == '<' + && (TARGET_FLOAT_FORMAT != IEEE_FLOAT_FORMAT + || TREE_CODE (TREE_TYPE (TREE_OPERAND (arg0, 0))) != REAL_TYPE) && operand_equal_for_comparison_p (TREE_OPERAND (arg0, 0), arg1, TREE_OPERAND (arg0, 1))) { -- 2.30.2