1 /* Test that __builtin_prefetch does no harm.
3 Check that the expression containing the address to prefetch is
4 evaluated if it has side effects, even if the target does not support
5 data prefetch. Check changes to pointers and to array indices that are
6 either global variables or arguments. */
14 /* Check that assignment within a prefetch argument is evaluated. */
17 assign_arg_ptr (int *p
)
20 __builtin_prefetch ((q
= p
), 0, 0);
25 assign_glob_ptr (void)
28 __builtin_prefetch ((q
= ptr
), 0, 0);
33 assign_arg_idx (int *p
, int i
)
36 __builtin_prefetch (&p
[j
= i
], 0, 0);
41 assign_glob_idx (void)
44 __builtin_prefetch (&ptr
[j
= arrindex
], 0, 0);
48 /* Check that pre/post increment/decrement within a prefetch argument are
52 preinc_arg_ptr (int *p
)
56 __builtin_prefetch (++p
, 0, 0);
61 preinc_glob_ptr (void)
65 __builtin_prefetch (++ptr
, 0, 0);
70 postinc_arg_ptr (int *p
)
74 __builtin_prefetch (p
++, 0, 0);
79 postinc_glob_ptr (void)
83 __builtin_prefetch (ptr
++, 0, 0);
88 predec_arg_ptr (int *p
)
92 __builtin_prefetch (--p
, 0, 0);
97 predec_glob_ptr (void)
101 __builtin_prefetch (--ptr
, 0, 0);
106 postdec_arg_ptr (int *p
)
110 __builtin_prefetch (p
--, 0, 0);
115 postdec_glob_ptr (void)
119 __builtin_prefetch (ptr
--, 0, 0);
124 preinc_arg_idx (int *p
, int i
)
127 __builtin_prefetch (&p
[++i
], 0, 0);
133 preinc_glob_idx (void)
135 int j
= arrindex
+ 1;
136 __builtin_prefetch (&ptr
[++arrindex
], 0, 0);
137 return arrindex
== j
;
141 postinc_arg_idx (int *p
, int i
)
144 __builtin_prefetch (&p
[i
++], 0, 0);
149 postinc_glob_idx (void)
151 int j
= arrindex
+ 1;
152 __builtin_prefetch (&ptr
[arrindex
++], 0, 0);
153 return arrindex
== j
;
157 predec_arg_idx (int *p
, int i
)
160 __builtin_prefetch (&p
[--i
], 0, 0);
165 predec_glob_idx (void)
167 int j
= arrindex
- 1;
168 __builtin_prefetch (&ptr
[--arrindex
], 0, 0);
169 return arrindex
== j
;
173 postdec_arg_idx (int *p
, int i
)
176 __builtin_prefetch (&p
[i
--], 0, 0);
181 postdec_glob_idx (void)
183 int j
= arrindex
- 1;
184 __builtin_prefetch (&ptr
[arrindex
--], 0, 0);
185 return arrindex
== j
;
188 /* Check that function calls within the first prefetch argument are
201 funccall_arg_ptr (int *p
)
203 __builtin_prefetch (getptr (p
), 0, 0);
204 return getptrcnt
== 1;
217 funccall_arg_idx (int *p
, int i
)
219 __builtin_prefetch (&p
[getint (i
)], 0, 0);
220 return getintcnt
== 1;
226 if (!assign_arg_ptr (ptr
))
228 if (!assign_glob_ptr ())
230 if (!assign_arg_idx (ptr
, 4))
232 if (!assign_glob_idx ())
234 if (!preinc_arg_ptr (ptr
))
236 if (!preinc_glob_ptr ())
238 if (!postinc_arg_ptr (ptr
))
240 if (!postinc_glob_ptr ())
242 if (!predec_arg_ptr (ptr
))
244 if (!predec_glob_ptr ())
246 if (!postdec_arg_ptr (ptr
))
248 if (!postdec_glob_ptr ())
250 if (!preinc_arg_idx (ptr
, 3))
252 if (!preinc_glob_idx ())
254 if (!postinc_arg_idx (ptr
, 3))
256 if (!postinc_glob_idx ())
258 if (!predec_arg_idx (ptr
, 3))
260 if (!predec_glob_idx ())
262 if (!postdec_arg_idx (ptr
, 3))
264 if (!postdec_glob_idx ())
266 if (!funccall_arg_ptr (ptr
))
268 if (!funccall_arg_idx (ptr
, 3))