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 8struct S { 9 short a; 10 short b; 11 char c[8]; 12} s; 13 14char arr[100]; 15char *ptr = arr; 16int idx = 3; 17 18void 19arg_ptr (char *p) 20{ 21 __builtin_prefetch (p, 0, 0); 22} 23 24void 25arg_idx (char *p, int i) 26{ 27 __builtin_prefetch (&p[i], 0, 0); 28} 29 30void 31glob_ptr (void) 32{ 33 __builtin_prefetch (ptr, 0, 0); 34} 35 36void 37glob_idx (void) 38{ 39 __builtin_prefetch (&ptr[idx], 0, 0); 40} 41 42int 43main () 44{ 45 __builtin_prefetch (&s.b, 0, 0); 46 __builtin_prefetch (&s.c[1], 0, 0); 47 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); 60} 61