aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Stallman <rms@gnu.org>1992-08-12 07:43:50 +0000
committerRichard Stallman <rms@gnu.org>1992-08-12 07:43:50 +0000
commit6a1746af423210c8419b7e90d0954ed28f9e8535 (patch)
treed730e62c5d043ac5b035dc4052c43e975436ee31 /gcc
parente92b33f50827f1f18db368670f855afeede8ef47 (diff)
downloadgcc-6a1746af423210c8419b7e90d0954ed28f9e8535.zip
gcc-6a1746af423210c8419b7e90d0954ed28f9e8535.tar.gz
gcc-6a1746af423210c8419b7e90d0954ed28f9e8535.tar.bz2
(operand_equal_p): Make it clear that this function tests for indistinguishable values, not for equality as computed by `=='...
(operand_equal_p): Make it clear that this function tests for indistinguishable values, not for equality as computed by `=='; the distinction is important for IEEE NaNs and -0.0. From-SVN: r1807
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fold-const.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 6a12970..a710750 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -1567,8 +1567,13 @@ swap_tree_comparison (code)
}
}
-/* Return nonzero if two operands are necessarily equal.
- If ONLY_CONST is non-zero, only return non-zero for constants. */
+/* Return nonzero if two operands are necessarily equal.
+ If ONLY_CONST is non-zero, only return non-zero for constants.
+ This function tests whether the operands are indistinguishable;
+ it does not test whether they are equal using C's == operation.
+ The distinction is important for IEEE floating point, because
+ (1) -0.0 and 0.0 are distinguishable, but -0.0==0.0, and
+ (2) two NaNs may be indistinguishable, but NaN!=NaN. */
int
operand_equal_p (arg0, arg1, only_const)
@@ -1604,18 +1609,11 @@ operand_equal_p (arg0, arg1, only_const)
&& TREE_INT_CST_HIGH (arg0) == TREE_INT_CST_HIGH (arg1))
return 1;
- /* Detect when real constants are equal.
- But reject weird values because we can't be sure what to do with them. */
+ /* Detect when real constants are equal. */
if (TREE_CODE (arg0) == TREE_CODE (arg1)
- && TREE_CODE (arg0) == REAL_CST
- && !bcmp (&TREE_REAL_CST (arg0), &TREE_REAL_CST (arg1),
- sizeof (REAL_VALUE_TYPE))
- /* Some people say these are not necessary.
- But they do little harm, and taking them out would be risky.
- So leave them and let's not spend any more time on them--rms. */
- && !REAL_VALUE_ISINF (TREE_REAL_CST (arg0))
- && !REAL_VALUE_ISNAN (TREE_REAL_CST (arg0)))
- return 1;
+ && TREE_CODE (arg0) == REAL_CST)
+ return !bcmp (&TREE_REAL_CST (arg0), &TREE_REAL_CST (arg1),
+ sizeof (REAL_VALUE_TYPE));
if (only_const)
return 0;
@@ -3316,7 +3314,7 @@ fold (expr)
/* Fold &x - &x. This can happen from &x.foo - &x.
This is unsafe for certain floats even in non-IEEE formats.
In IEEE, it is unsafe because it does wrong for NaNs.
- Also note that operand_equal_p is always false is an operand
+ Also note that operand_equal_p is always false if an operand
is volatile. */
if (operand_equal_p (arg0, arg1,