Rebase.
[official-gcc.git] / gcc / testsuite / gcc.dg / torture / pr52060.c
blob44207a503c15afd01a7b59a504ae636ee7794627
1 /* PR rtl-optimization/52060 */
2 /* { dg-do run { target int32plus } } */
4 extern void abort (void);
5 union U { float f; unsigned int i; };
7 static inline __attribute__((always_inline)) unsigned int
8 foo (float x)
10 union U u;
11 unsigned int a, b, c;
12 int d;
13 int e;
14 u.f = x;
15 d = ((unsigned) u.i >> 23) & 0xFF;
16 c = d < 126 ? 0 : ~0;
17 e = 127 + 30 - d;
18 a = (u.i << 8) | 0x80000000U;
19 b = a & ((1 << e) - 1);
20 a = a >> e;
21 c &= (b | (a & 2)) ? ~0 : ~1;
22 a = ((a + 1U) >> 1) & c;
23 return a;
26 __attribute__((noinline)) unsigned int
27 bar (float x)
29 unsigned int a, b, c;
30 static const unsigned int d[128] =
32 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
33 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
34 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
35 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
36 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
37 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
38 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
39 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6, 7
41 a = foo (1048575.0f * x);
42 c = d[a >> 13];
43 b = (c << 13) | ((a >> (7 - c)) & 0x1fff);
44 return b;
47 int
48 main ()
50 union U u;
51 u.f = 1048575.0f;
52 if (sizeof (u.i) == sizeof (u.f)
53 && u.i == 0x497ffff0U
54 && bar (1.0f) != 65535)
55 abort ();
56 return 0;