OSDN Git Service

Add NIOS2 support. Code from SourceyG++.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / tree-ssa / prefetch-7.c
1 /* { dg-do compile { target i?86-*-* x86_64-*-* } } */
2 /* { dg-require-effective-target ilp32 } */
3 /* { dg-require-effective-target sse2 } */
4 /* { dg-skip-if "" { i?86-*-* x86_64-*-* } { "-march=*" } { "-march=athlon" } } */
5 /* { dg-options "-O2 -fprefetch-loop-arrays -march=athlon -msse2 -mfpmath=sse --param simultaneous-prefetches=100 -fdump-tree-aprefetch-details -fdump-tree-optimized" } */
6
7 #define K 1000000
8 int a[K], b[K];
9
10 void test(int *p)
11 {
12   unsigned i;
13
14   /* Nontemporal store should be used for a.  */
15   for (i = 0; i < K; i++)
16     a[i] = 0;
17
18   /* Nontemporal store should be used for a, nontemporal prefetch for b.  */
19   for (i = 0; i < K; i++)
20     a[i] = b[i];
21
22   /* Nontemporal store should not be used here (only write and read temporal
23      prefetches).  */
24   for (i = 0; i < K - 10000; i++)
25     a[i + 10000] = a[i];
26
27   /* Nontemporal store should not be used here (only write and read nontemporal
28      prefetches).  */
29   for (i = 0; i < K - 100000; i++)
30     a[i + 100000] = a[i];
31
32   /* Nontemporal store should be used neither for a nor for p, as we do not know
33      whether they alias or not.  */
34   for (i = 0; i < K; i++)
35     {
36       a[i] = 0;
37       *p++ = 1;
38     }
39
40   /* Nontemporal store should not be used for a, as we do not know whether its
41      value will be reused or not.  */
42   for (i = 0; i < 1000; i++)
43     a[i] = 0;
44 }
45
46 /* { dg-final { scan-tree-dump-times "Issued prefetch" 5 "aprefetch" } } */
47 /* { dg-final { scan-tree-dump-times "Issued nontemporal prefetch" 3 "aprefetch" } } */
48 /* { dg-final { scan-tree-dump-times "a nontemporal store" 2 "aprefetch" } } */
49
50 /* { dg-final { scan-tree-dump-times "builtin_prefetch" 8 "optimized" } } */
51 /* { dg-final { scan-tree-dump-times "=\\{nt\\}" 18 "optimized" } } */
52 /* { dg-final { scan-tree-dump-times "__builtin_ia32_mfence" 2 "optimized" } } */
53
54 /* { dg-final { scan-assembler-times "prefetchw" 5 } } */
55 /* { dg-final { scan-assembler-times "prefetcht" 1 } } */
56 /* { dg-final { scan-assembler-times "prefetchnta" 2 } } */
57 /* { dg-final { scan-assembler-times "movnti" 18 } } */
58 /* { dg-final { scan-assembler-times "mfence" 2 } } */
59
60 /* { dg-final { cleanup-tree-dump "aprefetch" } } */
61 /* { dg-final { cleanup-tree-dump "optimized" } } */