OSDN Git Service

testsuite/
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.c-torture / execute / pr39501.c
1 /* { dg-options "-ffast-math" } */
2 #define min1(a,b) ((a) < (b) ? (a) : (b))
3 #define max1(a,b) ((a) > (b) ? (a) : (b))
4
5 #define min2(a,b) ((a) <= (b) ? (a) : (b))
6 #define max2(a,b) ((a) >= (b) ? (a) : (b))
7
8 #define F(type,n)                                               \
9   type __attribute__((noinline)) type##_##n(type a, type b)     \
10   {                                                             \
11     return n(a, b);                                             \
12   }
13
14 F(float,min1)
15 F(float,min2)
16 F(float,max1)
17 F(float,max2)
18
19 F(double,min1)
20 F(double,min2)
21 F(double,max1)
22 F(double,max2)
23
24 int main()
25 {
26   if (float_min1(0.f, -1.f) != -1.f) abort();
27   if (float_min1(-1.f, 0.f) != -1.f) abort();
28   if (float_min1(0.f, 1.f)  != 0.f)  abort();
29   if (float_min1(1.f, 0.f)  != 0.f)  abort();
30   if (float_min1(-1.f, 1.f) != -1.f) abort();
31   if (float_min1(1.f, -1.f) != -1.f) abort();
32   
33   if (float_max1(0.f, -1.f) != 0.f)  abort();
34   if (float_max1(-1.f, 0.f) != 0.f)  abort();
35   if (float_max1(0.f, 1.f)  != 1.f)  abort();
36   if (float_max1(1.f, 0.f)  != 1.f)  abort();
37   if (float_max1(-1.f, 1.f) != 1.f)  abort();
38   if (float_max1(1.f, -1.f) != 1.f)  abort();
39   
40   if (float_min2(0.f, -1.f) != -1.f) abort();
41   if (float_min2(-1.f, 0.f) != -1.f) abort();
42   if (float_min2(0.f, 1.f)  != 0.f)  abort();
43   if (float_min2(1.f, 0.f)  != 0.f)  abort();
44   if (float_min2(-1.f, 1.f) != -1.f) abort();
45   if (float_min2(1.f, -1.f) != -1.f) abort();
46   
47   if (float_max2(0.f, -1.f) != 0.f)  abort();
48   if (float_max2(-1.f, 0.f) != 0.f)  abort();
49   if (float_max2(0.f, 1.f)  != 1.f)  abort();
50   if (float_max2(1.f, 0.f)  != 1.f)  abort();
51   if (float_max2(-1.f, 1.f) != 1.f)  abort();
52   if (float_max2(1.f, -1.f) != 1.f)  abort();
53   
54   if (double_min1(0., -1.) != -1.) abort();
55   if (double_min1(-1., 0.) != -1.) abort();
56   if (double_min1(0., 1.)  != 0.)  abort();
57   if (double_min1(1., 0.)  != 0.)  abort();
58   if (double_min1(-1., 1.) != -1.) abort();
59   if (double_min1(1., -1.) != -1.) abort();
60   
61   if (double_max1(0., -1.) != 0.)  abort();
62   if (double_max1(-1., 0.) != 0.)  abort();
63   if (double_max1(0., 1.)  != 1.)  abort();
64   if (double_max1(1., 0.)  != 1.)  abort();
65   if (double_max1(-1., 1.) != 1.)  abort();
66   if (double_max1(1., -1.) != 1.)  abort();
67   
68   if (double_min2(0., -1.) != -1.) abort();
69   if (double_min2(-1., 0.) != -1.) abort();
70   if (double_min2(0., 1.)  != 0.)  abort();
71   if (double_min2(1., 0.)  != 0.)  abort();
72   if (double_min2(-1., 1.) != -1.) abort();
73   if (double_min2(1., -1.) != -1.) abort();
74   
75   if (double_max2(0., -1.) != 0.)  abort();
76   if (double_max2(-1., 0.) != 0.)  abort();
77   if (double_max2(0., 1.)  != 1.)  abort();
78   if (double_max2(1., 0.)  != 1.)  abort();
79   if (double_max2(-1., 1.) != 1.)  abort();
80   if (double_max2(1., -1.) != 1.)  abort();
81   
82   exit(0);
83 }