Daily bump.
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / builtin-prefetch-5.c
blobf42a2c0ca87e3f54770d8dcb04b2f041c605753c
1 /* Test that __builtin_prefetch does no harm.
3 Use addresses that are unlikely to be word-aligned. Some targets
4 have alignment requirements for prefetch addresses, so make sure the
5 compiler takes care of that. This fails if it aborts, anything else
6 is OK. */
8 struct S {
9 short a;
10 short b;
11 char c[8];
12 } s;
14 char arr[100];
15 char *ptr = arr;
16 int idx = 3;
18 void
19 arg_ptr (char *p)
21 __builtin_prefetch (p, 0, 0);
24 void
25 arg_idx (char *p, int i)
27 __builtin_prefetch (&p[i], 0, 0);
30 void
31 glob_ptr (void)
33 __builtin_prefetch (ptr, 0, 0);
36 void
37 glob_idx (void)
39 __builtin_prefetch (&ptr[idx], 0, 0);
42 int
43 main ()
45 __builtin_prefetch (&s.b, 0, 0);
46 __builtin_prefetch (&s.c[1], 0, 0);
48 arg_ptr (&s.c[1]);
49 arg_ptr (ptr+3);
50 arg_idx (ptr, 3);
51 arg_idx (ptr+1, 2);
52 idx = 3;
53 glob_ptr ();
54 glob_idx ();
55 ptr++;
56 idx = 2;
57 glob_ptr ();
58 glob_idx ();
59 exit (0);