[NDS32] Add intrinsic functions for TLB operation and data prefech.
[official-gcc.git] / gcc / testsuite / gcc.dg / pr55940.c
blobd046d0b6912ff7f24db2780c6858571d68e04953
1 /* PR target/55940 */
2 /* { dg-do run } */
3 /* { dg-options "-Os" } */
4 /* { dg-additional-options "-mpreferred-stack-boundary=2" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */
6 struct S { int s; unsigned long t; };
8 __attribute__ ((noinline, noclone)) unsigned long long
9 bar (struct S *x, unsigned long y)
11 asm volatile ("" : : "r" (x), "r" (y) : "memory");
12 return x->s + y;
15 __attribute__ ((noinline, noclone)) unsigned long long
16 foo (struct S *x, unsigned long y)
18 unsigned long a;
19 if (__builtin_expect (((__UINTPTR_TYPE__) (x) + 0x1000U < 0x2000U), 0))
20 return ~0ULL;
21 if (__builtin_expect (x->s <= 0 || x->s > 9, 0))
22 return ~0ULL;
23 a = x->t >> 12;
24 if (y == a)
25 return ~0ULL;
26 if (x->s == 3)
27 return x->t + y * 4096;
28 return bar (x, y);
31 int va, vb, vc, vd;
33 int
34 main ()
36 struct S s;
37 asm volatile ("" : : : "memory");
38 int a = va, b = vb, c = vc, d = vd;
39 asm volatile ("" : : : "memory");
40 int i;
41 for (i = 0; i < 64; i++)
42 if (foo ((struct S *) 0, 0) != ~0ULL)
43 __builtin_abort ();
44 s.s = 3;
45 s.t = 2 << 12;
46 if (foo (&s, 2) != ~0ULL)
47 __builtin_abort ();
48 if (foo (&s, 3) != (2 << 12) + 3 * 4096)
49 __builtin_abort ();
50 asm volatile ("" : : : "memory");
51 va = a; vb = b; vc = c; vd = d;
52 asm volatile ("" : : : "memory");
53 return 0;