1 /* PR rtl-optimization/52060 */
2 /* { dg-do run { target int32plus } } */
3 
4 extern void abort (void);
5 union U { float f; unsigned int i; };
6 
7 static inline __attribute__((always_inline)) unsigned int
foo(float x)8 foo (float x)
9 {
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;
24 }
25 
26 __attribute__((noinline)) unsigned int
bar(float x)27 bar (float x)
28 {
29   unsigned int a, b, c;
30   static const unsigned int d[128] =
31   {
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
40   };
41   a = foo (1048575.0f * x);
42   c = d[a >> 13];
43   b = (c << 13) | ((a >> (7 - c)) & 0x1fff);
44   return b;
45 }
46 
47 int
main()48 main ()
49 {
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;
57 }
58