aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/compile/20030405-1.c
blob: 2e61f1fa3ff3dd3cd7b6f64b18cbca4e09b6fb2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* PR optimization/10024 */
extern int *allegro_errno;
typedef long fixed;
extern inline int
fixfloor (fixed x)
{
  if (x >= 0)
    return (x >> 16);
  else
    return ~((~x) >> 16);
}
extern inline int
fixtoi (fixed x)
{
  return fixfloor (x) + ((x & 0x8000) >> 15);
}
extern inline fixed
ftofix (double x)
{
  if (x > 32767.0)
    {
      *allegro_errno = 34;
      return 0x7FFFFFFF;
    }
  if (x < -32767.0)
    {
      *allegro_errno = 34;
      return -0x7FFFFFFF;
    }
  return (long) (x * 65536.0 + (x < 0 ? -0.5 : 0.5));
}
extern inline double
fixtof (fixed x)
{
  return (double) x / 65536.0;
}
extern inline fixed
fixdiv (fixed x, fixed y)
{
  if (y == 0)
    {
      *allegro_errno = 34;
      return (x < 0) ? -0x7FFFFFFF : 0x7FFFFFFF;
    }
  else
    return ftofix (fixtof (x) / fixtof (y));
}
extern inline fixed
itofix (int x)
{
  return x << 16;
}

int
foo (int n)
{
  return fixtoi (fixdiv (itofix (512), itofix (n)));
}