From d0546b2ebab8372d1135f774b27912313efbed4b Mon Sep 17 00:00:00 2001 From: spop Date: Sat, 6 Feb 2010 17:41:28 +0000 Subject: [PATCH] Add runtime tests for interchange and blocking. 2010-02-03 Sebastian Pop * testsuite/g++.dg/graphite/graphite.exp: Rewritten. * testsuite/gcc.dg/graphite/graphite.exp: Rewritten. * testsuite/gfortran.dg/graphite/graphite.exp: Rewritten. * gcc/testsuite/gcc.dg/graphite/block-0.c: Added runtime test. * testsuite/gcc.dg/graphite/block-1.c: Same. * testsuite/gcc.dg/graphite/block-3.c: Same. * testsuite/gcc.dg/graphite/block-4.c: Same. * testsuite/gcc.dg/graphite/block-5.c: Same. * testsuite/gcc.dg/graphite/block-6.c: Same. * testsuite/gcc.dg/graphite/block-7.c: Same. * testsuite/gcc.dg/graphite/interchange-0.c: Same. * testsuite/gcc.dg/graphite/interchange-1.c: Same. * testsuite/gcc.dg/graphite/interchange-10.c: Same. * testsuite/gcc.dg/graphite/interchange-11.c: Same. * testsuite/gcc.dg/graphite/interchange-12.c: Same. * testsuite/gcc.dg/graphite/interchange-2.c: Same. * testsuite/gcc.dg/graphite/interchange-3.c: Same. * testsuite/gcc.dg/graphite/interchange-4.c: Same. * testsuite/gcc.dg/graphite/interchange-5.c: Same. * testsuite/gcc.dg/graphite/interchange-6.c: Same. * testsuite/gcc.dg/graphite/interchange-7.c: Same. * testsuite/gcc.dg/graphite/interchange-8.c: Same. * testsuite/gcc.dg/graphite/interchange-9.c: Same. * testsuite/gcc.dg/graphite/interchange-mvt.c: Same. * testsuite/gcc.dg/graphite/run-id-2.c: Remove useless dg-do run. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156548 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog.graphite | 28 ++++++++++++ gcc/testsuite/g++.dg/graphite/graphite.exp | 58 ++++++++---------------- gcc/testsuite/gcc.dg/graphite/block-0.c | 24 ++++++++-- gcc/testsuite/gcc.dg/graphite/block-1.c | 17 ++++--- gcc/testsuite/gcc.dg/graphite/block-3.c | 33 +++++++++++++- gcc/testsuite/gcc.dg/graphite/block-4.c | 39 +++++++++++++--- gcc/testsuite/gcc.dg/graphite/block-5.c | 48 +++++++++++++++----- gcc/testsuite/gcc.dg/graphite/block-6.c | 47 +++++++++++++++----- gcc/testsuite/gcc.dg/graphite/block-7.c | 38 ++++++++++++++-- gcc/testsuite/gcc.dg/graphite/graphite.exp | 58 ++++++++---------------- gcc/testsuite/gcc.dg/graphite/interchange-0.c | 38 +++++++++++++--- gcc/testsuite/gcc.dg/graphite/interchange-1.c | 30 ++++++++++++- gcc/testsuite/gcc.dg/graphite/interchange-10.c | 30 ++++++++++++- gcc/testsuite/gcc.dg/graphite/interchange-11.c | 28 +++++++++++- gcc/testsuite/gcc.dg/graphite/interchange-12.c | 38 ++++++++++++++-- gcc/testsuite/gcc.dg/graphite/interchange-2.c | 31 +++++++++++-- gcc/testsuite/gcc.dg/graphite/interchange-3.c | 39 +++++++++++++--- gcc/testsuite/gcc.dg/graphite/interchange-4.c | 29 +++++++++++- gcc/testsuite/gcc.dg/graphite/interchange-5.c | 39 +++++++++++++--- gcc/testsuite/gcc.dg/graphite/interchange-6.c | 39 +++++++++++++--- gcc/testsuite/gcc.dg/graphite/interchange-7.c | 38 +++++++++++++--- gcc/testsuite/gcc.dg/graphite/interchange-8.c | 43 ++++++++++++++++-- gcc/testsuite/gcc.dg/graphite/interchange-9.c | 36 +++++++++++++-- gcc/testsuite/gcc.dg/graphite/interchange-mvt.c | 59 +++++++++++++++++++------ gcc/testsuite/gcc.dg/graphite/run-id-2.c | 5 +-- gcc/testsuite/gfortran.dg/graphite/graphite.exp | 56 ++++++++--------------- 26 files changed, 739 insertions(+), 229 deletions(-) diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite index 83b8b1c..fe9962c 100644 --- a/gcc/ChangeLog.graphite +++ b/gcc/ChangeLog.graphite @@ -1,3 +1,31 @@ +2010-02-03 Sebastian Pop + + * testsuite/g++.dg/graphite/graphite.exp: Rewritten. + * testsuite/gcc.dg/graphite/graphite.exp: Rewritten. + * testsuite/gfortran.dg/graphite/graphite.exp: Rewritten. + * gcc/testsuite/gcc.dg/graphite/block-0.c: Added runtime test. + * testsuite/gcc.dg/graphite/block-1.c: Same. + * testsuite/gcc.dg/graphite/block-3.c: Same. + * testsuite/gcc.dg/graphite/block-4.c: Same. + * testsuite/gcc.dg/graphite/block-5.c: Same. + * testsuite/gcc.dg/graphite/block-6.c: Same. + * testsuite/gcc.dg/graphite/block-7.c: Same. + * testsuite/gcc.dg/graphite/interchange-0.c: Same. + * testsuite/gcc.dg/graphite/interchange-1.c: Same. + * testsuite/gcc.dg/graphite/interchange-10.c: Same. + * testsuite/gcc.dg/graphite/interchange-11.c: Same. + * testsuite/gcc.dg/graphite/interchange-12.c: Same. + * testsuite/gcc.dg/graphite/interchange-2.c: Same. + * testsuite/gcc.dg/graphite/interchange-3.c: Same. + * testsuite/gcc.dg/graphite/interchange-4.c: Same. + * testsuite/gcc.dg/graphite/interchange-5.c: Same. + * testsuite/gcc.dg/graphite/interchange-6.c: Same. + * testsuite/gcc.dg/graphite/interchange-7.c: Same. + * testsuite/gcc.dg/graphite/interchange-8.c: Same. + * testsuite/gcc.dg/graphite/interchange-9.c: Same. + * testsuite/gcc.dg/graphite/interchange-mvt.c: Same. + * testsuite/gcc.dg/graphite/run-id-2.c: Remove useless dg-do run. + 2010-01-22 Ramakrishna Upadrasta * graphite-scop-detection.c (dot_all_scops): Make calls to dot run in diff --git a/gcc/testsuite/g++.dg/graphite/graphite.exp b/gcc/testsuite/g++.dg/graphite/graphite.exp index ba7c8cc..f46dcc7 100644 --- a/gcc/testsuite/g++.dg/graphite/graphite.exp +++ b/gcc/testsuite/g++.dg/graphite/graphite.exp @@ -33,58 +33,36 @@ proc lremove {list_variable value} { # The default action for a test is 'compile'. Save current default. global dg-do-what-default set save-dg-do-what-default ${dg-do-what-default} -set dg-do-what-default compile # Initialize `dg'. dg-init -# Main loop. - set wait_to_run_files [lsort [glob -nocomplain $srcdir/$subdir/*.C ] ] - -# Flags using for block-* files. -set DEFAULT_FLAGS_GRAPHITE_BLOCK "-O2 -floop-block -fno-loop-strip-mine \ - -fno-loop-interchange -fdump-tree-graphite-all" -set block_files [lsort [glob -nocomplain $srcdir/$subdir/block-*.C ] ] -dg-runtest $block_files "" $DEFAULT_FLAGS_GRAPHITE_BLOCK -foreach block_file $block_files {lremove wait_to_run_files $block_file} - -# Flags using for id-* files. -set DEFAULT_FLAGS_GRAPHITE_IDENTITY "-O2 -fgraphite-identity" -set id_files [lsort [glob -nocomplain $srcdir/$subdir/id-*.C ] ] -dg-runtest $id_files "" $DEFAULT_FLAGS_GRAPHITE_IDENTITY -foreach id_file $id_files {lremove wait_to_run_files $id_file} - -# Flags using for interchange-* files. -set DEFAULT_FLAGS_GRAPHITE_INTERCHANGE "-O2 -fdump-tree-graphite-all \ - -floop-interchange -fno-loop-block -fno-loop-strip-mine -ffast-math" +set scop_files [lsort [glob -nocomplain $srcdir/$subdir/scop-*.C ] ] +set id_files [lsort [glob -nocomplain $srcdir/$subdir/id-*.C ] ] +set run_id_files [lsort [glob -nocomplain $srcdir/$subdir/run-id-*.C ] ] set interchange_files [lsort [glob -nocomplain $srcdir/$subdir/interchange-*.C ] ] -dg-runtest $interchange_files "" $DEFAULT_FLAGS_GRAPHITE_INTERCHANGE -foreach interchange_file $interchange_files {lremove wait_to_run_files $interchange_file} - -# Flags using for scop-* files. -set DEFAULT_FLAGS_GRAPHITE_SCOP "-O2 -fgraphite -fdump-tree-graphite-all" -set scop_files [lsort [glob -nocomplain $srcdir/$subdir/scop-*.C ] ] -dg-runtest $scop_files "" $DEFAULT_FLAGS_GRAPHITE_SCOP -foreach scop_file $scop_files {lremove wait_to_run_files $scop_file} +set block_files [lsort [glob -nocomplain $srcdir/$subdir/block-*.C ] ] +# Tests to be compiled. +set dg-do-what-default compile +dg-runtest $scop_files "" "-O2 -fgraphite -fdump-tree-graphite-all" +dg-runtest $id_files "" "-O2 -fgraphite-identity -ffast-math" -# Schedule now the tests to be run. +# Tests to be run. set dg-do-what-default run - -# Flags using for run-id-* files. -set DEFAULT_FLAGS_RUN_ID "-O2 -fgraphite-identity" -set run_id_files [lsort [glob -nocomplain $srcdir/$subdir/run-id-*.C ] ] -dg-runtest $run_id_files "" $DEFAULT_FLAGS_RUN_ID -foreach run_id_file $run_id_files {lremove wait_to_run_files $run_id_file} - +dg-runtest $run_id_files "" "-O2 -fgraphite-identity" +dg-runtest $interchange_files "" "-O2 -floop-interchange -fno-loop-block -fno-loop-strip-mine -ffast-math -fdump-tree-graphite-all" +dg-runtest $block_files "" "-O2 -floop-block -fno-loop-strip-mine -fno-loop-interchange -ffast-math -fdump-tree-graphite-all" # The default action for the rest of the files is 'compile'. set dg-do-what-default compile - -# Flags using for other files. -set DEFAULT_FLAGS_GRAPHITE "-ansi -pedantic-errors" -dg-runtest $wait_to_run_files "" $DEFAULT_FLAGS_GRAPHITE +foreach f $scop_files {lremove wait_to_run_files $f} +foreach f $id_files {lremove wait_to_run_files $f} +foreach f $run_id_files {lremove wait_to_run_files $f} +foreach f $interchange_files {lremove wait_to_run_files $f} +foreach f $block_files {lremove wait_to_run_files $f} +dg-runtest $wait_to_run_files "" "-ansi -pedantic-errors" # Clean up. set dg-do-what-default ${save-dg-do-what-default} diff --git a/gcc/testsuite/gcc.dg/graphite/block-0.c b/gcc/testsuite/gcc.dg/graphite/block-0.c index a00694c..112b889 100644 --- a/gcc/testsuite/gcc.dg/graphite/block-0.c +++ b/gcc/testsuite/gcc.dg/graphite/block-0.c @@ -1,11 +1,16 @@ +#define DEBUG 0 +#if DEBUG +#include +#endif + #define N 1000 +int a[N]; -int toto() +static int __attribute__((noinline)) +foo (void) { int j; int i; - int a[N]; - int b[N]; for (i = 0; i < N; i++) for (j = 0; j < N; j++) @@ -16,7 +21,18 @@ int toto() main() { - return toto(); + int i, res; + + for (i = 0; i < N; i++) + a[i] = i; + + res = foo (); + +#if DEBUG + fprintf (stderr, "res = %d \n", res); +#endif + + return res != 1999; } /* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/block-1.c b/gcc/testsuite/gcc.dg/graphite/block-1.c index 35c5c6a..64ff67b 100644 --- a/gcc/testsuite/gcc.dg/graphite/block-1.c +++ b/gcc/testsuite/gcc.dg/graphite/block-1.c @@ -1,8 +1,11 @@ /* { dg-require-effective-target size32plus } */ -#define MAX 8192 +#define DEBUG 0 +#if DEBUG +#include +#endif -void bar (void); +#define MAX 100 int main() { @@ -11,8 +14,6 @@ int main() int A[MAX * MAX]; int B[MAX * MAX]; - bar (); - for (i = 0; i < MAX; i++) for (j = 0; j < MAX; j++) { @@ -24,13 +25,15 @@ int main() for (j = 0; j < MAX; j++) A[i*MAX + j] += B[j*MAX + i]; - bar (); - for(i = 0; i < MAX; i++) for(j = 0; j < MAX; j++) sum += A[i*MAX + j]; - return sum; +#if DEBUG + fprintf (stderr, "sum = %d \n", sum); +#endif + + return sum != 990000; } /* { dg-final { scan-tree-dump-times "will be loop blocked" 2 "graphite" { xfail *-*-* } } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/block-3.c b/gcc/testsuite/gcc.dg/graphite/block-3.c index 7535616..01e1863 100644 --- a/gcc/testsuite/gcc.dg/graphite/block-3.c +++ b/gcc/testsuite/gcc.dg/graphite/block-3.c @@ -1,11 +1,17 @@ /* { dg-require-effective-target size32plus } */ +#define DEBUG 0 +#if DEBUG +#include +#endif + #define N 24 #define M 100 -float A[M][M][M], B[M][M], C[M][M]; +int A[M][M][M], B[M][M], C[M][M]; -void test (void) +static int __attribute__((noinline)) +foo (void) { int i, j, k; @@ -20,6 +26,29 @@ void test (void) for (j = 0; j < M; j++) for (k = 0; k < M; k++) A[i][j][k] = B[i][k] * C[k][j]; + + return A[0][0][0] + A[M-1][M-1][M-1]; +} + +int +main (void) +{ + int i, j, res; + + for (i = 0; i < M; i++) + for (j = 0; j < M; j++) + { + B[i][j] = i; + C[i][j] = j; + } + + res = foo (); + +#if DEBUG + fprintf (stderr, "res = %d \n", res); +#endif + + return res != 9801; } /* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/block-4.c b/gcc/testsuite/gcc.dg/graphite/block-4.c index d752a4d..3019f79 100644 --- a/gcc/testsuite/gcc.dg/graphite/block-4.c +++ b/gcc/testsuite/gcc.dg/graphite/block-4.c @@ -1,11 +1,17 @@ /* { dg-require-effective-target size32plus } */ +#define DEBUG 0 +#if DEBUG +#include +#endif + #define N 24 #define M 1000 -float A[1000][1000], B[1000][1000], C[1000][1000]; +int A[M][M], B[M][M], C[M][M]; -void test (void) +static int __attribute__((noinline)) +foo (void) { int i, j, k; @@ -14,10 +20,33 @@ void test (void) for (k = 0; k < 24; k++) A[i][j] = B[i][k] * C[k][j]; - for (i = 0; i < 1000; i++) - for (j = 0; j < 1000; j++) - for (k = 0; k < 1000; k++) + for (i = 0; i < M; i++) + for (j = 0; j < M; j++) + for (k = 0; k < M; k++) A[i][j] = B[i][k] * C[k][j]; + + return A[0][0] + A[M-1][M-1]; +} + +int +main (void) +{ + int i, j, res; + + for (i = 0; i < M; i++) + for (j = 0; j < M; j++) + { + B[i][j] = i; + C[i][j] = j; + } + + res = foo (); + +#if DEBUG + fprintf (stderr, "res = %d \n", res); +#endif + + return res != 998001; } /* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/block-5.c b/gcc/testsuite/gcc.dg/graphite/block-5.c index a8f3817..4b99900 100644 --- a/gcc/testsuite/gcc.dg/graphite/block-5.c +++ b/gcc/testsuite/gcc.dg/graphite/block-5.c @@ -1,16 +1,20 @@ /* { dg-require-effective-target size32plus } */ -#define N 10000 -void foo (int); -int test () -{ - int a[N][N]; - int b[N][N]; - unsigned i, j; +#define DEBUG 0 +#if DEBUG +#include +#endif - for (i = 0; i < N; i++) - for (j = 0; j < N; j++) - a[i][j] = i*j; +#define N 200 + +int a[N][N]; +int b[N][N]; + +static int __attribute__((noinline)) +foo (void) +{ + int i, j; + int res = 0; /* This loop nest should be blocked. */ for (j = 1; j < N; j++) @@ -18,8 +22,30 @@ int test () a[i][j] = a[i][j-1] + b[i][j]; for (i = 0; i < N; i++) + res += a[i][i]; + + return res; +} + +int +main (void) +{ + int i, j, res; + + for (i = 0; i < N; i++) for (j = 0; j < N; j++) - foo (a[i][j]); + { + a[i][j] = i + j; + b[i][j] = i - j; + } + + res = foo (); + +#if DEBUG + fprintf (stderr, "res = %d \n", res); +#endif + + return res != 1333300; } /* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/block-6.c b/gcc/testsuite/gcc.dg/graphite/block-6.c index 6905e36..171b1df 100644 --- a/gcc/testsuite/gcc.dg/graphite/block-6.c +++ b/gcc/testsuite/gcc.dg/graphite/block-6.c @@ -1,25 +1,48 @@ /* { dg-require-effective-target size32plus } */ -#define N 10000 -void foo (int); -int test () -{ - int a[N][N]; - unsigned i, j; +#define DEBUG 0 +#if DEBUG +#include +#endif - for (i = 0; i < N; i++) - for (j = 0; j < N; j++) - a[i][j] = i*j; +#define N 200 +int a[N][N]; + +static int __attribute__((noinline)) +foo (void) +{ + int i, j; + int res = 0; /* Interchange is not legal for loops 0 and 1. */ for (i = 1; i < N; i++) - for (j = 1; j < (N-1) ; j++) - a[i][j] = a[i-1][j+1] * a[i-1][j+1]/2; + for (j = 1; j < N - 1; j++) + a[i][j] = a[i-1][j+1] * a[i-1][j+1] / 2; + + for (i = 0; i < N; i++) + res += a[i][i]; + + return res; +} + +int +main (void) +{ + int i, j, res; for (i = 0; i < N; i++) for (j = 0; j < N; j++) - foo (a[i][j]); + a[i][j] = i + j; + + res = foo (); + +#if DEBUG + fprintf (stderr, "res = %d \n", res); +#endif + + return res != 204007516; } + /* { dg-final { scan-tree-dump-times "will be loop blocked" 0 "graphite" } } */ /* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/block-7.c b/gcc/testsuite/gcc.dg/graphite/block-7.c index 994a55a..3e8ff92 100644 --- a/gcc/testsuite/gcc.dg/graphite/block-7.c +++ b/gcc/testsuite/gcc.dg/graphite/block-7.c @@ -1,8 +1,16 @@ -#define N 1000 +/* { dg-require-effective-target size32plus } */ -float A[N][N], B[N][N], C[N][N]; +#define DEBUG 0 +#if DEBUG +#include +#endif -void matmult () +#define N 200 + +int A[N][N], B[N][N], C[N][N]; + +static void __attribute__((noinline)) +matmult (void) { int i, j, k; @@ -15,5 +23,29 @@ void matmult () } } +int +main (void) +{ + int i, j, res = 0; + + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + { + B[i][j] = j; + C[i][j] = i; + } + + matmult (); + + for (i = 0; i < N; i++) + res += A[i][i]; + +#if DEBUG + fprintf (stderr, "res = %d \n", res); +#endif + + return res != 529340000; +} + /* { dg-final { scan-tree-dump-times "SCoP will be loop blocked" 1 "graphite" } } */ /* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/graphite.exp b/gcc/testsuite/gcc.dg/graphite/graphite.exp index c4a8b2e..411e041 100644 --- a/gcc/testsuite/gcc.dg/graphite/graphite.exp +++ b/gcc/testsuite/gcc.dg/graphite/graphite.exp @@ -33,58 +33,36 @@ proc lremove {list_variable value} { # The default action for a test is 'compile'. Save current default. global dg-do-what-default set save-dg-do-what-default ${dg-do-what-default} -set dg-do-what-default compile # Initialize `dg'. dg-init -# Main loop. - set wait_to_run_files [lsort [glob -nocomplain $srcdir/$subdir/*.c ] ] - -# Flags using for block-* files. -set DEFAULT_FLAGS_GRAPHITE_BLOCK "-O2 -floop-block -fno-loop-strip-mine \ - -fno-loop-interchange -fdump-tree-graphite-all" -set block_files [lsort [glob -nocomplain $srcdir/$subdir/block-*.c ] ] -dg-runtest $block_files "" $DEFAULT_FLAGS_GRAPHITE_BLOCK -foreach block_file $block_files {lremove wait_to_run_files $block_file} - -# Flags using for id-* files. -set DEFAULT_FLAGS_GRAPHITE_IDENTITY "-O2 -fgraphite-identity" -set id_files [lsort [glob -nocomplain $srcdir/$subdir/id-*.c ] ] -dg-runtest $id_files "" $DEFAULT_FLAGS_GRAPHITE_IDENTITY -foreach id_file $id_files {lremove wait_to_run_files $id_file} - -# Flags using for interchange-* files. -set DEFAULT_FLAGS_GRAPHITE_INTERCHANGE "-O2 -fdump-tree-graphite-all \ - -floop-interchange -fno-loop-block -fno-loop-strip-mine -ffast-math" +set scop_files [lsort [glob -nocomplain $srcdir/$subdir/scop-*.c ] ] +set id_files [lsort [glob -nocomplain $srcdir/$subdir/id-*.c ] ] +set run_id_files [lsort [glob -nocomplain $srcdir/$subdir/run-id-*.c ] ] set interchange_files [lsort [glob -nocomplain $srcdir/$subdir/interchange-*.c ] ] -dg-runtest $interchange_files "" $DEFAULT_FLAGS_GRAPHITE_INTERCHANGE -foreach interchange_file $interchange_files {lremove wait_to_run_files $interchange_file} - -# Flags using for scop-* files. -set DEFAULT_FLAGS_GRAPHITE_SCOP "-O2 -fgraphite -fdump-tree-graphite-all" -set scop_files [lsort [glob -nocomplain $srcdir/$subdir/scop-*.c ] ] -dg-runtest $scop_files "" $DEFAULT_FLAGS_GRAPHITE_SCOP -foreach scop_file $scop_files {lremove wait_to_run_files $scop_file} +set block_files [lsort [glob -nocomplain $srcdir/$subdir/block-*.c ] ] +# Tests to be compiled. +set dg-do-what-default compile +dg-runtest $scop_files "" "-O2 -fgraphite -fdump-tree-graphite-all" +dg-runtest $id_files "" "-O2 -fgraphite-identity -ffast-math" -# Schedule now the tests to be run. +# Tests to be run. set dg-do-what-default run - -# Flags using for run-id-* files. -set DEFAULT_FLAGS_RUN_ID "-O2 -fgraphite-identity" -set run_id_files [lsort [glob -nocomplain $srcdir/$subdir/run-id-*.c ] ] -dg-runtest $run_id_files "" $DEFAULT_FLAGS_RUN_ID -foreach run_id_file $run_id_files {lremove wait_to_run_files $run_id_file} - +dg-runtest $run_id_files "" "-O2 -fgraphite-identity" +dg-runtest $interchange_files "" "-O2 -floop-interchange -fno-loop-block -fno-loop-strip-mine -ffast-math -fdump-tree-graphite-all" +dg-runtest $block_files "" "-O2 -floop-block -fno-loop-strip-mine -fno-loop-interchange -ffast-math -fdump-tree-graphite-all" # The default action for the rest of the files is 'compile'. set dg-do-what-default compile - -# Flags using for other files. -set DEFAULT_FLAGS_GRAPHITE "-ansi -pedantic-errors" -dg-runtest $wait_to_run_files "" $DEFAULT_FLAGS_GRAPHITE +foreach f $scop_files {lremove wait_to_run_files $f} +foreach f $id_files {lremove wait_to_run_files $f} +foreach f $run_id_files {lremove wait_to_run_files $f} +foreach f $interchange_files {lremove wait_to_run_files $f} +foreach f $block_files {lremove wait_to_run_files $f} +dg-runtest $wait_to_run_files "" "-ansi -pedantic-errors" # Clean up. set dg-do-what-default ${save-dg-do-what-default} diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-0.c b/gcc/testsuite/gcc.dg/graphite/interchange-0.c index 3e85250..e6e6dfc 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-0.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-0.c @@ -1,9 +1,16 @@ /* { dg-require-effective-target size32plus } */ -int a[1000][1000]; +#define DEBUG 0 -int -foo (int N) +#if DEBUG +#include +#endif + +#define N 1000 +int a[N][N]; + +static int __attribute__((noinline)) +foo (void) { int j; int i; @@ -12,8 +19,27 @@ foo (int N) for (j = 0; j < N; j++) a[j][i] = a[j][i] + 1; - return a[N][123]; + return a[N-1][N-1]; +} + +int +main (void) +{ + int i, j, res; + + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + a[i][j] = 1; + + a[N-1][N-1] = 12; + res = foo (); + +#if DEBUG + fprintf (stderr, "res = %d \n", res); +#endif + + return res != 13; } -/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */ -/* { dg-final { cleanup-tree-dump "graphite" } } */ +/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */ +/* { dg -final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-1.c b/gcc/testsuite/gcc.dg/graphite/interchange-1.c index cd9197d..80a2e34 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-1.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-1.c @@ -2,8 +2,15 @@ /* Formerly known as ltrans-1.c */ +#define DEBUG 0 +#if DEBUG +#include +#endif + double u[1782225]; -int foo(int N, int *res) + +static int __attribute__((noinline)) +foo (int N) { int i, j; double sum = 0.0; @@ -15,8 +22,27 @@ int foo(int N, int *res) u[1336 * i] *= 2; } - *res = sum + N; + + return sum + N + u[1336 * 2] + u[1336]; } +int +main (void) +{ + int i, j, res; + + for (i = 0; i < 1782225; i++) + u[i] = 2; + + res = foo (1335); + +#if DEBUG + fprintf (stderr, "res = %d \n", res); +#endif + + return res != 3565793; +} + + /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" { xfail *-*-* } } } */ /* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-10.c b/gcc/testsuite/gcc.dg/graphite/interchange-10.c index 0cd22a3..17f807b 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-10.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-10.c @@ -1,5 +1,14 @@ +/* { dg-require-effective-target size32plus } */ + +#define DEBUG 0 +#if DEBUG +#include +#endif + double u[1782225]; -int foo(int N, int *res) + +static void __attribute__((noinline)) +foo (int N, int *res) { int i, j; double sum = 0.0; @@ -12,7 +21,24 @@ int foo(int N, int *res) for (j = 0; j < N; j++) sum = sum + u[i + 1335 * j]; - *res = sum + N; + *res = sum + N + u[1336 * 2] + u[1336]; +} + +int +main (void) +{ + int i, res; + + for (i = 0; i < 1782225; i++) + u[i] = 2; + + foo (1335, &res); + +#if DEBUG + fprintf (stderr, "res = %d \n", res); +#endif + + return res != 7130239; } /* { dg-final { scan-tree-dump-times "will be interchanged" 2 "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-11.c b/gcc/testsuite/gcc.dg/graphite/interchange-11.c index dea8df7..eecc979 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-11.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-11.c @@ -1,5 +1,14 @@ +/* { dg-require-effective-target size32plus } */ + +#define DEBUG 0 +#if DEBUG +#include +#endif + double u[1782225]; -int foo(int N, int *res) + +static void __attribute__((noinline)) +foo (int N, int *res) { int i, j; double sum = 0.0; @@ -14,5 +23,22 @@ int foo(int N, int *res) *res = sum; } +int +main (void) +{ + int i, res; + + for (i = 0; i < 1782225; i++) + u[i] = 2; + + foo (1335, &res); + +#if DEBUG + fprintf (stderr, "res = %d \n", res); +#endif + + return res != 3564450; +} + /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" { xfail *-*-* } } } */ /* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-12.c b/gcc/testsuite/gcc.dg/graphite/interchange-12.c index 73c9c8c..dc5b138 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-12.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-12.c @@ -1,8 +1,16 @@ -#define N 1000 +/* { dg-require-effective-target size32plus } */ -float A[N][N], B[N][N], C[N][N]; +#define DEBUG 0 +#if DEBUG +#include +#endif -void matmult () +#define N 200 + +int A[N][N], B[N][N], C[N][N]; + +static int __attribute__((noinline)) +matmult (void) { int i, j, k; @@ -13,6 +21,30 @@ void matmult () for (k = 0; k < N; k++) A[i][j] += B[i][k] * C[k][j]; } + + return A[0][0] + A[N-1][N-1]; +} + +int +main (void) +{ + int i, j, res; + + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + { + A[i][j] = 0; + B[i][j] = i - j; + C[i][j] = i + j; + } + + res = matmult (); + +#if DEBUG + fprintf (stderr, "res = %d \n", res); +#endif + + return res != 2626800; } /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-2.c b/gcc/testsuite/gcc.dg/graphite/interchange-2.c index 6b1dbe6..62692de 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-2.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-2.c @@ -2,12 +2,19 @@ /* Formerly known as ltrans-2.c */ +#define DEBUG 0 +#if DEBUG +#include +#endif + double u[1782225]; -int foo(int N, int *res) + +static void __attribute__((noinline)) +foo (int N, int *res) { unsigned int i, j; double sum = 0; - + /* This loop should be converted to a perfect nest and interchanged. */ for (i = 0; i < N; i++) @@ -19,7 +26,25 @@ int foo(int N, int *res) u[1336 * i] *= 2; } } - *res = sum + N; + + *res = sum + N + u[1336 * 2] + u[1336]; +} + +int +main (void) +{ + int i, j, res; + + for (i = 0; i < 1782225; i++) + u[i] = 2; + + foo (1335, &res); + +#if DEBUG + fprintf (stderr, "res = %d \n", res); +#endif + + return res != 3565793; } /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" { xfail *-*-* } } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-3.c b/gcc/testsuite/gcc.dg/graphite/interchange-3.c index c2a6744..95c228d 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-3.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-3.c @@ -2,19 +2,44 @@ /* Formerly known as ltrans-3.c */ +#define DEBUG 0 +#if DEBUG +#include +#endif + double u[1782225]; -int foo(int N, int *res) + +static void __attribute__((noinline)) +foo (int N, int *res) { unsigned int i, j; double sum = 0; - for (i = 0; i < N; i++) + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) { - for (j = 0; j < N; j++) - { - sum = sum + u[i + 1335 * j]; - } + sum = sum + u[i + 1335 * j]; } - *res = sum + N; + } + + *res = sum + N + u[1336 * 2] + u[1336]; +} + +int +main (void) +{ + int i, j, res; + + for (i = 0; i < 1782225; i++) + u[i] = 2; + + foo (1335, &res); + +#if DEBUG + fprintf (stderr, "res = %d \n", res); +#endif + + return res != 3565789; } /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-4.c b/gcc/testsuite/gcc.dg/graphite/interchange-4.c index c0ec7fa..5d3c7b1 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-4.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-4.c @@ -2,8 +2,15 @@ /* Formerly known as ltrans-4.c */ +#define DEBUG 0 +#if DEBUG +#include +#endif + double u[1782225]; -int foo(int N, int *res) + +static int __attribute__((noinline)) +foo (int N, int *res) { int i, j; double sum = 0; @@ -13,7 +20,25 @@ int foo(int N, int *res) for (i = 0; i < N; i++) u[1336 * i] *= 2; - *res = sum + N; + + *res = sum + N + u[1336 * 2] + u[1336]; +} + +int +main (void) +{ + int i, j, res; + + for (i = 0; i < 1782225; i++) + u[i] = 2; + + foo (1335, &res); + +#if DEBUG + fprintf (stderr, "res = %d \n", res); +#endif + + return res != 3565793; } /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-5.c b/gcc/testsuite/gcc.dg/graphite/interchange-5.c index 19a5e09..a912fe2 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-5.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-5.c @@ -2,17 +2,44 @@ /* Formerly known as ltrans-5.c */ -int foo () +#define DEBUG 0 +#if DEBUG +#include +#endif + +#define N 100 +#define M 1111 +int A[N][M]; + +static int __attribute__((noinline)) +foo (void) { - int A[100][1111]; int i, j; - for( i = 0; i < 1111; i++) - for( j = 0; j < 100; j++) + for( i = 0; i < M; i++) + for( j = 0; j < N; j++) A[j][i] = 5 * A[j][i]; - return A[10][10]; + return A[0][0] + A[N-1][M-1]; +} + +int +main (void) +{ + int i, j, res; + + for (i = 0; i < N; i++) + for (j = 0; j < M; j++) + A[i][j] = 2; + + res = foo (); + +#if DEBUG + fprintf (stderr, "res = %d \n", res); +#endif + + return res != 20; } -/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */ +/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */ /* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-6.c b/gcc/testsuite/gcc.dg/graphite/interchange-6.c index 1845487..2ff886c 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-6.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-6.c @@ -2,17 +2,44 @@ /* Formerly known as ltrans-6.c */ -int medium_loop_interchange(int A[100][200]) +#define DEBUG 0 +#if DEBUG +#include +#endif + +#define N 100 +#define M 200 + +static int __attribute__((noinline)) +foo (int A[N][M]) { - int i,j; + int i, j; /* This loop should be interchanged. */ - - for(j = 0; j < 200; j++) - for(i = 0; i < 100; i++) + for(j = 0; j < M; j++) + for(i = 0; i < N; i++) A[i][j] = A[i][j] + A[i][j]; - return A[1][1]; + return A[0][0] + A[N-1][M-1]; +} + +int +main (void) +{ + int A[N][M]; + int i, j, res; + + for (i = 0; i < N; i++) + for (j = 0; j < M; j++) + A[i][j] = 2; + + res = foo (A); + +#if DEBUG + fprintf (stderr, "res = %d \n", res); +#endif + + return res != 8; } /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-7.c b/gcc/testsuite/gcc.dg/graphite/interchange-7.c index 2a7bf86..a030943 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-7.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-7.c @@ -1,17 +1,45 @@ +/* { dg-require-effective-target size32plus } */ + /* Formerly known as ltrans-8.c */ -double +#define DEBUG 0 +#if DEBUG +#include +#endif + +#define N 111 +#define M 1111 + +static int __attribute__((noinline)) foo (double *a) { int i,j; - double r = 0.0; + int r = 0; - for (i = 0; i < 100; ++i) - for (j = 0; j < 1000; ++j) - r += a[j * 100 + i]; + for (i = 0; i < N; ++i) + for (j = 0; j < M; ++j) + r += a[j * N + i]; return r; } +int +main (void) +{ + double A[N*M]; + int i, res; + + for (i = 0; i < N*M; i++) + A[i] = 2; + + res = foo (A); + +#if DEBUG + fprintf (stderr, "res = %d \n", res); +#endif + + return res != 246642; +} + /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */ /* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-8.c b/gcc/testsuite/gcc.dg/graphite/interchange-8.c index 24b9a15..94bd66b 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-8.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-8.c @@ -1,9 +1,15 @@ -int +#define DEBUG 0 +#if DEBUG +#include +#endif + +int B[4]; +int A[4][4][4][4]; + +static int __attribute__((noinline)) foo (void) { int i, j, k, l; - int B[4]; - int A[4][4][4][4]; for (l = 0; l < 4; l++) { @@ -37,7 +43,36 @@ foo (void) } } - return A[0][1][0][2]; + return A[0][1][0][2] + A[0][3][0][3] + A[0][2][0][2] + A[0][1][0][1] + A[3][3][0][2]; +} + +int +main (void) +{ + int i, j, k, l, res; + + for (i = 0; i < 4; i++) + B[i] = 2; + + for (i = 0; i < 4; i++) + for (j = 0; j < 4; j++) + for (k = 0; k < 4; k++) + for (l = 0; l < 4; l++) + A[i][j][k][l] = i + j + k + l; + + res = foo (); + +#if DEBUG + for (i = 0; i < 4; i++) + for (j = 0; j < 4; j++) + for (k = 0; k < 4; k++) + for (l = 0; l < 4; l++) + fprintf (stderr, "A[%d][%d][%d][%d] = %d \n", i, j, k, l, A[i][j][k][l]); + + fprintf (stderr, "res = %d \n", res); +#endif + + return res != 424; } /* Loops K and L should be interchanged. */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-9.c b/gcc/testsuite/gcc.dg/graphite/interchange-9.c index e55d818..d4e05c3 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-9.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-9.c @@ -1,15 +1,43 @@ -int +/* { dg-require-effective-target size32plus } */ + +#define DEBUG 0 +#if DEBUG +#include +#endif + +#define N 1111 +#define M 1111 + +static int __attribute__((noinline)) foo (int *x) { int i, j; int sum = 0; - for (j = 0; j < 10000; ++j) - for (i = 0; i < 10000; ++i) - sum += x[10000 * i + j]; + for (j = 0; j < M; ++j) + for (i = 0; i < N; ++i) + sum += x[M * i + j]; return sum; } +int +main (void) +{ + int A[N*M]; + int i, res; + + for (i = 0; i < N*M; i++) + A[i] = 2; + + res = foo (A); + +#if DEBUG + fprintf (stderr, "res = %d \n", res); +#endif + + return res != 2468642; +} + /* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" } } */ /* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-mvt.c b/gcc/testsuite/gcc.dg/graphite/interchange-mvt.c index 915a7ac..1e44f0a 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-mvt.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-mvt.c @@ -1,22 +1,55 @@ +/* { dg-require-effective-target size32plus } */ + +#define DEBUG 0 +#if DEBUG +#include +#endif + #define NMAX 2000 -static double x1[NMAX], x2[NMAX], a[NMAX][NMAX], y_1[NMAX], y_2[NMAX]; +static int x1[NMAX], x2[NMAX], a[NMAX][NMAX], y1[NMAX], y2[NMAX]; -void mvt(long N) { +static int __attribute__((noinline)) +mvt (long N) +{ - int i,j; + int i,j; - for (i=0; i