PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / pr57003.c
blob841deb929cdda5d828a3ccf7d0abf99e741ae55c
1 /* PR rtl-optimization/57003 */
2 /* { dg-do run { target { ! x32 } } } */
3 /* { dg-options "-O2" } */
5 #define N 2001
6 unsigned short *b, *c, *d;
8 __attribute__ ((noinline, noclone)) unsigned
9 bar (void)
11 asm volatile ("" : : : "memory");
12 return N;
15 __attribute__ ((noinline, noclone)) unsigned short *
16 baz (unsigned long x)
18 if (x != N * sizeof (unsigned short) + 20)
19 __builtin_abort ();
20 asm volatile ("" : : : "memory");
21 return d;
24 __attribute__ ((ms_abi, noinline, noclone)) void
25 foo (void)
27 unsigned d;
28 unsigned short *e;
29 if ((d = bar ()))
31 e = baz (d * sizeof (unsigned short) + 20);
32 __builtin_memcpy (e, b, d * sizeof (unsigned short));
33 c = e;
37 int
38 main ()
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;