diff options
author | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-02-06 21:44:56 +0000 |
---|---|---|
committer | bstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-02-06 21:44:56 +0000 |
commit | 3c0d801cdcce83e1739c42de0e26106281a61df9 (patch) | |
tree | a4bb1c0be4d5153898c2f02a7677e835473d9781 /gcc/testsuite/gcc.dg/graphite | |
parent | 7b919065100b9d5597126afce413f6caa6277704 (diff) | |
download | gcc-3c0d801cdcce83e1739c42de0e26106281a61df9.tar.gz |
2010-02-06 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 156556
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@156557 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/graphite')
27 files changed, 770 insertions, 149 deletions
diff --git a/gcc/testsuite/gcc.dg/graphite/block-0.c b/gcc/testsuite/gcc.dg/graphite/block-0.c index a00694ca406..320ee791367 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 <stdio.h> +#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,8 +21,19 @@ 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" } } */ +/* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" { xfail *-*-* } } } */ /* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/block-1.c b/gcc/testsuite/gcc.dg/graphite/block-1.c index 35c5c6a1f1e..64ff67b2226 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 <stdio.h> +#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 75356161334..01e186352f8 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 <stdio.h> +#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 d752a4d95e6..50927573782 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 <stdio.h> +#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,11 +20,34 @@ 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" } } */ +/* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" { xfail *-*-* } } } */ /* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/block-5.c b/gcc/testsuite/gcc.dg/graphite/block-5.c index a8f3817e67e..4b99900c9d4 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 <stdio.h> +#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 6905e3635f7..a147ab8af49 100644 --- a/gcc/testsuite/gcc.dg/graphite/block-6.c +++ b/gcc/testsuite/gcc.dg/graphite/block-6.c @@ -1,24 +1,46 @@ /* { 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 <stdio.h> +#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" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/block-7.c b/gcc/testsuite/gcc.dg/graphite/block-7.c new file mode 100644 index 00000000000..a07ef11738d --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/block-7.c @@ -0,0 +1,51 @@ +/* { dg-require-effective-target size32plus } */ + +#define DEBUG 0 +#if DEBUG +#include <stdio.h> +#endif + +#define N 200 + +int A[N][N], B[N][N], C[N][N]; + +static void __attribute__((noinline)) +matmult (void) +{ + int i, j, k; + + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + { + A[i][j] = 0; + for (k = 0; k < N; k++) + A[i][j] += B[i][k] * C[k][j]; + } +} + +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 "will be loop blocked" 1 "graphite" { xfail *-*-* } } } */ +/* { 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 c4a8b2e748b..411e0417afd 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/id-17.c b/gcc/testsuite/gcc.dg/graphite/id-17.c new file mode 100644 index 00000000000..c93c211e459 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-17.c @@ -0,0 +1,21 @@ +typedef struct +{ + int offset_for_ref_frame[256]; +} seq_parameter_set_rbsp_t; + +typedef struct +{ + unsigned int num_ref_frames_in_pic_order_cnt_cycle; + int offset_for_ref_frame[1]; + int auto_crop_right; +} ImageParameters; + +ImageParameters *img; + +void GenerateSequenceParameterSet(seq_parameter_set_rbsp_t *sps) +{ + unsigned i; + for (i=0; i<img->num_ref_frames_in_pic_order_cnt_cycle; i++) + sps->offset_for_ref_frame[i] = img->offset_for_ref_frame[i]; + error("foo"); +} diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-0.c b/gcc/testsuite/gcc.dg/graphite/interchange-0.c index 3e8525070bf..e6e6dfc4795 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 <stdio.h> +#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 cd9197d4d1a..80a2e346234 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 <stdio.h> +#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 0cd22a3b412..17f807b0c07 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 <stdio.h> +#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 dea8df75369..eecc979a1f3 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 <stdio.h> +#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 new file mode 100644 index 00000000000..c0e331bb687 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/interchange-12.c @@ -0,0 +1,51 @@ +/* { dg-require-effective-target size32plus } */ + +#define DEBUG 0 +#if DEBUG +#include <stdio.h> +#endif + +#define N 200 + +int A[N][N], B[N][N], C[N][N]; + +static int __attribute__((noinline)) +matmult (void) +{ + int i, j, k; + + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + { + A[i][j] = 0; + 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" { xfail *-*-* } } } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-2.c b/gcc/testsuite/gcc.dg/graphite/interchange-2.c index 6b1dbe6514f..62692defae4 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 <stdio.h> +#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 c2a67445631..95c228d07e8 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 <stdio.h> +#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 c0ec7fa3c81..5d3c7b186f6 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 <stdio.h> +#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 19a5e09397f..a912fe24984 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 <stdio.h> +#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 18454879b1f..2ff886cf7ee 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 <stdio.h> +#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 2a7bf867bda..a030943c01a 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 <stdio.h> +#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 24b9a15a7ed..94bd66b644d 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 <stdio.h> +#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 e55d8180cfe..d4e05c369af 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 <stdio.h> +#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 915a7acf33b..a1310dd6725 100644 --- a/gcc/testsuite/gcc.dg/graphite/interchange-mvt.c +++ b/gcc/testsuite/gcc.dg/graphite/interchange-mvt.c @@ -1,24 +1,57 @@ +/* { dg-require-effective-target size32plus } */ + +#define DEBUG 0 +#if DEBUG +#include <stdio.h> +#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<N; i++) { - for (j=0; j<N; j++) { - x1[i] = x1[i] + a[i][j] * y_1[j]; - } - } - - for (i=0; i<N; i++) { - for (j=0; j<N; j++) { - x2[i] = x2[i] + a[j][i] * y_2[j]; - } + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + x1[i] = x1[i] + a[i][j] * y1[j]; + + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + x2[i] = x2[i] + a[j][i] * y2[j]; + + return x1[0] + x2[0]; +} + +int +main (void) +{ + int i, j, res; + + for (i = 0; i < NMAX; i++) + for (j = 0; j < NMAX; j++) + a[i][j] = i + j; + + for (i = 0; i < NMAX; i++) + { + x1[i] = 0; + x2[i] = 2*i; + y1[i] = 100 - i; + y2[i] = i; } + + res = mvt (NMAX); + +#if DEBUG + fprintf (stderr, "res = %d \n", res); +#endif + + return res != 199900000; } -/* { dg-final { scan-tree-dump-times "will be interchanged" 1 "graphite" { xfail *-*-* } } } */ +/* { 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/pr41888.c b/gcc/testsuite/gcc.dg/graphite/pr41888.c new file mode 100644 index 00000000000..b262af68e92 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr41888.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-g -O2 -ftree-loop-distribution -fgraphite-identity" } */ + +int +foo (int *x) +{ + int a[10], b[10]; + int i; + a[9] = 8; + b[9] = 8; + for (i = 0; i < 9; i++) + { + a[i] = *x++; + b[i] = 1; + } + b[i] = b[i] & !(a[i] ^ *x++); + return b[i] ? i + 1 : 0; +} diff --git a/gcc/testsuite/gcc.dg/graphite/run-id-2.c b/gcc/testsuite/gcc.dg/graphite/run-id-2.c index acaa14c6d0e..0fd5efd8dc2 100644 --- a/gcc/testsuite/gcc.dg/graphite/run-id-2.c +++ b/gcc/testsuite/gcc.dg/graphite/run-id-2.c @@ -1,6 +1,7 @@ int a[1] = {1}; -static int __attribute__((noinline)) foo(int n) +static int __attribute__((noinline)) +foo(int n) { int i, c = 0; for (i = 0; i < n; i++) @@ -24,5 +25,3 @@ int main() foo(0) != 0 || foo(1) != 1 || bar(0) != 0 || bar(1) != 2 || bar(2) != 5; } -/* { dg-do run } */ -/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-0.c b/gcc/testsuite/gcc.dg/graphite/scop-0.c index 067e7bcffe0..120de9c7f23 100644 --- a/gcc/testsuite/gcc.dg/graphite/scop-0.c +++ b/gcc/testsuite/gcc.dg/graphite/scop-0.c @@ -17,6 +17,6 @@ int toto() /* End scop 1. */ } -/* { dg-final { scan-tree-dump-times "number of SCoPs: 1" 1 "graphite"} } */ +/* { dg-final { scan-tree-dump-times "number of SCoPs: 1" 1 "graphite"} } */ /* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-22.c b/gcc/testsuite/gcc.dg/graphite/scop-22.c new file mode 100644 index 00000000000..b77be22b14d --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/scop-22.c @@ -0,0 +1,21 @@ +double u[1782225]; + +void foo(int N, int *res) +{ + int i; + double a, b; + double sum = 0.0; + + for (i = 0; i < N; i++) + { + a = u[i]; + u[i] = i * i; + b = u[i]; + sum += a + b; + } + + *res = sum + N; +} + +/* { dg-final { scan-tree-dump-times "number of SCoPs: 1" 1 "graphite"} } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ |