1 /* { dg-do compile { target { i?86-*-* x86_64-*-* } } } */
2 /* { dg-options "-O2 -fno-tree-vectorize -fprefetch-loop-arrays -march=amdfam10 --param simultaneous-prefetches=100 --param min-insn-to-prefetch-ratio=6 -fdump-tree-aprefetch-details" } */
14 /* Here, we should use non-temporal prefetch instruction. */
15 for (i
= 0; i
< K
; i
++)
16 for (j
= 0; j
< K
; 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
++)
47 /* { dg-final { scan-tree-dump-times "Issued prefetch" 5 "aprefetch" } } */
48 /* { dg-final { scan-tree-dump-times "Issued nontemporal prefetch" 3 "aprefetch" } } */