1 /* Copyright (C) 2003  Free Software Foundation.
2 
3    Verify that constant folding comparisons against built-in math functions
4    don't cause any problems for the compiler, and produce expected results.
5 
6    Written by Roger Sayle, 15th March 2003.  */
7 
8 /* { dg-do run } */
9 /* { dg-options "-O2 -ffast-math" } */
10 
11 #include <float.h>
12 
13 extern void abort (void);
14 extern double sqrt (double);
15 
test1(double x)16 int test1(double x)
17 {
18   return sqrt(x) < -9.0;
19 }
20 
test2(double x)21 int test2(double x)
22 {
23   return sqrt(x) > -9.0;
24 }
25 
test3(double x)26 int test3(double x)
27 {
28   return sqrt(x) < 9.0;
29 }
30 
test4(double x)31 int test4(double x)
32 {
33   return sqrt(x) > 9.0;
34 }
35 
test5(double x)36 int test5(double x)
37 {
38   return sqrt(x) < DBL_MAX;
39 }
40 
test6(double x)41 int test6(double x)
42 {
43   return sqrt(x) > DBL_MAX;
44 }
45 
main()46 int main()
47 {
48   double x;
49 
50   x = 80.0;
51   if (test1 (x))
52     abort ();
53   if (! test2 (x))
54     abort ();
55   if (! test3 (x))
56     abort ();
57   if (test4 (x))
58     abort ();
59   if (! test5 (x))
60     abort ();
61   if (test6 (x))
62     abort ();
63 
64   x = 100.0;
65   if (test1 (x))
66     abort ();
67   if (! test2 (x))
68     abort ();
69   if (test3 (x))
70     abort ();
71   if (! test4 (x))
72     abort ();
73   if (! test5 (x))
74     abort ();
75   if (test6 (x))
76     abort ();
77 
78   return 0;
79 }
80 
81