Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / gcc.c-torture / execute / builtin-prefetch-3.c
blob2e2e808c17206cacdc6fd969ab96370465395ac1
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. */
6 int glob_int_arr[100];
7 int glob_int = 4;
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;
21 struct S {
22 int a;
23 short b, c;
24 char d[8];
25 struct S *next;
28 struct S str;
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. */
36 void
37 simple_vol_global ()
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. */
48 void
49 simple_vol_file ()
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. */
60 void
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);
103 main ()
105 simple_vol_global ();
106 simple_vol_file ();
108 str.next = &str;
109 vol_str.next = &str;
110 expr_vol_global ();
112 exit (0);