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