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