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