2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.dg / builtins-6.c
blob2ebb0b2d86d8049451e06e7aa776d106ea181293
1 /* Copyright (C) 2003 Free Software Foundation.
3 Verify that constant folding comparisons against built-in math functions
4 don't cause any problems for the compiler, and produce expected results.
6 Written by Roger Sayle, 15th March 2003. */
8 /* { dg-do run } */
9 /* { dg-options "-O2 -ffast-math" } */
11 #include <float.h>
13 extern void abort (void);
14 extern double sqrt (double);
16 int test1(double x)
18 return sqrt(x) < -9.0;
21 int test2(double x)
23 return sqrt(x) > -9.0;
26 int test3(double x)
28 return sqrt(x) < 9.0;
31 int test4(double x)
33 return sqrt(x) > 9.0;
36 int test5(double x)
38 return sqrt(x) < DBL_MAX;
41 int test6(double x)
43 return sqrt(x) > DBL_MAX;
46 int main()
48 double x;
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 ();
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 ();
78 return 0;