* tree-loop-distribution.c (INCLUDE_ALGORITHM): New header file.
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / prefetch-6.c
blob12f09016943b93ceb04540ae5a31fba765ecf444
1 /* { dg-do compile { target { i?86-*-* x86_64-*-* } } } */
2 /* { dg-options "-O2 -fprefetch-loop-arrays -march=amdfam10 --param simultaneous-prefetches=100 --param min-insn-to-prefetch-ratio=6 -fdump-tree-aprefetch-details" } */
4 #define N 1000
5 #define K 900
7 double a[N][N];
9 double test(void)
11 unsigned i, j;
12 double sum = 0;
14 /* Here, we should use non-temporal prefetch instruction. */
15 for (i = 0; i < K; i++)
16 for (j = 0; j < K; j++)
17 sum += a[i][j];
19 /* Here, we should not use non-temporal prefetch instruction, since the
20 value of a[i+10][j] is reused in L2 cache. */
21 for (i = 0; i < K; i++)
22 for (j = 0; j < K; j++)
23 sum += a[i][j] * a[i + 10][j];
25 /* Here, we should use non-temporal prefetch instruction, since the
26 value of a[i+100][j] is too far to be reused in L2 cache. */
27 for (i = 0; i < K; i++)
28 for (j = 0; j < K; j++)
29 sum += a[i][j] * a[i + 100][j];
31 /* Here, temporal prefetches should be used, since the volume of the
32 memory accesses is smaller than L2 cache. */
33 for (i = 0; i < 100; i++)
34 for (j = 0; j < 100; j++)
35 sum += a[i][j] * a[i + 100][j];
37 /* Temporal prefetches should be used here (even though the accesses to
38 a[j][i] are independent, the same cache line is almost always hit
39 every N iterations). */
40 for (i = 0; i < N; i++)
41 for (j = 0; j < N; j++)
42 sum += a[j][i];
44 return sum;
47 /* { dg-final { scan-tree-dump-times "Issued prefetch" 5 "aprefetch" } } */
48 /* { dg-final { scan-tree-dump-times "Issued nontemporal prefetch" 3 "aprefetch" } } */