| 1 |
/* PR rtl-optimization/57003 */ |
| 2 |
/* { dg-do run { target { ! x32 } } } */ |
| 3 |
/* { dg-options "-O2" } */ |
| 4 |
|
| 5 |
#define N 2001 |
| 6 |
unsigned short *b, *c, *d; |
| 7 |
|
| 8 |
__attribute__ ((noinline, noclone)) unsigned |
| 9 |
bar (void) |
| 10 |
{ |
| 11 |
asm volatile ("" : : : "memory"); |
| 12 |
return N; |
| 13 |
} |
| 14 |
|
| 15 |
__attribute__ ((noinline, noclone)) unsigned short * |
| 16 |
baz (unsigned long x) |
| 17 |
{ |
| 18 |
if (x != N * sizeof (unsigned short) + 20) |
| 19 |
__builtin_abort (); |
| 20 |
asm volatile ("" : : : "memory"); |
| 21 |
return d; |
| 22 |
} |
| 23 |
|
| 24 |
__attribute__ ((ms_abi, noinline, noclone)) void |
| 25 |
foo (void) |
| 26 |
{ |
| 27 |
unsigned d; |
| 28 |
unsigned short *e; |
| 29 |
if ((d = bar ())) |
| 30 |
{ |
| 31 |
e = baz (d * sizeof (unsigned short) + 20); |
| 32 |
__builtin_memcpy (e, b, d * sizeof (unsigned short)); |
| 33 |
c = e; |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
int |
| 38 |
main () |
| 39 |
{ |
| 40 |
unsigned short a[2 * N]; |
| 41 |
int i; |
| 42 |
for (i = 0; i < 2 * N; i++) |
| 43 |
a[i] = i + 1; |
| 44 |
b = a; |
| 45 |
d = a + N; |
| 46 |
asm volatile ("" : : : "memory"); |
| 47 |
foo (); |
| 48 |
for (i = 0; i < N; i++) |
| 49 |
if (a[i] != i + 1 || a[i + N] != i + 1) |
| 50 |
__builtin_abort (); |
| 51 |
if (c != a + N) |
| 52 |
__builtin_abort (); |
| 53 |
return 0; |
| 54 |
} |