PR c++/86728 - C variadic generic lambda.
[official-gcc.git] / gcc / testsuite / g++.dg / opt / pr69570.C
blob11ed416745832c84172397511c1988dbf6d7e133
1 // PR rtl-optimization/69570
2 // { dg-do run }
3 // { dg-options "-O2" }
4 // { dg-additional-options "-fpic" { target fpic } }
5 // { dg-additional-options "-march=i686" { target ia32 } }
7 template <typename T> inline const T &
8 min (const T &a, const T &b)
10   if (b < a)
11     return b;
12   return a;
15 template <typename T> inline const T &
16 max (const T &a, const T &b)
18   if (a < b)
19     return b;
20   return a;
23 static inline void
24 foo (unsigned x, unsigned y, unsigned z, double &h, double &s, double &l)
26   double r = x / 255.0;
27   double g = y / 255.0;
28   double b = z / 255.0;
29   double m = max (r, max (g, b));
30   double n = min (r, min (g, b));
31   double d = m - n;
32   double e = m + n;
33   h = 0.0, s = 0.0, l = e / 2.0;
34   if (d > 0.0)
35     {
36       s = l > 0.5 ? d / (2.0 - e) : d / e;
37       if (m == r && m != g)
38         h = (g - b) / d + (g < b ? 6.0 : 0.0);
39       if (m == g && m != b)
40         h = (b - r) / d + 2.0;
41       if (m == b && m != r)
42         h = (r - g) / d + 4.0;
43       h /= 6.0;
44     }
47 __attribute__ ((noinline, noclone))
48 void bar (unsigned x[3], double y[3])
50   double h, s, l;
51   foo (x[0], x[1], x[2], h, s, l);
52   y[0] = h;
53   y[1] = s;
54   y[2] = l;
57 int
58 main ()
60   unsigned x[3] = { 0, 128, 0 };
61   double y[3];
63   bar (x, y);
64   if (__builtin_fabs (y[0] - 0.33333) > 0.001
65       || __builtin_fabs (y[1] - 1) > 0.001
66       || __builtin_fabs (y[2] - 0.25098) > 0.001)
67     __builtin_abort ();
69   return 0;