1 /* { dg-do compile { target { i?86-*-* x86_64-*-* } } } */
2 /* { dg-options "-O2 -fprefetch-loop-arrays -march=amdfam10 --param simultaneous-prefetches=100 -fdump-tree-aprefetch-details -fdump-tree-optimized" } */
3 
4 #define K 1000000
5 int a[K];
6 
test(int * p)7 void test(int *p)
8 {
9   unsigned i;
10 
11   /* Nontemporal store should not be used here (only write and read temporal
12      prefetches).  */
13   for (i = 0; i < K - 10000; i++)
14     a[i + 10000] = a[i];
15 
16   /* Nontemporal store should not be used here (only write and read nontemporal
17      prefetches).  */
18   for (i = 0; i < K - 100000; i++)
19     a[i + 100000] = a[i];
20 
21   /* Nontemporal store should be used neither for a nor for p, as we do not know
22      whether they alias or not.  */
23   for (i = 0; i < K; i++)
24     {
25       a[i] = 0;
26       *p++ = 1;
27     }
28 
29   /* Nontemporal store should not be used for a, as we do not know whether its
30      value will be reused or not.  */
31   for (i = 0; i < 1000; i++)
32     a[i] = 0;
33 }
34 
35 /* { dg-final { scan-tree-dump-times "Issued prefetch" 5 "aprefetch" } } */
36 /* { dg-final { scan-tree-dump-times "Issued nontemporal prefetch" 2 "aprefetch" } } */
37 /* { dg-final { scan-tree-dump-times "a nontemporal store" 0 "aprefetch" } } */
38 
39 /* { dg-final { scan-tree-dump-times "builtin_prefetch" 7 "optimized" } } */
40