This commit was manufactured by cvs2svn to create branch
[official-gcc.git] / gcc / testsuite / gcc.dg / 20020426-2.c
blob19bf991b3466588d9f0ab44617935131edf9eeab
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-*-* } } */
6 /* { dg-skip-if "" { i?86-*-* } { "-m64" } { "" } } */
7 /* { dg-bogus "\[Uu\]nresolved symbol .(_GLOBAL_OFFSET_TABLE_|\[_.A-Za-z\]\[_.0-9A-Za-z\]*@(PLT|GOT|GOTOFF))" "PIC unsupported" { xfail *-*-netware* } 0 } */
9 extern void exit (int);
11 typedef struct
13 union
15 struct
17 unsigned char a3;
18 unsigned char a4;
19 } a2;
20 unsigned int a5;
21 } a0;
22 unsigned int a1;
23 } A;
25 static int
26 foo (unsigned int *b, unsigned int n, unsigned int s, const unsigned int *d,
27 const unsigned int *e, A **t, unsigned int *m, A *hp, unsigned int *hn,
28 unsigned int *v)
30 unsigned int a, c[15 + 1], f;
31 int g, h;
32 unsigned int i, j, k;
33 int l;
34 unsigned int ee;
35 unsigned int *p;
36 A *q, r, *u[15];
37 int w;
38 unsigned int x[15 + 1], *xx;
39 int y;
40 unsigned int z;
41 p = c;
42 *p++ = 0; *p++ = 0; *p++ = 0; *p++ = 0;
43 *p++ = 0; *p++ = 0; *p++ = 0; *p++ = 0;
44 *p++ = 0; *p++ = 0; *p++ = 0; *p++ = 0;
45 *p++ = 0; *p++ = 0; *p++ = 0; *p++ = 0;
46 p = b;
47 i = n;
49 c[*p++]++;
50 while (--i);
51 if (c[0] == n)
53 *t = (A *) 0;
54 *m = 0;
55 return 0;
57 l = *m;
58 for (j = 1; j <= 15; j++)
59 if (c[j])
60 break;
61 k = j;
62 if ((unsigned int) l < j)
63 l = j;
64 for (i = 15; i; i--)
65 if (c[i])
66 break;
67 g = i;
68 if ((unsigned int) l > i)
69 l = i;
70 *m = l;
71 for (y = 1 << j; j < i; j++, y <<= 1)
72 if ((y -= c[j]) < 0)
73 return -3;
74 if ((y -= c[i]) < 0)
75 return -3;
76 c[i] += y;
77 x[1] = j = 0;
78 p = c + 1;
79 xx = x + 2;
80 while (--i)
81 *xx++ = (j += *p++);
82 p = b;
83 i = 0;
85 if ((j = *p++) != 0)
86 v[x[j]++] = i;
87 while (++i < n);
88 n = x[g];
89 x[0] = i = 0;
90 p = v;
91 h = -1;
92 w = -l;
93 u[0] = (A *) 0;
94 q = (A *) 0;
95 z = 0;
96 for (; k <= g; k++)
98 a = c[k];
99 while (a--)
101 while (k > w + l)
103 h++;
104 w += l;
105 z = g - w;
106 z = z > (unsigned int) l ? l : z;
107 if ((f = 1 << (j = k - w)) > a + 1)
109 f -= a + 1;
110 xx = c + k;
111 if (j < z)
112 while (++j < z)
114 if ((f <<= 1) <= *++xx)
115 break;
116 f -= *xx;
119 z = 1 << j;
120 if (*hn + z > 1440)
121 return -3;
122 u[h] = q = hp + *hn;
123 *hn += z;
124 if (h)
126 x[h] = i;
127 r.a0.a2.a4 = (unsigned char) l;
128 r.a0.a2.a3 = (unsigned char) j;
129 j = i >> (w - l);
130 r.a1 = (unsigned int) (q - u[h - 1] - j);
131 u[h - 1][j] = r;
133 else
134 *t = q;
136 r.a0.a2.a4 = (unsigned char) (k - w);
137 if (p >= v + n)
138 r.a0.a2.a3 = 128 + 64;
139 else if (*p < s)
141 r.a0.a2.a3 = (unsigned char) (*p < 256 ? 0 : 32 + 64);
142 r.a1 = *p++;
144 else
146 r.a0.a2.a3 = (unsigned char) (e[*p - s] + 16 + 64);
147 r.a1 = d[*p++ - s];
149 f = 1 << (k - w);
150 for (j = i >> w; j < z; j += f)
151 q[j] = r;
152 for (j = 1 << (k - 1); i & j; j >>= 1)
153 i ^= j;
154 i ^= j;
155 ee = (1 << w) - 1;
156 while ((i & ee) != x[h])
158 h--;
159 w -= l;
160 ee = (1 << w) - 1;
164 return y != 0 && g != 1 ? (-5) : 0;
167 unsigned int a[19] = { 3, 4, 0, 2, 2, [17] = 3, 3 };
168 unsigned int d[19];
169 A h[1440];
172 main (void)
174 unsigned int b = 0, c = 0;
175 A *e = 0;
176 foo (a, 19, 19, 0, 0, &e, &b, h, &c, d);
177 exit (0);