FSF GCC merge 02/23/03
[official-gcc.git] / gcc / testsuite / gcc.dg / 20020426-2.c
blob18a172767a1f6c83af1ce56a49c4a02f613e46ba
1 /* PR optimization/6475
2 Distilled from zlib sources. */
3 /* { dg-do run } */
4 /* { dg-options "-O2" } */
5 /* { dg-options "-O2 -frename-registers -fomit-frame-pointer -fPIC -mtune=i686" { target i?86-*-* } } */
7 typedef struct
9 union
11 struct
13 unsigned char a3;
14 unsigned char a4;
15 } a2;
16 unsigned int a5;
17 } a0;
18 unsigned int a1;
19 } A;
21 static int
22 foo (unsigned int *b, unsigned int n, unsigned int s, const unsigned int *d,
23 const unsigned int *e, A **t, unsigned int *m, A *hp, unsigned int *hn,
24 unsigned int *v)
26 unsigned int a, c[15 + 1], f;
27 int g, h;
28 unsigned int i, j, k;
29 int l;
30 unsigned int ee;
31 unsigned int *p;
32 A *q, r, *u[15];
33 int w;
34 unsigned int x[15 + 1], *xx;
35 int y;
36 unsigned int z;
37 p = c;
38 *p++ = 0; *p++ = 0; *p++ = 0; *p++ = 0;
39 *p++ = 0; *p++ = 0; *p++ = 0; *p++ = 0;
40 *p++ = 0; *p++ = 0; *p++ = 0; *p++ = 0;
41 *p++ = 0; *p++ = 0; *p++ = 0; *p++ = 0;
42 p = b;
43 i = n;
45 c[*p++]++;
46 while (--i);
47 if (c[0] == n)
49 *t = (A *) 0;
50 *m = 0;
51 return 0;
53 l = *m;
54 for (j = 1; j <= 15; j++)
55 if (c[j])
56 break;
57 k = j;
58 if ((unsigned int) l < j)
59 l = j;
60 for (i = 15; i; i--)
61 if (c[i])
62 break;
63 g = i;
64 if ((unsigned int) l > i)
65 l = i;
66 *m = l;
67 for (y = 1 << j; j < i; j++, y <<= 1)
68 if ((y -= c[j]) < 0)
69 return -3;
70 if ((y -= c[i]) < 0)
71 return -3;
72 c[i] += y;
73 x[1] = j = 0;
74 p = c + 1;
75 xx = x + 2;
76 while (--i)
77 *xx++ = (j += *p++);
78 p = b;
79 i = 0;
81 if ((j = *p++) != 0)
82 v[x[j]++] = i;
83 while (++i < n);
84 n = x[g];
85 x[0] = i = 0;
86 p = v;
87 h = -1;
88 w = -l;
89 u[0] = (A *) 0;
90 q = (A *) 0;
91 z = 0;
92 for (; k <= g; k++)
94 a = c[k];
95 while (a--)
97 while (k > w + l)
99 h++;
100 w += l;
101 z = g - w;
102 z = z > (unsigned int) l ? l : z;
103 if ((f = 1 << (j = k - w)) > a + 1)
105 f -= a + 1;
106 xx = c + k;
107 if (j < z)
108 while (++j < z)
110 if ((f <<= 1) <= *++xx)
111 break;
112 f -= *xx;
115 z = 1 << j;
116 if (*hn + z > 1440)
117 return -3;
118 u[h] = q = hp + *hn;
119 *hn += z;
120 if (h)
122 x[h] = i;
123 r.a0.a2.a4 = (unsigned char) l;
124 r.a0.a2.a3 = (unsigned char) j;
125 j = i >> (w - l);
126 r.a1 = (unsigned int) (q - u[h - 1] - j);
127 u[h - 1][j] = r;
129 else
130 *t = q;
132 r.a0.a2.a4 = (unsigned char) (k - w);
133 if (p >= v + n)
134 r.a0.a2.a3 = 128 + 64;
135 else if (*p < s)
137 r.a0.a2.a3 = (unsigned char) (*p < 256 ? 0 : 32 + 64);
138 r.a1 = *p++;
140 else
142 r.a0.a2.a3 = (unsigned char) (e[*p - s] + 16 + 64);
143 r.a1 = d[*p++ - s];
145 f = 1 << (k - w);
146 for (j = i >> w; j < z; j += f)
147 q[j] = r;
148 for (j = 1 << (k - 1); i & j; j >>= 1)
149 i ^= j;
150 i ^= j;
151 ee = (1 << w) - 1;
152 while ((i & ee) != x[h])
154 h--;
155 w -= l;
156 ee = (1 << w) - 1;
160 return y != 0 && g != 1 ? (-5) : 0;
163 int a[19] = { 3, 4, 0, 2, 2, [17] = 3, 3 };
164 int d[19];
165 A h[1440];
168 main (void)
170 int b = 0, c = 0;
171 A *e = 0;
172 foo (a, 19, 19, 0, 0, &e, &b, h, &c, d);
173 exit (0);