1 /* Test that __builtin_prefetch does no harm.
3 Prefetch using all valid combinations of rw and locality values.
4 These must be compile-time constants. */
6 #define NO_TEMPORAL_LOCALITY 0
7 #define LOW_TEMPORAL_LOCALITY 1
8 #define MODERATE_TEMPORAL_LOCALITY 1
9 #define HIGH_TEMPORAL_LOCALITY 3
11 #define WRITE_ACCESS 1
14 enum locality
{ none
, low
, moderate
, high
};
15 enum rw
{ read
, write
};
20 good_const (const int *p
)
22 __builtin_prefetch (p
, 0, 0);
23 __builtin_prefetch (p
, 0, 1);
24 __builtin_prefetch (p
, 0, 2);
25 __builtin_prefetch (p
, READ_ACCESS
, 3);
26 __builtin_prefetch (p
, 1, NO_TEMPORAL_LOCALITY
);
27 __builtin_prefetch (p
, 1, LOW_TEMPORAL_LOCALITY
);
28 __builtin_prefetch (p
, 1, MODERATE_TEMPORAL_LOCALITY
);
29 __builtin_prefetch (p
, WRITE_ACCESS
, HIGH_TEMPORAL_LOCALITY
);
33 good_enum (const int *p
)
35 __builtin_prefetch (p
, read
, none
);
36 __builtin_prefetch (p
, read
, low
);
37 __builtin_prefetch (p
, read
, moderate
);
38 __builtin_prefetch (p
, read
, high
);
39 __builtin_prefetch (p
, write
, none
);
40 __builtin_prefetch (p
, write
, low
);
41 __builtin_prefetch (p
, write
, moderate
);
42 __builtin_prefetch (p
, write
, high
);
46 good_expr (const int *p
)
48 __builtin_prefetch (p
, 1 - 1, 6 - (2 * 3));
49 __builtin_prefetch (p
, 1 + 0, 1 + 2);
53 good_vararg (const int *p
)
55 __builtin_prefetch (p
, 0, 3);
56 __builtin_prefetch (p
, 0);
57 __builtin_prefetch (p
, 1);
58 __builtin_prefetch (p
);