1 /* Test that __builtin_prefetch does no harm.
3 Prefetch data using a variety of storage classes and address
4 expressions with volatile variables and pointers. */
8 volatile int glob_vol_int_arr
[100];
9 int * volatile glob_vol_ptr_int
= glob_int_arr
;
10 volatile int *glob_ptr_vol_int
= glob_vol_int_arr
;
11 volatile int * volatile glob_vol_ptr_vol_int
= glob_vol_int_arr
;
12 volatile int glob_vol_int
;
14 static stat_int_arr
[100];
15 static volatile int stat_vol_int_arr
[100];
16 static int * volatile stat_vol_ptr_int
= stat_int_arr
;
17 static volatile int *stat_ptr_vol_int
= stat_vol_int_arr
;
18 static volatile int * volatile stat_vol_ptr_vol_int
= stat_vol_int_arr
;
19 static volatile int stat_vol_int
;
29 volatile struct S vol_str
;
30 struct S
* volatile vol_ptr_str
= &str
;
31 volatile struct S
*ptr_vol_str
= &vol_str
;
32 volatile struct S
* volatile vol_ptr_vol_str
= &vol_str
;
34 /* Prefetch volatile global variables using the address of the variable. */
39 __builtin_prefetch (glob_vol_int_arr
, 0, 0);
40 __builtin_prefetch (glob_vol_ptr_int
, 0, 0);
41 __builtin_prefetch (glob_ptr_vol_int
, 0, 0);
42 __builtin_prefetch (glob_vol_ptr_vol_int
, 0, 0);
43 __builtin_prefetch (&glob_vol_int
, 0, 0);
46 /* Prefetch volatile static variables using the address of the variable. */
51 __builtin_prefetch (stat_vol_int_arr
, 0, 0);
52 __builtin_prefetch (stat_vol_ptr_int
, 0, 0);
53 __builtin_prefetch (stat_ptr_vol_int
, 0, 0);
54 __builtin_prefetch (stat_vol_ptr_vol_int
, 0, 0);
55 __builtin_prefetch (&stat_vol_int
, 0, 0);
58 /* Prefetch using address expressions involving volatile global variables. */
61 expr_vol_global (void)
63 __builtin_prefetch (&vol_str
, 0, 0);
64 __builtin_prefetch (ptr_vol_str
, 0, 0);
65 __builtin_prefetch (vol_ptr_str
, 0, 0);
66 __builtin_prefetch (vol_ptr_vol_str
, 0, 0);
67 __builtin_prefetch (&vol_str
.b
, 0, 0);
68 __builtin_prefetch (&ptr_vol_str
->b
, 0, 0);
69 __builtin_prefetch (&vol_ptr_str
->b
, 0, 0);
70 __builtin_prefetch (&vol_ptr_vol_str
->b
, 0, 0);
71 __builtin_prefetch (&vol_str
.d
, 0, 0);
72 __builtin_prefetch (&vol_ptr_str
->d
, 0, 0);
73 __builtin_prefetch (&ptr_vol_str
->d
, 0, 0);
74 __builtin_prefetch (&vol_ptr_vol_str
->d
, 0, 0);
75 __builtin_prefetch (vol_str
.next
, 0, 0);
76 __builtin_prefetch (vol_ptr_str
->next
, 0, 0);
77 __builtin_prefetch (ptr_vol_str
->next
, 0, 0);
78 __builtin_prefetch (vol_ptr_vol_str
->next
, 0, 0);
79 __builtin_prefetch (vol_str
.next
->d
, 0, 0);
80 __builtin_prefetch (vol_ptr_str
->next
->d
, 0, 0);
81 __builtin_prefetch (ptr_vol_str
->next
->d
, 0, 0);
82 __builtin_prefetch (vol_ptr_vol_str
->next
->d
, 0, 0);
84 __builtin_prefetch (&glob_vol_int_arr
, 0, 0);
85 __builtin_prefetch (glob_vol_ptr_int
, 0, 0);
86 __builtin_prefetch (glob_ptr_vol_int
, 0, 0);
87 __builtin_prefetch (glob_vol_ptr_vol_int
, 0, 0);
88 __builtin_prefetch (&glob_vol_int_arr
[2], 0, 0);
89 __builtin_prefetch (&glob_vol_ptr_int
[3], 0, 0);
90 __builtin_prefetch (&glob_ptr_vol_int
[3], 0, 0);
91 __builtin_prefetch (&glob_vol_ptr_vol_int
[3], 0, 0);
92 __builtin_prefetch (glob_vol_int_arr
+3, 0, 0);
93 __builtin_prefetch (glob_vol_int_arr
+glob_vol_int
, 0, 0);
94 __builtin_prefetch (glob_vol_ptr_int
+5, 0, 0);
95 __builtin_prefetch (glob_ptr_vol_int
+5, 0, 0);
96 __builtin_prefetch (glob_vol_ptr_vol_int
+5, 0, 0);
97 __builtin_prefetch (glob_vol_ptr_int
+glob_vol_int
, 0, 0);
98 __builtin_prefetch (glob_ptr_vol_int
+glob_vol_int
, 0, 0);
99 __builtin_prefetch (glob_vol_ptr_vol_int
+glob_vol_int
, 0, 0);
105 simple_vol_global ();