(cmp { build_real (TREE_TYPE (@0), dconst0); } @1))
/* x != NaN is always true, other ops are always false. */
(if (REAL_VALUE_ISNAN (TREE_REAL_CST (@1))
+ && (cmp == EQ_EXPR || cmp == NE_EXPR || !flag_trapping_math)
&& !tree_expr_signaling_nan_p (@1)
&& !tree_expr_maybe_signaling_nan_p (@0))
{ constant_boolean_node (cmp == NE_EXPR, type); })
/* NaN != y is always true, other ops are always false. */
(if (TREE_CODE (@0) == REAL_CST
&& REAL_VALUE_ISNAN (TREE_REAL_CST (@0))
+ && (cmp == EQ_EXPR || cmp == NE_EXPR || !flag_trapping_math)
&& !tree_expr_signaling_nan_p (@0)
&& !tree_expr_signaling_nan_p (@1))
{ constant_boolean_node (cmp == NE_EXPR, type); })
{
volatile int nonfinite_1;
nonfinite_1 = (float) x > QNAN;
- /* { dg-final { scan-tree-dump "nonfinite_1 = 0" "original" } } */
+ /* { dg-final { scan-tree-dump "nonfinite_1 = \\(float\\)" "original" } } */
}
{
volatile int nonfinite_2;
nonfinite_2 = (float) x >= QNAN;
- /* { dg-final { scan-tree-dump "nonfinite_2 = 0" "original" } } */
+ /* { dg-final { scan-tree-dump "nonfinite_2 = \\(float\\)" "original" } } */
}
{
volatile int nonfinite_3;
nonfinite_3 = (float) x < QNAN;
- /* { dg-final { scan-tree-dump "nonfinite_3 = 0" "original" } } */
+ /* { dg-final { scan-tree-dump "nonfinite_3 = \\(float\\)" "original" } } */
}
{
volatile int nonfinite_4;
nonfinite_4 = (float) x <= QNAN;
- /* { dg-final { scan-tree-dump "nonfinite_4 = 0" "original" } } */
+ /* { dg-final { scan-tree-dump "nonfinite_4 = \\(float\\)" "original" } } */
}
{
--- /dev/null
+/* { dg-do compile } */
+/* { 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. */
+
+#define QNAN __builtin_nanf ("0")
+
+void nonfinite(unsigned short x) {
+ {
+ volatile int nonfinite_1;
+ nonfinite_1 = (float) x > QNAN;
+ /* { dg-final { scan-tree-dump "nonfinite_1 = 0" "original" } } */
+ }
+
+ {
+ volatile int nonfinite_2;
+ nonfinite_2 = (float) x >= QNAN;
+ /* { dg-final { scan-tree-dump "nonfinite_2 = 0" "original" } } */
+ }
+
+ {
+ volatile int nonfinite_3;
+ nonfinite_3 = (float) x < QNAN;
+ /* { dg-final { scan-tree-dump "nonfinite_3 = 0" "original" } } */
+ }
+
+ {
+ volatile int nonfinite_4;
+ nonfinite_4 = (float) x <= QNAN;
+ /* { dg-final { scan-tree-dump "nonfinite_4 = 0" "original" } } */
+ }
+
+ {
+ volatile int nonfinite_11;
+ nonfinite_11 = (float) x == QNAN;
+ /* { dg-final { scan-tree-dump "nonfinite_11 = 0" "original" } } */
+ }
+
+ {
+ volatile int nonfinite_12;
+ nonfinite_12 = (float) x != QNAN;
+ /* { dg-final { scan-tree-dump "nonfinite_12 = 1" "original" } } */
+ }
+}
+lappend additional_flags "-fno-trapping-math"
# The ARM VxWorks kernel uses an external floating-point library in
# which routines like __ledf2 are just aliases for __cmpdf2. These
# routines therefore don't handle NaNs correctly.
--- /dev/null
+
+const double dnan = 1.0/0.0 - 1.0/0.0;
+double x = 1.0;
+
+extern void link_error (void);
+extern void abort (void);
+
+main ()
+{
+#if ! defined (__vax__) && ! defined (_CRAY)
+ /* NaN is an IEEE unordered operand. All these test should be false. */
+ if (dnan == dnan)
+ link_error ();
+ if (dnan != x)
+ x = 1.0;
+ else
+ link_error ();
+
+ if (dnan == x)
+ link_error ();
+#endif
+ exit (0);
+}
+
+#ifndef __OPTIMIZE__
+void link_error (void)
+{
+ abort ();
+}
+#endif
+
--- /dev/null
+# The ARM VxWorks kernel uses an external floating-point library in
+# which routines like __ledf2 are just aliases for __cmpdf2. These
+# routines therefore don't handle NaNs correctly.
+if [istarget "arm*-*-vxworks*"] {
+ set torture_eval_before_execute {
+ global compiler_conditional_xfail_data
+ set compiler_conditional_xfail_data {
+ "The ARM kernel uses a flawed floating-point library."
+ { "*-*-*" }
+ { "-O0" }
+ { "-mrtp" }
+ }
+ }
+}
+
+return 0