]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gcc.dg/tree-ssa/loop-interchange-3.c
PR tree-optimization/81303
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / loop-interchange-3.c
1 /* { dg-do run } */
2 /* { dg-options "-O2 -floop-interchange -fdump-tree-linterchange-details" } */
3
4 /* Copied from graphite/interchange-6.c */
5
6 #define DEBUG 0
7 #if DEBUG
8 #include <stdio.h>
9 #endif
10
11 #define N 100
12 #define M 200
13
14 static int __attribute__((noinline))
15 foo (int A[N][M])
16 {
17 int i, j;
18
19 /* This loop should be interchanged. */
20 for(j = 0; j < M; j++)
21 for(i = 0; i < N; i++)
22 A[i][j] = A[i][j] + A[i][j];
23
24 return A[0][0] + A[N-1][M-1];
25 }
26
27 extern void abort ();
28
29 static void __attribute__((noinline))
30 init (int *arr, int i)
31 {
32 int j;
33
34 for (j = 0; j < M; j++)
35 arr[j] = 2;
36 }
37
38 int
39 main (void)
40 {
41 int A[N][M];
42 int i, j, res;
43
44 for (i = 0; i < N; i++)
45 init (A[i], i);
46
47 res = foo (A);
48
49 #if DEBUG
50 fprintf (stderr, "res = %d \n", res);
51 #endif
52
53 if (res != 8)
54 abort ();
55
56 return 0;
57 }
58
59 /* { dg-final { scan-tree-dump-times "Loop_pair<outer:., inner:.> is interchanged" 1 "linterchange"} } */