blob: b5fda2d5097f7f4624bee03bf1c86ada9e915318 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/* { dg-do run } */
/* { dg-options "-O2 -floop-interchange -fdump-tree-linterchange-details" } */
/* { dg-require-effective-target size20plus } */
/* { dg-skip-if "too big data segment" { visium-*-* } } */
#define M 256
int a[M][M], b[M][M], c[M], d[M];
void __attribute__((noinline))
simple_reduc_1 (int n)
{
for (int j = 0; j < n; j++)
{
int sum = c[j];
for (int i = 0; i < n; i++)
sum = sum + a[i][j]*b[i][j];
c[j] = sum;
}
}
void __attribute__((noinline))
simple_reduc_2 (int n)
{
for (int j = 0; j < n; j++)
{
int sum = d[j];
for (int i = 0; i < n; i++)
sum = sum + a[i][j]*b[i][j];
asm volatile ("" ::: "memory");
d[j] = sum;
}
}
extern void abort ();
static void __attribute__((noinline))
init (int i)
{
c[i] = 0;
d[i] = 0;
for (int j = 0; j < M; j++)
{
a[i][j] = i;
b[i][j] = j;
}
}
int main (void)
{
for (int i = 0; i < M; ++i)
init (i);
simple_reduc_1 (M);
simple_reduc_2 (M);
for (int i = 0; i < M; ++i)
if (c[i] != d[i])
abort ();
return 0;
}
/* { dg-final { scan-tree-dump-times "Loop_pair<outer:., inner:.> is interchanged" 1 "linterchange" } } */
|