| 1 |
/* PR tree-optimization/37573 */ |
| 2 |
/* { dg-require-effective-target int32plus } */ |
| 3 |
|
| 4 |
struct S |
| 5 |
{ |
| 6 |
unsigned int *a; |
| 7 |
unsigned int b; |
| 8 |
unsigned int c[624]; |
| 9 |
}; |
| 10 |
|
| 11 |
static unsigned char __attribute__((noinline)) |
| 12 |
foo (struct S *s) |
| 13 |
{ |
| 14 |
unsigned int r; |
| 15 |
if (!--s->b) |
| 16 |
{ |
| 17 |
unsigned int *c = s->c; |
| 18 |
unsigned int i; |
| 19 |
s->a = c; |
| 20 |
for (i = 0; i < 227; i++) |
| 21 |
c[i] = ((((c[i] ^ c[i + 1]) & 0x7ffffffe) ^ c[i]) >> 1) |
| 22 |
^ ((0 - (c[i + 1] & 1)) & 0x9908b0df) ^ c[i + 397]; |
| 23 |
} |
| 24 |
r = *(s->a++); |
| 25 |
r ^= (r >> 11); |
| 26 |
r ^= ((r & 0xff3a58ad) << 7); |
| 27 |
r ^= ((r & 0xffffdf8c) << 15); |
| 28 |
r ^= (r >> 18); |
| 29 |
return (unsigned char) (r >> 1); |
| 30 |
} |
| 31 |
|
| 32 |
static void __attribute__((noinline)) |
| 33 |
bar (unsigned char *p, unsigned int q, unsigned int r) |
| 34 |
{ |
| 35 |
struct S s; |
| 36 |
unsigned int i; |
| 37 |
unsigned int *c = s.c; |
| 38 |
*c = r; |
| 39 |
for (i = 1; i < 624; i++) |
| 40 |
c[i] = i + 0x6c078965 * ((c[i - 1] >> 30) ^ c[i - 1]); |
| 41 |
s.b = 1; |
| 42 |
while (q--) |
| 43 |
*p++ ^= foo (&s); |
| 44 |
}; |
| 45 |
|
| 46 |
static unsigned char p[23] = { |
| 47 |
0xc0, 0x49, 0x17, 0x32, 0x62, 0x1e, 0x2e, 0xd5, 0x4c, 0x19, 0x28, 0x49, |
| 48 |
0x91, 0xe4, 0x72, 0x83, 0x91, 0x3d, 0x93, 0x83, 0xb3, 0x61, 0x38 |
| 49 |
}; |
| 50 |
|
| 51 |
static unsigned char q[23] = { |
| 52 |
0x3e, 0x41, 0x55, 0x54, 0x4f, 0x49, 0x54, 0x20, 0x55, 0x4e, 0x49, 0x43, |
| 53 |
0x4f, 0x44, 0x45, 0x20, 0x53, 0x43, 0x52, 0x49, 0x50, 0x54, 0x3c |
| 54 |
}; |
| 55 |
|
| 56 |
int |
| 57 |
main (void) |
| 58 |
{ |
| 59 |
unsigned int s; |
| 60 |
s = 23; |
| 61 |
bar (p, s, s + 0xa25e); |
| 62 |
if (__builtin_memcmp (p, q, s) != 0) |
| 63 |
__builtin_abort (); |
| 64 |
return 0; |
| 65 |
} |
| 66 |
|