OSDN Git Service

* gcc.dg/format/asm_fprintf-1.c: New test.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / builtin-prefetch-1.c
1 /* Test that __builtin_prefetch does no harm.
2
3    Prefetch using some invalid rw and locality values.  These must be
4    compile-time constants.  */
5
6 /* { dg-do run } */
7
8 enum locality { none, low, moderate, high, bogus };
9 enum rw { read, write };
10
11 int arr[10];
12
13 void
14 good (int *p)
15 {
16   __builtin_prefetch (p, 0, 0);
17   __builtin_prefetch (p, 0, 1);
18   __builtin_prefetch (p, 0, 2);
19   __builtin_prefetch (p, 0, 3);
20   __builtin_prefetch (p, 1, 0);
21   __builtin_prefetch (p, 1, 1);
22   __builtin_prefetch (p, 1, 2);
23   __builtin_prefetch (p, 1, 3);
24 }
25
26 void
27 bad (int *p)
28 {
29   __builtin_prefetch (p, -1, 0);  /* { dg-warning "invalid second arg to __builtin_prefetch; using zero" } */
30   __builtin_prefetch (p, 2, 0);   /* { dg-warning "invalid second arg to __builtin_prefetch; using zero" } */
31   __builtin_prefetch (p, bogus, 0);   /* { dg-warning "invalid second arg to __builtin_prefetch; using zero" } */
32   __builtin_prefetch (p, 0, -1);  /* { dg-warning "invalid third arg to __builtin_prefetch; using zero" } */
33   __builtin_prefetch (p, 0, 4);   /* { dg-warning "invalid third arg to __builtin_prefetch; using zero" } */
34   __builtin_prefetch (p, 0, bogus);   /* { dg-warning "invalid third arg to __builtin_prefetch; using zero" } */
35 }
36
37 int
38 main ()
39 {
40   good (arr);
41   bad (arr);
42   exit (0);
43 }