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