PR tree-optimization/81303
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / loop-interchange-3.c
blob98d3d2f183bbe3c862ccee3d4eb305969aafa678
1 /* { dg-do run } */
2 /* { dg-options "-O2 -floop-interchange -fdump-tree-linterchange-details" } */
4 /* Copied from graphite/interchange-6.c */
6 #define DEBUG 0
7 #if DEBUG
8 #include <stdio.h>
9 #endif
11 #define N 100
12 #define M 200
14 static int __attribute__((noinline))
15 foo (int A[N][M])
17 int i, j;
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];
24 return A[0][0] + A[N-1][M-1];
27 extern void abort ();
29 static void __attribute__((noinline))
30 init (int *arr, int i)
32 int j;
34 for (j = 0; j < M; j++)
35 arr[j] = 2;
38 int
39 main (void)
41 int A[N][M];
42 int i, j, res;
44 for (i = 0; i < N; i++)
45 init (A[i], i);
47 res = foo (A);
49 #if DEBUG
50 fprintf (stderr, "res = %d \n", res);
51 #endif
53 if (res != 8)
54 abort ();
56 return 0;
59 /* { dg-final { scan-tree-dump-times "Loop_pair<outer:., inner:.> is interchanged" 1 "linterchange"} } */