@@ -6823,13 +6823,13 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
tree itype = TREE_TYPE (@0);
format_helper fmt (REAL_MODE_FORMAT (TYPE_MODE (TREE_TYPE (@1))));
const REAL_VALUE_TYPE *cst = TREE_REAL_CST_PTR (@1);
- /* Be careful to preserve any potential exceptions due to
- NaNs. qNaNs are ok in == or != context.
- TODO: relax under -fno-trapping-math or
- -fno-signaling-nans. */
- bool exception_p
- = real_isnan (cst) && (cst->signalling
- || (cmp != EQ_EXPR && cmp != NE_EXPR));
+ /* Be careful to preserve any potential exceptions due to NaNs.
+ qNaNs are ok in == or != context. */
+ bool exception_p = real_isnan (cst)
+ && flag_trapping_math
+ && ((cmp != EQ_EXPR && cmp != NE_EXPR)
+ || (cst->signalling
+ && HONOR_SNANS (TREE_TYPE (@1))));
}
/* TODO: allow non-fitting itype and SNaNs when
-fno-trapping-math. */
@@ -2,9 +2,7 @@
/* { dg-options "-O -fsignaling-nans -fdump-tree-original" } */
/* We can not get rid of comparison in tests below because of
- pending NaN exceptions.
-
- TODO: avoid under -fno-trapping-math. */
+ pending NaN exceptions. */
#define QNAN __builtin_nanf ("0")
#define SNAN __builtin_nansf ("0")
@@ -2,11 +2,10 @@
/* { dg-options "-O -fno-signaling-nans -fno-trapping-math -fdump-tree-original" } */
/* We can not get rid of comparison in tests below because of
- pending NaN exceptions.
-
- TODO: avoid under -fno-trapping-math. */
+ pending NaN exceptions. */
#define QNAN __builtin_nanf ("0")
+#define SNAN __builtin_nansf ("0")
void nonfinite(unsigned short x) {
{
@@ -34,6 +33,43 @@ void nonfinite(unsigned short x) {
}
{
+ volatile int nonfinite_5;
+ nonfinite_5 = (float) x > SNAN;
+ /* { dg-final { scan-tree-dump "nonfinite_5 = 0" "original" } } */
+ }
+
+ {
+ volatile int nonfinite_6;
+ nonfinite_6 = (float) x >= SNAN;
+ /* { dg-final { scan-tree-dump "nonfinite_6 = 0" "original" } } */
+ }
+
+ {
+ volatile int nonfinite_7;
+ nonfinite_7 = (float) x < SNAN;
+ /* { dg-final { scan-tree-dump "nonfinite_7 = 0" "original" } } */
+ }
+
+ {
+ volatile int nonfinite_8;
+ nonfinite_8 = (float) x <= SNAN;
+ /* { dg-final { scan-tree-dump "nonfinite_8 = 0" "original" } } */
+ }
+
+ {
+ volatile int nonfinite_9;
+ nonfinite_9 = (float) x == SNAN;
+ /* { dg-final { scan-tree-dump "nonfinite_9 = 0" "original" } } */
+ }
+
+ {
+ volatile int nonfinite_10;
+ nonfinite_10 = (float) x != SNAN;
+ /* { dg-final { scan-tree-dump "nonfinite_10 = 1" "original" } } *
+ */
+ }
+
+ {
volatile int nonfinite_11;
nonfinite_11 = (float) x == QNAN;
/* { dg-final { scan-tree-dump "nonfinite_11 = 0" "original" } } */