OSDN Git Service

2007-07-06 Daniel Berlin <dberlin@dberlin.org>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / tree-ssa / prefetch-5.c
1 /* { dg-do compile { target i?86-*-* x86_64-*-* } } */
2 /* { dg-require-effective-target ilp32 } */
3 /* { dg-options "-O2 -fprefetch-loop-arrays -march=athlon -fdump-tree-aprefetch-details" } */
4
5 /* These are common idioms for writing variable-length arrays at the end
6    of structures.  We should not deduce anything about the number of iterations
7    of the loops from them.  */
8
9 struct tail0
10 {
11   int xxx;
12   int yyy[0];
13 };
14
15 int loop0 (int n, struct tail0 *x)
16 {
17   int i, s = 0;
18
19   for (i = 0; i < n; i++)
20     s += x->yyy[i];
21
22   return s;
23 }
24
25 struct tail1
26 {
27   int xxx;
28   int yyy[1];
29 };
30 int loop1 (int n, struct tail1 *x)
31 {
32   int i, s = 0;
33
34   for (i = 0; i < n; i++)
35     s += x->yyy[i];
36
37   return s;
38 }
39
40 /* It is unlikely that this should be a tail array.  We may deduce that most
41    likely, the loop iterates about 5 times, and the array is not worth prefetching.  */
42
43 struct tail5
44 {
45   int xxx;
46   int yyy[5];
47 };
48 int loop5 (int n, struct tail5 *x)
49 {
50   int i, s = 0;
51
52   for (i = 0; i < n; i++)
53     s += x->yyy[i];
54
55   return s;
56 }
57
58 /* { dg-final { scan-tree-dump-times "Issued prefetch" 2 "aprefetch" } } */
59 /* { dg-final { scan-tree-dump-times "Not prefetching" 1 "aprefetch" } } */
60 /* { dg-final { cleanup-tree-dump "aprefetch" } } */