1 /* { dg-do compile  { target { powerpc*-*-* && lp64 } } } */
2 /* { dg-options "-O2 -fstack-protector-strong -mlong-double-128" } */
3 
4 extern long double foo (long double);
5 extern double bar (double);
6 typedef long long int64_t;
7 typedef unsigned long long uint64_t;
8 typedef union { int64_t i[2]; long double x; double d[2]; } mynumber;
9 static const double t512 = 0x1p512, tm256 = 0x1p-256, two54 = 0x1p54, twom54 = 0x1p-54;
10 
11 long double
foo(long double x)12 foo (long double x)
13 {
14   static const long double big = 134217728.0, big1 = 134217729.0;
15   long double t, s, i;
16   mynumber a, c;
17   uint64_t k, l;
18   int64_t m, n;
19   double d;
20 
21   a.x = x;
22   k = a.i[0] & 0x7fffffffffffffffL;
23 
24   if (k > 0x000fffff00000000L && k < 0x7ff0000000000000L)
25     {
26       if (x < 0)
27 	return (big1 - big1) / (big - big);
28       l = (k & 0x001fffffffffffffL) | 0x3fe0000000000000L;
29       if ((a.i[1] & 0x7fffffffffffffffL) != 0)
30 	{
31 	  n = (int64_t) ((l - k) * 2) >> 53;
32 	  m = (a.i[1] >> 52) & 0x7ff;
33 	  if (m == 0)
34 	    {
35 	      a.d[1] *= two54;
36 	      m = ((a.i[1] >> 52) & 0x7ff) - 54;
37 	    }
38 	  m += n;
39 	  if (m > 0)
40 	    a.i[1] = (a.i[1] & 0x800fffffffffffffL) | (m << 52);
41 	  else if (m <= -54)
42 	    {
43 	      a.i[1] &= 0x8000000000000000L;
44 	    }
45 	  else
46 	    {
47 	      m += 54;
48 	      a.i[1] = (a.i[1] & 0x800fffffffffffffL) | (m << 52);
49 	      a.d[1] *= twom54;
50 	    }
51 	}
52       a.i[0] = l;
53       s = a.x;
54       d = bar (a.d[0]);
55       c.i[0] = 0x2000000000000000L + ((k & 0x7fe0000000000000L) >> 1);
56       c.i[1] = 0;
57       i = d;
58       t = 0.5L * (i + s / i);
59       i = 0.5L * (t + s / t);
60       return c.x * i;
61     }
62   else
63     {
64       if (k >= 0x7ff0000000000000L)
65 
66 	return x * x + x;
67       if (x == 0)
68 	return x;
69       if (x < 0)
70 	return (big1 - big1) / (big - big);
71       return tm256 * foo (x * t512);
72     }
73 }
74