Debian Codegraph @

gcc/testsuite/gcc.c-torture/execute/builtin-prefetch-5.c

raw
1 /* Test that __builtin_prefetch does no harm.
2
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. */
7
8 void exit (int);
9
10 struct S {
11 short a;
12 short b;
13 char c[8];
14 } s;
15
16 char arr[100];
17 char *ptr = arr;
18 int idx = 3;
19
20 void
21 arg_ptr (char *p)
22 {
23 __builtin_prefetch (p, 0, 0);
24 }
25
26 void
27 arg_idx (char *p, int i)
28 {
29 __builtin_prefetch (&p[i], 0, 0);
30 }
31
32 void
33 glob_ptr (void)
34 {
35 __builtin_prefetch (ptr, 0, 0);
36 }
37
38 void
39 glob_idx (void)
40 {
41 __builtin_prefetch (&ptr[idx], 0, 0);
42 }
43
44 int
45 main ()
46 {
47 __builtin_prefetch (&s.b, 0, 0);
48 __builtin_prefetch (&s.c[1], 0, 0);
49
50 arg_ptr (&s.c[1]);
51 arg_ptr (ptr+3);
52 arg_idx (ptr, 3);
53 arg_idx (ptr+1, 2);
54 idx = 3;
55 glob_ptr ();
56 glob_idx ();
57 ptr++;
58 idx = 2;
59 glob_ptr ();
60 glob_idx ();
61 exit (0);
62 }