diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gcc.dg/graphite | |
download | cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2 cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig;
imported gcc-4.6.4 source tree from verified upstream tarball.
downloading a git-generated archive based on the 'upstream' tag
should provide you with a source tree that is binary identical
to the one extracted from the above tarball.
if you have obtained the source via the command 'git clone',
however, do note that line-endings of files in your working
directory might differ from line-endings of the respective
files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gcc.dg/graphite')
174 files changed, 5281 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/graphite/block-0.c b/gcc/testsuite/gcc.dg/graphite/block-0.c new file mode 100644 index 000000000..9bf97126d --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/block-0.c @@ -0,0 +1,46 @@ +#define DEBUG 0 +#if DEBUG +#include <stdio.h> +#endif + +#define N 1000 +int a[N]; + +static int __attribute__((noinline)) +foo (void) +{ + int j; + int i; + + /* This is not blocked as it is not profitable. */ + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + a[j] = a[i] + 1; + + return a[0]; +} + +extern void abort (); + +int +main (void) +{ + int i, res; + + for (i = 0; i < N; i++) + a[i] = i; + + res = foo (); + +#if DEBUG + fprintf (stderr, "res = %d \n", res); +#endif + + if (res != 1999) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-not "will be loop blocked" "graphite" } } */ +/* { 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 new file mode 100644 index 000000000..d335345a6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/block-1.c @@ -0,0 +1,49 @@ +/* { dg-require-effective-target size32plus } */ + +#define DEBUG 0 +#if DEBUG +#include <stdio.h> +#endif + +#define MAX 100 + +extern void abort (); + +int +main (void) +{ + int i, j; + int sum = 0; + int A[MAX * MAX]; + int B[MAX * MAX]; + + /* These loops should be loop blocked. */ + for (i = 0; i < MAX; i++) + for (j = 0; j < MAX; j++) + { + A[i*MAX + j] = j; + B[i*MAX + j] = j; + } + + /* These loops should be loop blocked. */ + for (i = 0; i < MAX; i++) + for (j = 0; j < MAX; j++) + A[i*MAX + j] += B[j*MAX + i]; + + /* These loops should be loop blocked. */ + for(i = 0; i < MAX; i++) + for(j = 0; j < MAX; j++) + sum += A[i*MAX + j]; + +#if DEBUG + fprintf (stderr, "sum = %d \n", sum); +#endif + + if (sum != 990000) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "will be loop blocked" 3 "graphite" } } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/block-3.c b/gcc/testsuite/gcc.dg/graphite/block-3.c new file mode 100644 index 000000000..322ed8d7f --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/block-3.c @@ -0,0 +1,61 @@ +/* { dg-require-effective-target size32plus } */ +/* { dg-timeout-factor 4.0 } */ + +#define DEBUG 0 +#if DEBUG +#include <stdio.h> +#endif + +#define N 24 +#define M 100 + +int A[M][M][M], B[M][M], C[M][M]; + +static int __attribute__((noinline)) +foo (void) +{ + int i, j, k; + + /* These loops contain too few iterations to be blocked by 64. */ + for (i = 0; i < 24; i++) + for (j = 0; j < 24; j++) + for (k = 0; k < 24; k++) + A[i][j][k] = B[i][k] * C[k][j]; + + /* These loops should still be loop blocked. */ + for (i = 0; i < M; i++) + 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]; +} + +extern void abort (); + +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 + + if (res != 9801) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" } } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/block-4.c b/gcc/testsuite/gcc.dg/graphite/block-4.c new file mode 100644 index 000000000..eb98f0447 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/block-4.c @@ -0,0 +1,60 @@ +/* { dg-require-effective-target size32plus } */ + +#define DEBUG 0 +#if DEBUG +#include <stdio.h> +#endif + +#define N 24 +#define M 1000 + +int A[M][M], B[M][M], C[M][M]; + +static int __attribute__((noinline)) +foo (void) +{ + int i, j, k; + + /* This should NOT be blocked: each loop iterates only 24 times. */ + for (i = 0; i < 24; i++) + for (j = 0; j < 24; j++) + for (k = 0; k < 24; k++) + A[i][j] = B[i][k] * C[k][j]; + + /* This should be blocked. */ + 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]; +} + +extern void abort (); + +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 + + if (res != 998001) + abort (); + + return 0; +} + +/* { 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 new file mode 100644 index 000000000..b577958c5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/block-5.c @@ -0,0 +1,57 @@ +/* { dg-require-effective-target size32plus } */ + +#define DEBUG 0 +#if DEBUG +#include <stdio.h> +#endif + +#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++) + for (i = 0; i < N; i++) + a[i][j] = a[i][j-1] + b[i][j]; + + for (i = 0; i < N; i++) + res += a[i][i]; + + return res; +} + +extern void abort (); + +int +main (void) +{ + int i, j, res; + + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + { + a[i][j] = i + j; + b[i][j] = i - j; + } + + res = foo (); + +#if DEBUG + fprintf (stderr, "res = %d \n", res); +#endif + + if (res != 1333300) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" } } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/block-6.c b/gcc/testsuite/gcc.dg/graphite/block-6.c new file mode 100644 index 000000000..8f250db51 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/block-6.c @@ -0,0 +1,52 @@ +/* { dg-require-effective-target size32plus } */ + +#define DEBUG 0 +#if DEBUG +#include <stdio.h> +#endif + +#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 (i = 0; i < N; i++) + res += a[i][i]; + + return res; +} + +extern void abort (); + +int +main (void) +{ + int i, j, res; + + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + a[i][j] = i + j; + + res = foo (); + +#if DEBUG + fprintf (stderr, "res = %d \n", res); +#endif + + if (res != 204007516) + abort (); + + return 0; +} + +/* { 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 new file mode 100644 index 000000000..fbbe1f3ad --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/block-7.c @@ -0,0 +1,57 @@ +/* { 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; + + /* This should be blocked. */ + 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]; + } +} + +extern void abort (); + +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 + + if (res != 529340000) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "will be loop blocked" 1 "graphite" } } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/block-8.c b/gcc/testsuite/gcc.dg/graphite/block-8.c new file mode 100644 index 000000000..9c1c9cebe --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/block-8.c @@ -0,0 +1,58 @@ +/* { 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; + + /* This should be blocked. */ + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + for (k = 0; k < N; k++) + A[i][j] += B[i][k] * C[k][j]; +} + +extern void abort (); + +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 + + if (res != 529340000) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "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 new file mode 100644 index 000000000..cdf35ebab --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/graphite.exp @@ -0,0 +1,81 @@ +# Copyright (C) 2006, 2007, 2008, 2010 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. + +# GCC testsuite that uses the `dg.exp' driver. + +# Load support procs. +load_lib gcc-dg.exp + +if ![check_effective_target_fgraphite] { + return +} + +# Remove VALUE from LIST_VARIABLE. +proc lremove {list_variable value} { + upvar 1 $list_variable var + set idx [lsearch -exact $var $value] + set var [lreplace $var $idx $idx] +} + +# 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} + +# Initialize `dg'. +dg-init + +set wait_to_run_files [lsort [glob -nocomplain $srcdir/$subdir/*.c ] ] +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 ] ] +set block_files [lsort [glob -nocomplain $srcdir/$subdir/block-*.c ] ] +set vect_files [lsort [glob -nocomplain $srcdir/$subdir/vect-*.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" + +# Tests to be run. +set dg-do-what-default run +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" + +# Vectorizer tests, to be run or compiled, depending on target capabilities. +global DEFAULT_VECTCFLAGS +set DEFAULT_VECTCFLAGS "-O2 -fgraphite-identity -ftree-vectorize -fno-vect-cost-model -fdump-tree-vect-details -ffast-math" + +if [check_vect_support_and_set_flags] { + dg-runtest $vect_files "" $DEFAULT_VECTCFLAGS +} + +# The default action for the rest of the files is 'compile'. +set dg-do-what-default compile +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} +foreach f $vect_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} + +# All done. +dg-finish diff --git a/gcc/testsuite/gcc.dg/graphite/id-1.c b/gcc/testsuite/gcc.dg/graphite/id-1.c new file mode 100644 index 000000000..70b477a07 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-1.c @@ -0,0 +1,18 @@ +typedef int *lambda_vector; +typedef lambda_vector *lambda_matrix; +lambda_vector_add_mc (lambda_vector vec1, int const1, + lambda_vector vec2, int const2, + lambda_vector vec3, int size) +{ + int i; + for (i = 0; i < size; i++) + vec3[i] = const1 * vec1[i] + const2 * vec2[i]; +} +lambda_matrix_add_mc (lambda_matrix mat1, int const1, + lambda_matrix mat2, int const2, + lambda_matrix mat3, int m, int n) +{ + int i; + for (i = 0; i < m; i++) + lambda_vector_add_mc (mat1[i], const1, mat2[i], const2, mat3[i], n); +} diff --git a/gcc/testsuite/gcc.dg/graphite/id-10.c b/gcc/testsuite/gcc.dg/graphite/id-10.c new file mode 100644 index 000000000..8c2b88982 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-10.c @@ -0,0 +1,15 @@ +int bar[100][100]; + +int +foo (int N, unsigned int J) +{ + int i, k; + + for (k = 0; k < N; k++) + if (k != J) + for (i = 0; i < N; i++) + if (i != J) + bar[k][i] = 20; + + return bar[N][J]; +} diff --git a/gcc/testsuite/gcc.dg/graphite/id-11.c b/gcc/testsuite/gcc.dg/graphite/id-11.c new file mode 100644 index 000000000..387512c3c --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-11.c @@ -0,0 +1,14 @@ +double +foo (double x, double *cof) +{ + int i; + double tmp, value; + + for (i = 10; i >= 0; i--) + { + value += cof[i] / tmp; + tmp -= 1.0; + } + + return value; +} diff --git a/gcc/testsuite/gcc.dg/graphite/id-12.c b/gcc/testsuite/gcc.dg/graphite/id-12.c new file mode 100644 index 000000000..57857d1d2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-12.c @@ -0,0 +1,10 @@ +void +foo (unsigned short x[]) +{ + int i; + unsigned short *p = &x[2]; + if (*p) + x += 2; + for (i = 2; i < 9; i++, ++x) + *x >>= 8; +} diff --git a/gcc/testsuite/gcc.dg/graphite/id-13.c b/gcc/testsuite/gcc.dg/graphite/id-13.c new file mode 100644 index 000000000..e921cd4e9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-13.c @@ -0,0 +1,11 @@ +void +foo (int N, int k, int *fb) +{ + int i, j; + for (i = 1; i <= N; i++) + { + for (j = 1; j < i; j++) + k %= N; + bar (k); + } +} diff --git a/gcc/testsuite/gcc.dg/graphite/id-14.c b/gcc/testsuite/gcc.dg/graphite/id-14.c new file mode 100644 index 000000000..51ac4c1bb --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-14.c @@ -0,0 +1,19 @@ +typedef struct { + int n; + float *a; +} bar; + +float +foo (bar *b) +{ + float c, d; + int j; + + for (j = 0; (j < b->n); j++) + d += b->a[j]; + + for (j = 0; (j < b->n); j++) + c += b->a[j]; + + return d; +} diff --git a/gcc/testsuite/gcc.dg/graphite/id-15.c b/gcc/testsuite/gcc.dg/graphite/id-15.c new file mode 100644 index 000000000..b57c20969 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-15.c @@ -0,0 +1,120 @@ +/* { dg-require-effective-target int32plus } */ + +typedef long unsigned int size_t; +extern void *memset (void *__s, int __c, size_t __n) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1))); + +static void +encode (words, low, hi) + long *words; + unsigned long low; + long hi; +{ + words[0] = ((low) & (((unsigned long) 1 << (sizeof(unsigned long) / 2)) - 1)); + words[1] = ((unsigned long) (low) >> sizeof(unsigned long) / 2); + words[2] = ((hi) & (((unsigned long) 1 << (sizeof(unsigned long) / 2)) - 1)); + words[3] = ((unsigned long) (hi) >> sizeof(unsigned long) / 2); +} + +static void +decode (words, low, hi) + long *words; + unsigned long *low; + long *hi; +{ + *low = words[0] + words[1] * ((unsigned long) 1 << sizeof(unsigned long) / 2); + *hi = words[2] + words[3] * ((unsigned long) 1 << sizeof(unsigned long) / 2); +} + +int +neg_double (l1, h1, lv, hv) + unsigned long l1; + long h1; + unsigned long *lv; + long *hv; +{ + if (l1 == 0) + { + *lv = 0; + *hv = - h1; + return (*hv & h1) < 0; + } + else + { + *lv = -l1; + *hv = ~h1; + return 0; + } +} + +int +add_double (l1, h1, l2, h2, lv, hv) + unsigned long l1, l2; + long h1, h2; + unsigned long *lv; + long *hv; +{ + unsigned long l; + long h; + + l = l1 + l2; + h = h1 + h2 + (l < l1); + + *lv = l; + *hv = h; + return ((~((h1) ^ (h2)) & ((h1) ^ (h))) < 0); +} + +int +mul_double (l1, h1, l2, h2, lv, hv) + unsigned long l1, l2; + long h1, h2; + unsigned long *lv; + long *hv; +{ + long arg1[4]; + long arg2[4]; + long prod[4 * 2]; + unsigned long carry; + int i, j, k; + unsigned long toplow, neglow; + long tophigh, neghigh; + + encode (arg1, l1, h1); + encode (arg2, l2, h2); + + memset ((char *) prod, 0, sizeof prod); + + for (i = 0; i < 4; i++) + { + carry = 0; + for (j = 0; j < 4; j++) + { + k = i + j; + + carry += arg1[i] * arg2[j]; + + carry += prod[k]; + prod[k] = ((carry) & (((unsigned long) 1 << (sizeof(unsigned long) / 2)) - 1)); + carry = ((unsigned long) (carry) >> sizeof(unsigned long) / 2); + } + prod[i + 4] = carry; + } + + decode (prod, lv, hv); + + + + decode (prod + 4, &toplow, &tophigh); + if (h1 < 0) + { + neg_double (l2, h2, &neglow, &neghigh); + add_double (neglow, neghigh, toplow, tophigh, &toplow, &tophigh); + } + if (h2 < 0) + { + neg_double (l1, h1, &neglow, &neghigh); + add_double (neglow, neghigh, toplow, tophigh, &toplow, &tophigh); + } + return (*hv < 0 ? ~(toplow & tophigh) : toplow | tophigh) != 0; +} + diff --git a/gcc/testsuite/gcc.dg/graphite/id-16.c b/gcc/testsuite/gcc.dg/graphite/id-16.c new file mode 100644 index 000000000..faa685f80 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-16.c @@ -0,0 +1,44 @@ +int transformation[(2*19 - 1) * (2*19 - 1)][8]; + +const int transformation2[8][2][2] = { + {{1, 0}, {0, 1}}, + {{0, 1}, {-1, 0}}, + {{-1, 0}, {0, -1}}, + {{0, -1}, {1, 0}}, + {{0, -1}, {-1, 0}}, + {{-1, 0}, {0, 1}}, + {{0, 1}, {1, 0}}, + {{1, 0}, {0, -1}} +}; + +void +transformation_init (void) +{ + int k; + int dx; + int dy; + + for (k = 0; k < 8; k++) + { + for (dy = -19 + 1; dy <= 19 - 1; dy++) + { + for (dx = -19 + 1; dx <= 19 - 1; dx++) + { + int tx; + int ty; + do + { + *&tx = + transformation2[k][0][0] * (dx) + + transformation2[k][0][1] * (dy); + *&ty = + transformation2[k][1][0] * (dx) + + transformation2[k][1][1] * (dy); + } + while (0); + transformation[((dy + 19 - 1) * (2 * 19 - 1) + + (dx + 19 - 1))][k] = ((tx) * (19 + 1) + (ty)); + } + } + } +} 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 000000000..c93c211e4 --- /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/id-18.c b/gcc/testsuite/gcc.dg/graphite/id-18.c new file mode 100644 index 000000000..77628fa8c --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-18.c @@ -0,0 +1,7 @@ +long do_hash (const char * lo, const char * hi) +{ + int val = 0; + for (; lo < hi; ++lo) + val = *lo; + return val; +} diff --git a/gcc/testsuite/gcc.dg/graphite/id-19.c b/gcc/testsuite/gcc.dg/graphite/id-19.c new file mode 100644 index 000000000..b0d626b81 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-19.c @@ -0,0 +1,6 @@ +void byte_insert_op1 (unsigned char *loc, unsigned char *end) +{ + register unsigned char *pto = end + 1 + 2; + while (end != loc) + *--pto = *--end; +} diff --git a/gcc/testsuite/gcc.dg/graphite/id-2.c b/gcc/testsuite/gcc.dg/graphite/id-2.c new file mode 100644 index 000000000..c11f6a283 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-2.c @@ -0,0 +1,16 @@ +typedef _Complex float GFC_COMPLEX_4; +matmul_c4 () +{ + int x, n, count; + GFC_COMPLEX_4 * bbase_y; + GFC_COMPLEX_4 * dest_y; + GFC_COMPLEX_4 * abase_n; + GFC_COMPLEX_4 bbase_yn; + + for (n = 0; n < count; n++) + { + bbase_yn = bbase_y[n]; + for (x = 0; x < count; x++) + dest_y[x] += abase_n[x] * bbase_yn; + } +} diff --git a/gcc/testsuite/gcc.dg/graphite/id-20.c b/gcc/testsuite/gcc.dg/graphite/id-20.c new file mode 100644 index 000000000..7e0cf6dda --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-20.c @@ -0,0 +1,26 @@ +/* { dg-options "-O3 -fgraphite-identity -ffast-math" } */ + +typedef enum +{ + I_SLICE, +} SliceType; +typedef struct +{ + int type; +} ImageParameters; +extern ImageParameters *img; +int A[64], B[64], C[13][8][8], D[13][8][8]; + +void +foo (int q, int temp) +{ + int i, j, k; + for(k=0; k<13; k++) + for(j=0; j<8; j++) + for(i=0; i<8; i++) + { + if (img->type == I_SLICE) + C[k][j][i] = A[temp] << q; + D[k][j][i] = B[temp] << q; + } +} diff --git a/gcc/testsuite/gcc.dg/graphite/id-22.c b/gcc/testsuite/gcc.dg/graphite/id-22.c new file mode 100644 index 000000000..d82554215 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-22.c @@ -0,0 +1,15 @@ +typedef float rvec[3]; +float calc_similar_ind (int nind, rvec x[]) +{ + int i, j, d; + float m, tm, xd, rd; + for(j=0; j<nind; j++) { + i = x[j][0]; + tm += m; + for(d=0 ; d<3; d++) { + xd = x[i][d] - x[i][d]; + rd += m * xd; + } + } + return rd/tm; +} diff --git a/gcc/testsuite/gcc.dg/graphite/id-23.c b/gcc/testsuite/gcc.dg/graphite/id-23.c new file mode 100644 index 000000000..0f8a1f32f --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-23.c @@ -0,0 +1,22 @@ +double *ZV_entries (void); +void SubMtx_fillRowZV (int irow) +{ + double *rowvec = ZV_entries (); + double *entries; + int ii, ipivot, jrow, kk, m; + int *pivotsizes; + + SubMtx_blockDiagonalInfo (&pivotsizes); + + for (jrow = ipivot = kk = 0; jrow <= irow; ipivot++) + { + m = pivotsizes[ipivot]; + if (jrow <= irow && irow < jrow + m) + for (ii = jrow; ii < irow; ii++) + { + rowvec[2*ii] = entries[2*kk]; + rowvec[2*ii+1] = entries[2*kk+1]; + } + jrow += m; + } +} diff --git a/gcc/testsuite/gcc.dg/graphite/id-24.c b/gcc/testsuite/gcc.dg/graphite/id-24.c new file mode 100644 index 000000000..d4660694c --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-24.c @@ -0,0 +1,22 @@ +/* gcc.dg/tree-ssa/loadpre23.c used to ICE with Graphite. */ + +struct { + int a; + int large[100]; +} x; + +int foo(int argc) +{ + int b; + int c; + int i; + int d, e; + + for (i = 0; i < argc; i++) + { + e = x.a; + x.a = 9; + } + return d + e; +} + diff --git a/gcc/testsuite/gcc.dg/graphite/id-25.c b/gcc/testsuite/gcc.dg/graphite/id-25.c new file mode 100644 index 000000000..b719972d0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-25.c @@ -0,0 +1,34 @@ +typedef struct +{ + int mvd[2][(16/4)][(16/4)][2]; +} Macroblock; +typedef struct +{ + int part_size[8][2]; +} InputParameters; +typedef struct +{ + Macroblock *mb_data; + short****** pred_mv; + short****** all_mv; +} ImageParameters; +extern InputParameters *input; +extern ImageParameters *img; +int writeMotionVector8x8 (void) +{ + int i, j, k, l, m; + int step_h = input->part_size[7][0]; + int step_v = input->part_size[7][1]; + Macroblock* currMB = &img->mb_data[9]; + int refindex = 0; + short****** all_mv = img->all_mv; + short****** pred_mv = img->pred_mv; + + for (k=0; k<2; k++) + { + int curr_mvd = all_mv[2][8][0][8][7][8] - pred_mv[2][7][0][8][7][0]; + for (l=0; l < step_v; l++) + for (m=0; m < step_h; m++) + currMB->mvd[0][8][9][8] = curr_mvd; + } +} diff --git a/gcc/testsuite/gcc.dg/graphite/id-26.c b/gcc/testsuite/gcc.dg/graphite/id-26.c new file mode 100644 index 000000000..507d1590f --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-26.c @@ -0,0 +1,24 @@ +int find_sad_16x16(int *intra_mode) +{ + int current_intra_sad_2,best_intra_sad2; + int M1[16][16],M0[4][4][4][4],M3[4],M4[4][4]; + int i,j,k; + int ii,jj; + int up_avail, left_avail, left_up_avail; + for (i=0;i<17;i++) + if (left_up_avail) + { + for (jj=0;jj<4;jj++) + for (ii=0;ii<4;ii++) + for (j=0;j<4;j++) + for (i=0;i<4;i++) + { + M0[i][ii][2][jj]=M3[0]-M3[1]; + M0[i][ii][1][jj]=M3[2]+M3[3]; + current_intra_sad_2 += abs(M0[i][ii][j][jj]); + } + + if(current_intra_sad_2 < best_intra_sad2) + best_intra_sad2=current_intra_sad_2; + } +} diff --git a/gcc/testsuite/gcc.dg/graphite/id-27.c b/gcc/testsuite/gcc.dg/graphite/id-27.c new file mode 100644 index 000000000..d2d4cd36b --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-27.c @@ -0,0 +1,17 @@ +/* { dg-options "-O2 -fgraphite-identity -flto" { target lto } } */ + +typedef long ll; +void foo (int n, ll *p) +{ + while (n--) + *p += *p; +} + +typedef long long lll; +void bar (int n, lll *p) +{ + while (n--) + *p += *p; +} + +int main() { return 0; } diff --git a/gcc/testsuite/gcc.dg/graphite/id-3.c b/gcc/testsuite/gcc.dg/graphite/id-3.c new file mode 100644 index 000000000..608c1c37c --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-3.c @@ -0,0 +1,11 @@ +struct { +} +mmaxloc0_4_i1 () +{ + int dstride; + int *dest; + int rank; + int n; + for (n = 0; n < rank; n++) + dest[n * dstride] = 0; +} diff --git a/gcc/testsuite/gcc.dg/graphite/id-4.c b/gcc/testsuite/gcc.dg/graphite/id-4.c new file mode 100644 index 000000000..38f6738d7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-4.c @@ -0,0 +1,7 @@ +extern a[]; +g () +{ + int i, b; + for (i = 0; i < 10; i++) + a[i] = (b == 0); +} diff --git a/gcc/testsuite/gcc.dg/graphite/id-5.c b/gcc/testsuite/gcc.dg/graphite/id-5.c new file mode 100644 index 000000000..93972d79e --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-5.c @@ -0,0 +1,15 @@ +void matmul_i1 () +{ + int *abase; + int aystride; + int x, n, count, xcount; + int *dest_y; + int *abase_n; + for (n = 0; n < count; n++) + { + abase_n = abase + n * aystride; + for (x = 0; x < xcount; x++) + dest_y[x] += abase_n[x]; + } +} + diff --git a/gcc/testsuite/gcc.dg/graphite/id-6.c b/gcc/testsuite/gcc.dg/graphite/id-6.c new file mode 100644 index 000000000..c3aab432a --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-6.c @@ -0,0 +1,29 @@ +#define N 10000 +void foo (int); +int test () +{ + int a[N]; + unsigned i; + + for (i = 0; i < N; i++) + { + a[i] = i + 12; + + if (i == 40) + a[i] = i; + else + a[i] = i+1; + + + a[i] = i + 12; + a[i] = a[i+1]; + a[i] += a[i+2]; + a[i] += a[i+3]; + a[i] += a[i+4]; + a[i] += a[i+5]; + a[i] += a[i+6]; + + } + + return a[20]; +} diff --git a/gcc/testsuite/gcc.dg/graphite/id-7.c b/gcc/testsuite/gcc.dg/graphite/id-7.c new file mode 100644 index 000000000..9fa811d6e --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-7.c @@ -0,0 +1,16 @@ +void foo (int *BM_tab) +{ + int *BM_tab_base; + + BM_tab_base = BM_tab; + BM_tab += 0400; + while (BM_tab_base != BM_tab) + *--BM_tab = 6; +} + +int main () +{ + int BM_tab[0400]; + foo (BM_tab); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/graphite/id-8.c b/gcc/testsuite/gcc.dg/graphite/id-8.c new file mode 100644 index 000000000..1a278c164 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-8.c @@ -0,0 +1,14 @@ +int blah; +foo() +{ + int i; + + for (i=0 ; i< 7 ; i++) + { + if (i == 7 - 1) + blah = 0xfcc; + else + blah = 0xfee; + } + return blah; +} diff --git a/gcc/testsuite/gcc.dg/graphite/id-9.c b/gcc/testsuite/gcc.dg/graphite/id-9.c new file mode 100644 index 000000000..219953869 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-9.c @@ -0,0 +1,26 @@ +typedef enum +{ + no_op, + jump +} +re_opcode_t; +struct +{ +} +byte_register_info_type () +{ + char *p; + for (;;) + switch ((re_opcode_t) p++) + { + case no_op: + { + for (; (p);) + ; + for (;;) + ; + } + case jump: + (p) += 2; + } +} diff --git a/gcc/testsuite/gcc.dg/graphite/id-pr43351.c b/gcc/testsuite/gcc.dg/graphite/id-pr43351.c new file mode 100644 index 000000000..0590584c5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-pr43351.c @@ -0,0 +1,5 @@ +int foo(int i) +{ + if (i < 0) return 0; + for (; i < 10; i++); +} diff --git a/gcc/testsuite/gcc.dg/graphite/id-pr43464-1.c b/gcc/testsuite/gcc.dg/graphite/id-pr43464-1.c new file mode 100644 index 000000000..d5a835965 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-pr43464-1.c @@ -0,0 +1,18 @@ +typedef struct regnode +{ + char flags; +} regnode; +extern const unsigned char A[]; + +char *foo (regnode *c, char *s, int norun) +{ + int uskip; + while (s + (uskip = A[*s])) + { + if ((c->flags || bar (c)) && norun) + goto got_it; + s += uskip; + } + got_it: + return s; +} diff --git a/gcc/testsuite/gcc.dg/graphite/id-pr43464.c b/gcc/testsuite/gcc.dg/graphite/id-pr43464.c new file mode 100644 index 000000000..a8e67dc2b --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-pr43464.c @@ -0,0 +1,63 @@ +typedef struct sv SV; +typedef struct regnode +{ + char flags; +} regnode; +typedef struct regexp +{ +} regexp; +typedef struct cop +{ + SV *cop_warnings; +} COP; +extern const unsigned char PL_utf8skip[]; +extern char PL_dowarn; +extern COP *volatile PL_curcop; +char * +S_find_byclass (regexp * prog, regnode * c, char *s, char *strend, + char *startpos, int norun) +{ + register long unsigned int uskip; + char *e; + switch (((c)->flags)) + { + case 17: + { + while (s + (uskip = PL_utf8skip[*s]) <= strend) + { + if (c->flags || S_reginclass (c)) + if (norun || S_regtry (prog, s)) + goto got_it; + s += uskip; + } + unsigned long c, f; + long unsigned int len; + { + while (s <= e) + { + c = Perl_utf8n_to_uvuni (s, 13, &len, + (((PL_curcop->cop_warnings != + ((SV *) ((void *) 0))) + && PL_dowarn)) ? 0 : 0x00FF); + if (c == 0 && (norun || S_regtry (prog, s))) + if (f != c && (norun || S_regtry (prog, s))) + goto got_it; + } + } + } + } +got_it: + return s; +} +Perl_re_intuit_start (regexp * prog) +{ + S_find_byclass (prog, 0, 0, 0, 0, 1); +} +Perl_regexec_flags (register regexp * prog, + register char *strend) +{ + S_find_byclass (prog, 0, 0, strend, 0, 0); +} +S_regtry (regexp * prog, char *startpos) +{ +} diff --git a/gcc/testsuite/gcc.dg/graphite/id-pr44676.c b/gcc/testsuite/gcc.dg/graphite/id-pr44676.c new file mode 100644 index 000000000..65821edba --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-pr44676.c @@ -0,0 +1,12 @@ +/* { dg-options "-O2 -fgraphite-identity -fprofile-generate" } */ + +int +extend_options (int h, int map, int x, int y, int dx) +{ + while (dx--) + { + if (x != dx && y != -x) + map++; + } + return map; +} diff --git a/gcc/testsuite/gcc.dg/graphite/id-pr45230-1.c b/gcc/testsuite/gcc.dg/graphite/id-pr45230-1.c new file mode 100644 index 000000000..ba14fe557 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-pr45230-1.c @@ -0,0 +1,140 @@ +/* Copyright (C) 2002 Free Software Foundation. + + Test strncmp with various combinations of pointer alignments and lengths to + make sure any optimizations in the library are correct. + + Written by Michael Meissner, March 9, 2002. */ + +#include <string.h> +#include <stddef.h> + +#ifndef MAX_OFFSET +#define MAX_OFFSET (sizeof (long long)) +#endif + +#ifndef MAX_TEST +#define MAX_TEST (8 * sizeof (long long)) +#endif + +#ifndef MAX_EXTRA +#define MAX_EXTRA (sizeof (long long)) +#endif + +#define MAX_LENGTH (MAX_OFFSET + MAX_TEST + MAX_EXTRA) + +static union { + unsigned char buf[MAX_LENGTH]; + long long align_int; + long double align_fp; +} u1, u2; + +void +test (const unsigned char *s1, const unsigned char *s2, size_t len, int expected) +{ + int value = strncmp ((char *) s1, (char *) s2, len); + + if (expected < 0 && value >= 0) + __builtin_abort (); + else if (expected == 0 && value != 0) + __builtin_abort (); + else if (expected > 0 && value <= 0) + __builtin_abort (); +} + +main () +{ + size_t off1, off2, len, i; + unsigned char *buf1, *buf2; + unsigned char *mod1, *mod2; + unsigned char *p1, *p2; + + for (off1 = 0; off1 < MAX_OFFSET; off1++) + for (off2 = 0; off2 < MAX_OFFSET; off2++) + for (len = 0; len < MAX_TEST; len++) + { + p1 = u1.buf; + for (i = 0; i < off1; i++) + *p1++ = '\0'; + + buf1 = p1; + for (i = 0; i < len; i++) + *p1++ = 'a'; + + mod1 = p1; + for (i = 0; i < MAX_EXTRA; i++) + *p1++ = 'x'; + + p2 = u2.buf; + for (i = 0; i < off2; i++) + *p2++ = '\0'; + + buf2 = p2; + for (i = 0; i < len; i++) + *p2++ = 'a'; + + mod2 = p2; + for (i = 0; i < MAX_EXTRA; i++) + *p2++ = 'x'; + + mod1[0] = '\0'; + mod2[0] = '\0'; + test (buf1, buf2, MAX_LENGTH, 0); + test (buf1, buf2, len, 0); + + mod1[0] = 'a'; + mod1[1] = '\0'; + mod2[0] = '\0'; + test (buf1, buf2, MAX_LENGTH, +1); + test (buf1, buf2, len, 0); + + mod1[0] = '\0'; + mod2[0] = 'a'; + mod2[1] = '\0'; + test (buf1, buf2, MAX_LENGTH, -1); + test (buf1, buf2, len, 0); + + mod1[0] = 'b'; + mod1[1] = '\0'; + mod2[0] = 'c'; + mod2[1] = '\0'; + test (buf1, buf2, MAX_LENGTH, -1); + test (buf1, buf2, len, 0); + + mod1[0] = 'c'; + mod1[1] = '\0'; + mod2[0] = 'b'; + mod2[1] = '\0'; + test (buf1, buf2, MAX_LENGTH, +1); + test (buf1, buf2, len, 0); + + mod1[0] = 'b'; + mod1[1] = '\0'; + mod2[0] = (unsigned char)'\251'; + mod2[1] = '\0'; + test (buf1, buf2, MAX_LENGTH, -1); + test (buf1, buf2, len, 0); + + mod1[0] = (unsigned char)'\251'; + mod1[1] = '\0'; + mod2[0] = 'b'; + mod2[1] = '\0'; + test (buf1, buf2, MAX_LENGTH, +1); + test (buf1, buf2, len, 0); + + mod1[0] = (unsigned char)'\251'; + mod1[1] = '\0'; + mod2[0] = (unsigned char)'\252'; + mod2[1] = '\0'; + test (buf1, buf2, MAX_LENGTH, -1); + test (buf1, buf2, len, 0); + + mod1[0] = (unsigned char)'\252'; + mod1[1] = '\0'; + mod2[0] = (unsigned char)'\251'; + mod2[1] = '\0'; + test (buf1, buf2, MAX_LENGTH, +1); + test (buf1, buf2, len, 0); + } + + __builtin_exit (0); +} diff --git a/gcc/testsuite/gcc.dg/graphite/id-pr45230.c b/gcc/testsuite/gcc.dg/graphite/id-pr45230.c new file mode 100644 index 000000000..80f67697f --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-pr45230.c @@ -0,0 +1,14 @@ +unsigned char buf[10]; +main () +{ + unsigned off1, len, i; + unsigned char *p1; + for (len = 0; len < 8; len++) + { + p1 = buf; + for (i = 0; i < off1; i++) + *p1++ = '\0'; + for (i = 0; i < len; i++) + *p1++ = 'a'; + } +} diff --git a/gcc/testsuite/gcc.dg/graphite/id-pr45231.c b/gcc/testsuite/gcc.dg/graphite/id-pr45231.c new file mode 100644 index 000000000..01e9a672e --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-pr45231.c @@ -0,0 +1,37 @@ +void +f (n, ppt, xrot) +{ + int tileWidth; + int nlwSrc; + int srcx; + int v3, v4; + register unsigned long ca1, cx1, ca2, cx2; + unsigned long *pSrcLine; + register unsigned long *pDst; + register unsigned long *pSrc; + register unsigned long b, tmp; + unsigned long tileEndMask; + int v1, v2; + int tileEndPart; + int needFirst; + tileEndPart = 0; + v1 = tileEndPart << 5; + v2 = 32 - v1; + while (n--) + { + if ((srcx = (ppt - xrot) % tileWidth) < 0) + if (needFirst) + if (nlwSrc == 1) + { + tmp = b; + if (tileEndPart) + b = (*pSrc & tileEndMask) | (*pSrcLine >> v1); + } + if (tileEndPart) + b = (tmp << v1) | (b >> v2); + if (v4 != 32) + *pDst = (*pDst & ((tmp << v3) | (b >> v4) & ca1 ^ cx1) + ^ (((tmp << v3) | (b >> v4)) & ca2 ^ cx2)); + *pDst = *pDst & tmp; + } +} diff --git a/gcc/testsuite/gcc.dg/graphite/id-pr46834.c b/gcc/testsuite/gcc.dg/graphite/id-pr46834.c new file mode 100644 index 000000000..8d89b8e3c --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-pr46834.c @@ -0,0 +1,12 @@ +/* { dg-options "-O -fgraphite-identity -ffast-math -fno-tree-dce" } */ + +void foo () +{ + int M0[4][4], M3[4] = {}; + int i=-1; + int ii, jj; + for (; i; i++) + for (jj = 0; jj < 4; jj++) + for (ii = 0; ii < 4; ii++) + M3[1] += __builtin_abs (M0[ii][0]); +} diff --git a/gcc/testsuite/gcc.dg/graphite/id-pr46845.c b/gcc/testsuite/gcc.dg/graphite/id-pr46845.c new file mode 100644 index 000000000..f4da78eda --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/id-pr46845.c @@ -0,0 +1,17 @@ +/* { dg-options "-O2 -ffast-math -fgraphite-identity -w -Wno-psabi" { target { i?86-*-* x86_64-*-* } } } */ + +typedef float V2SF __attribute__ ((vector_size (128))); + +V2SF +foo (int x, V2SF a) +{ + V2SF b; + if (x & 42) + b = a; + else + b = a + (V2SF) {1.0f/0.0f - 1.0f/0.0f, 1.0f/0.0f - 1.0f/0.0f}; + while (x--) + a += b; + + return a; +} diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-0.c b/gcc/testsuite/gcc.dg/graphite/interchange-0.c new file mode 100644 index 000000000..8bc6e1326 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/interchange-0.c @@ -0,0 +1,50 @@ +/* { dg-require-effective-target size32plus } */ + +#define DEBUG 0 + +#if DEBUG +#include <stdio.h> +#endif + +#define N 1000 +int a[N][N]; + +static int __attribute__((noinline)) +foo (void) +{ + int j; + int i; + + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + a[j][i] = a[j][i] + 1; + + return a[N-1][N-1]; +} + +extern void abort (); + +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 + + if (res != 13) + abort (); + + return 0; +} + +/* { 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 new file mode 100644 index 000000000..b4559d132 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/interchange-1.c @@ -0,0 +1,53 @@ +/* { dg-require-effective-target size32plus } */ + +/* Formerly known as ltrans-1.c */ + +#define DEBUG 0 +#if DEBUG +#include <stdio.h> +#endif + +double u[1782225]; + +static int __attribute__((noinline)) +foo (int N) +{ + int i, j; + double sum = 0.0; + + /* These two loops should be interchanged. */ + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) + sum = sum + u[i + 1335 * j]; + + u[1336 * i] *= 2; + } + + return sum + N + u[1336 * 2] + u[1336]; +} + +extern void abort (); + +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 + + if (res != 3565793) + abort (); + + return 0; +} + +/* { 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-10.c b/gcc/testsuite/gcc.dg/graphite/interchange-10.c new file mode 100644 index 000000000..51a46d623 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/interchange-10.c @@ -0,0 +1,50 @@ +/* { dg-require-effective-target size32plus } */ + +#define DEBUG 0 +#if DEBUG +#include <stdio.h> +#endif + +double u[1782225]; + +static void __attribute__((noinline)) +foo (int N, int *res) +{ + int i, j; + double sum = 0.0; + + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + sum = sum + u[i + 1335 * j]; + + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + sum = sum + u[i + 1335 * j]; + + *res = sum + N + u[1336 * 2] + u[1336]; +} + +extern void abort (); + +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 + + if (res != 7130239) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "will be interchanged" 2 "graphite" } } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-11.c b/gcc/testsuite/gcc.dg/graphite/interchange-11.c new file mode 100644 index 000000000..491fda15c --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/interchange-11.c @@ -0,0 +1,50 @@ +/* { dg-require-effective-target size32plus } */ + +#define DEBUG 0 +#if DEBUG +#include <stdio.h> +#endif + +double u[1782225]; + +static void __attribute__((noinline)) +foo (int N, int *res) +{ + int i, j; + double sum = 0.0; + + /* These two loops should be interchanged. */ + for (i = 0; i < 1335; i++) + { + for (j = 0; j < 1335; j++) + sum = sum + u[i + 1335 * j]; + + u[1336 * i] *= 2; + } + *res = sum; +} + +extern void abort (); + +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 + + if (res != 3564450) + abort (); + + return 0; +} + +/* { 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-12.c b/gcc/testsuite/gcc.dg/graphite/interchange-12.c new file mode 100644 index 000000000..fc27b4c53 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/interchange-12.c @@ -0,0 +1,57 @@ +/* { 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; + + /* Loops J and K should be interchanged. */ + 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]; +} + +extern void abort (); + +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 + + if (res != 2626800) + abort (); + + return 0; +} + +/* { 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-13.c b/gcc/testsuite/gcc.dg/graphite/interchange-13.c new file mode 100644 index 000000000..a8bf23be5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/interchange-13.c @@ -0,0 +1,54 @@ +/* { dg-require-effective-target size32plus } */ + +/* Formerly known as ltrans-1.c */ + +#define DEBUG 0 +#if DEBUG +#include <stdio.h> +#endif + +double u[25]; + +static int __attribute__((noinline)) +foo (int N) +{ + int i, j; + double sum = 0.0; + + /* These two loops should be interchanged. */ + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) + sum = sum + u[i + 5 * j]; + + u[6 * i] *= 2; + } + + return sum + N + u[6]; +} + +extern void abort (); + +int +main (void) +{ + int i, j, res; + + for (i = 0; i < 25; i++) + u[i] = 2; + + res = foo (5); + +#if DEBUG + fprintf (stderr, "res = %d \n", res); +#endif + + if (res != 59) + abort (); + + return 0; +} + + +/* { 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-14.c b/gcc/testsuite/gcc.dg/graphite/interchange-14.c new file mode 100644 index 000000000..53809b54d --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/interchange-14.c @@ -0,0 +1,58 @@ +/* { 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; + + /* Loops J and K should be interchanged. */ + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + for (k = 0; k < N; k++) + A[i][j] += B[i][k] * C[k][j]; +} + +extern void abort (); + +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 + + if (res != 529340000) + abort (); + + return 0; +} + +/* { 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-15.c b/gcc/testsuite/gcc.dg/graphite/interchange-15.c new file mode 100644 index 000000000..9eeef6617 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/interchange-15.c @@ -0,0 +1,53 @@ +/* { dg-require-effective-target size32plus } */ + +#define DEBUG 0 +#if DEBUG +#include <stdio.h> +#endif + +#define NMAX 2000 + +static int x[NMAX], a[NMAX][NMAX]; + +static int __attribute__((noinline)) +mvt (long N) +{ + int i,j; + + /* These two loops should be interchanged. */ + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + x[i] += a[j][i]; + + return x[1]; +} + +extern void abort (); + +int +main (void) +{ + int i, j, res; + + for (i = 0; i < NMAX; i++) + for (j = 0; j < NMAX; j++) + a[i][j] = j; + + for (i = 0; i < NMAX; i++) + x[i] = i; + + res = mvt (NMAX); + +#if DEBUG + fprintf (stderr, "res = %d \n", res); +#endif + + if (res != 2001) + abort (); + + return 0; +} + +/* { 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-2.c b/gcc/testsuite/gcc.dg/graphite/interchange-2.c new file mode 100644 index 000000000..2609a10eb --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/interchange-2.c @@ -0,0 +1,56 @@ +/* { dg-require-effective-target size32plus } */ + +/* Formerly known as ltrans-2.c */ + +#define DEBUG 0 +#if DEBUG +#include <stdio.h> +#endif + +double u[1782225]; + +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++) + { + for (j = 0; j < N; j++) + { + sum = sum + u[i + 1335 * j]; + if (j == N - 1) + u[1336 * i] *= 2; + } + } + + *res = sum + N + u[1336 * 2] + u[1336]; +} + +extern void abort (); + +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 + + if (res != 3565793) + abort (); + + return 0; +} + +/* { 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-3.c b/gcc/testsuite/gcc.dg/graphite/interchange-3.c new file mode 100644 index 000000000..26ec4d9d5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/interchange-3.c @@ -0,0 +1,51 @@ +/* { dg-require-effective-target size32plus } */ + +/* Formerly known as ltrans-3.c */ + +#define DEBUG 0 +#if DEBUG +#include <stdio.h> +#endif + +double u[1782225]; + +static void __attribute__((noinline)) +foo (int N, int *res) +{ + unsigned int i, j; + double sum = 0; + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) + { + sum = sum + u[i + 1335 * j]; + } + } + + *res = sum + N + u[1336 * 2] + u[1336]; +} + +extern void abort (); + +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 + + if (res != 3565789) + abort (); + + return 0; +} + +/* { 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-4.c b/gcc/testsuite/gcc.dg/graphite/interchange-4.c new file mode 100644 index 000000000..f86391c7f --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/interchange-4.c @@ -0,0 +1,50 @@ +/* { dg-require-effective-target size32plus } */ + +/* Formerly known as ltrans-4.c */ + +#define DEBUG 0 +#if DEBUG +#include <stdio.h> +#endif + +double u[1782225]; + +static int __attribute__((noinline)) +foo (int N, int *res) +{ + int i, j; + double sum = 0; + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + sum = sum + u[i + 1335 * j]; + + for (i = 0; i < N; i++) + u[1336 * i] *= 2; + + *res = sum + N + u[1336 * 2] + u[1336]; +} + +extern void abort (); + +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 + + if (res != 3565793) + abort (); + + return 0; +} + +/* { 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-5.c b/gcc/testsuite/gcc.dg/graphite/interchange-5.c new file mode 100644 index 000000000..1fbc8e6ec --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/interchange-5.c @@ -0,0 +1,50 @@ +/* { dg-require-effective-target size32plus } */ + +/* Formerly known as ltrans-5.c */ + +#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 i, j; + + for( i = 0; i < M; i++) + for( j = 0; j < N; j++) + A[j][i] = 5 * A[j][i]; + + return A[0][0] + A[N-1][M-1]; +} + +extern void abort (); + +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 + + if (res != 20) + abort (); + + return 0; +} + +/* { 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 new file mode 100644 index 000000000..9e189050e --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/interchange-6.c @@ -0,0 +1,51 @@ +/* { dg-require-effective-target size32plus } */ + +/* Formerly known as ltrans-6.c */ + +#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; + + /* This loop should be interchanged. */ + for(j = 0; j < M; j++) + for(i = 0; i < N; i++) + A[i][j] = A[i][j] + A[i][j]; + + return A[0][0] + A[N-1][M-1]; +} + +extern void abort (); + +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 + + if (res != 8) + abort (); + + return 0; +} + +/* { 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-7.c b/gcc/testsuite/gcc.dg/graphite/interchange-7.c new file mode 100644 index 000000000..b3710ad4c --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/interchange-7.c @@ -0,0 +1,50 @@ +/* { dg-require-effective-target size32plus } */ + +/* Formerly known as ltrans-8.c */ + +#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; + int r = 0; + + for (i = 0; i < N; ++i) + for (j = 0; j < M; ++j) + r += a[j * N + i]; + + return r; +} + +extern void abort (); + +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 + + if (res != 246642) + abort (); + + return 0; +} + +/* { 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 new file mode 100644 index 000000000..ca99dbc13 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/interchange-8.c @@ -0,0 +1,86 @@ +#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; + + /* Loops (L, J) are interchanged, and then loops (J and K) are + interchanged. The result is a nest starting with (K, J, L). */ + for (l = 0; l < 4; l++) + { + for (k = 0; k < 4; k++) + { + for (j = 0; j < 4; j++) + { + for (i = 0; i < 2; i++) + { + B[i] = A[i][k][j][l] + A[3 - i][k][j][l]; + B[3 - i] = A[i][k][j][l] - A[3 - i][k][j][l]; + } + A[0][k][j][l] = B[0] + B[1]; + A[2][k][j][l] = B[0] - B[1]; + A[1][k][j][l] = B[3] + B[2]; + A[3][k][j][l] = B[3] - B[2]; + } + + for (i = 0; i < 4; i++) + { + for (j = 0; j < 2; j++) + { + B[j] = A[i][k][j][l] + A[i][k][3 - j][l]; + B[3 - j] = A[i][k][j][l] - A[i][k][3 - j][l]; + } + A[i][k][0][l] = B[0] + B[1]; + A[i][k][2][l] = B[0] - B[1]; + A[i][k][1][l] = B[3] + B[2]; + A[i][k][3][l] = B[3] - B[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]; +} + +extern void abort (); + +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 + + if (res != 424) + abort (); + + return 0; +} + +/* { dg-final { scan-tree-dump-times "will be interchanged" 2 "graphite" } } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/interchange-9.c b/gcc/testsuite/gcc.dg/graphite/interchange-9.c new file mode 100644 index 000000000..3f8e843ea --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/interchange-9.c @@ -0,0 +1,48 @@ +/* { dg-require-effective-target size32plus } */ + +#define DEBUG 0 +#if DEBUG +#include <stdio.h> +#endif + +#define N 111 +#define M 111 + +static int __attribute__((noinline)) +foo (int *x) +{ + int i, j; + int sum = 0; + + for (j = 0; j < M; ++j) + for (i = 0; i < N; ++i) + sum += x[M * i + j]; + + return sum; +} + +extern void abort (); + +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 + + if (res != 24642) + abort (); + + return 0; +} + +/* { 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 new file mode 100644 index 000000000..ee262e9f7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/interchange-mvt.c @@ -0,0 +1,63 @@ +/* { dg-require-effective-target size32plus } */ + +#define DEBUG 0 +#if DEBUG +#include <stdio.h> +#endif + +#define NMAX 2000 + +static int x1[NMAX], x2[NMAX], a[NMAX][NMAX], y1[NMAX], y2[NMAX]; + +static int __attribute__((noinline)) +mvt (long N) +{ + + int i,j; + + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + x1[i] = x1[i] + a[i][j] * y1[j]; + + /* These two loops should be interchanged. */ + 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]; +} + +extern void abort (); + +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 + + if (res != 199900000) + abort (); + + return 0; +} + +/* { 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/pr18792.c b/gcc/testsuite/gcc.dg/graphite/pr18792.c new file mode 100644 index 000000000..4e93fe145 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr18792.c @@ -0,0 +1,16 @@ +/* PR tree-optimization/18792 */ +/* { dg-do compile } */ +/* { dg-options "-O1 -ftree-loop-linear" } */ +void put_atoms_in_triclinic_unitcell(float x[][3]) +{ + int i=0,d; + + while (x[i][3] < 0) + for (d=0; d<=3; d++) + x[i][d] = 0; + + while (x[i][3] >= 0) + for (d=0; d<=3; d++) + x[i][d] = 0; + +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr19910.c b/gcc/testsuite/gcc.dg/graphite/pr19910.c new file mode 100644 index 000000000..1ee0d213b --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr19910.c @@ -0,0 +1,16 @@ +/* Contributed by Volker Reichelt <reichelt@gcc.gnu.org>. */ + +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-loop-linear" } */ + +int a[3]; + +void foo() +{ + int i, j; + + for (i = 1; i >= 0; --i) + for (j = i; j >= 0; --j) + a[i+j] = 0; +} + diff --git a/gcc/testsuite/gcc.dg/graphite/pr20041110-1.c b/gcc/testsuite/gcc.dg/graphite/pr20041110-1.c new file mode 100644 index 000000000..825b2b41f --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr20041110-1.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-loop-linear" } */ + +/* This testcase was causing an ICE in building distance vectors because + we weren't ignoring the fact that one of the induction variables + involved in the dependence was outside of the loop. */ +extern int foo (int, int); +int +main (void) +{ + int a[50]; + int b[50]; + int i, j, k; + for (i = 4; i < 30; i++) + { + for (j = 3; j < 40; j++) + { + for (k = 9; k < 50; k++) + { + b[j] = a[i]; + a[k] = b[i]; + } + } + } + foo (a[i], b[i]); +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr20256.c b/gcc/testsuite/gcc.dg/graphite/pr20256.c new file mode 100644 index 000000000..29c8ebd14 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr20256.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-loop-linear" } */ +/* { dg-require-effective-target size32plus } */ + +int foo() +{ + int x[2][2], y[2]; + int i, n, s; + + /* This is a reduction: there is a scalar dependence that cannot be + removed by rewriting IVs. This code cannot and should not be + transformed into a perfect loop. */ + for (n = 0; n < 2; n++) + { + s = 0; + for (i = 0; i < 2; i++) + s += x[n][i]*y[i]; + s += 1; + } + + return s; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr23625.c b/gcc/testsuite/gcc.dg/graphite/pr23625.c new file mode 100644 index 000000000..aaeddb288 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr23625.c @@ -0,0 +1,27 @@ +/* Test case for PR23625 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-vectorize -ftree-loop-linear" } */ + +typedef long INT32; +void find_best_colors () +{ +int ic0, ic1, ic2; +INT32 * bptr; +INT32 dist1; +INT32 dist2; +INT32 xx1; +for (ic0 = (1<<(5 -3))-1;ic0 >= 0;ic0--) +{ + for (ic1 = (1<<(6 -3))-1;ic1 >= 0;ic1--) + { + dist2 = dist1; + for (ic2 = (1<<(5 -3))-1;ic2 >= 0;ic2--) + { + *bptr = dist2; + bptr++; + } + dist1 += xx1; + } +} +} + diff --git a/gcc/testsuite/gcc.dg/graphite/pr23820.c b/gcc/testsuite/gcc.dg/graphite/pr23820.c new file mode 100644 index 000000000..ee855e139 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr23820.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-loop-linear" } */ + +int t [2][4]; + +void foo (void) +{ + int i, j, k, v; + float e; + for (;;) + { + v = 0; + for (j = 0; j < 2; j ++) + { + for (k = 2; k < 4; k ++) + { + e = 0.0; + for (i = 0; i < 4; i ++) + e += t [j][i]; + if (e) + v = j; + } + } + t [v][0] = 0; + } +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr24309.c b/gcc/testsuite/gcc.dg/graphite/pr24309.c new file mode 100644 index 000000000..b50e7a8ca --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr24309.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-loop-linear" } */ + +float weight[10]; +void lsp_weight_quant(float *x, char *cdbk) +{ + int i,j; + float dist; + int best_id=0; + for (i=0;i<16;i++) + { + for (j=0;j<10;j++) + dist=dist+weight[j]; + if (dist<0) + best_id=i; + } + x[j] = cdbk[best_id*10+j]; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr26435.c b/gcc/testsuite/gcc.dg/graphite/pr26435.c new file mode 100644 index 000000000..4e5e5f74d --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr26435.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-loop-linear" } */ +/* { dg-require-effective-target size32plus } */ + +int foo(int *p, int n) +{ + int i, j, k = 0; + + /* This is a reduction: there is a scalar dependence that cannot be + removed by rewriting IVs. This code cannot and should not be + transformed into a perfect loop. */ + for (i = 0; i < 2; ++i, p += n) + for (j = 0; j < 2; ++j) + k += p[j]; + + return k; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr29330.c b/gcc/testsuite/gcc.dg/graphite/pr29330.c new file mode 100644 index 000000000..dff420779 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr29330.c @@ -0,0 +1,15 @@ +/* PR tree-optimization/29330 */ +/* { dg-do compile } */ +/* { dg-options "-O -ftree-loop-linear -std=gnu99" } */ + +int buf[2][2][2][2]; + +void +f (void) +{ + for (int a = 0; a < 2; ++a) + for (int b = 0; b < 2; ++b) + for (int c = 0; c < 2; ++c) + for (int d = 0; d < 2; ++d) + buf[a][b][c][d] = 0; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr29581-1.c b/gcc/testsuite/gcc.dg/graphite/pr29581-1.c new file mode 100644 index 000000000..e54007355 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr29581-1.c @@ -0,0 +1,44 @@ +/* PR tree-optimization/29581 */ +/* Origin: gcc.dg/vect/vect-85.c */ +/* { dg-do run } */ +/* { dg-options "-O2 -ftree-loop-linear" } */ + +extern void abort (void); + +#define N 16 + +int main1 (int *a) +{ + int i, j, k; + int b[N]; + + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) + { + k = i + N; + a[j] = k; + } + b[i] = k; + } + + + for (j = 0; j < N; j++) + if (a[j] != i + N - 1) + abort(); + + for (j = 0; j < N; j++) + if (b[j] != j + N) + abort(); + + return 0; +} + +int main (void) +{ + int a[N] __attribute__ ((__aligned__(16))); + + main1 (a); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr29581-2.c b/gcc/testsuite/gcc.dg/graphite/pr29581-2.c new file mode 100644 index 000000000..c99d78ce2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr29581-2.c @@ -0,0 +1,46 @@ +/* PR tree-optimization/29581 */ +/* Origin: gcc.dg/vect/vect-86.c */ +/* { dg-do run } */ +/* { dg-options "-O2 -ftree-loop-linear" } */ + +extern void abort (void); + +#define N 16 + +int main1 (int n) +{ + int i, j, k; + int a[N], b[N]; + + for (i = 0; i < n; i++) + { + for (j = 0; j < n; j++) + { + k = i + n; + a[j] = k; + } + b[i] = k; + } + + + for (j = 0; j < n; j++) + if (a[j] != i + n - 1) + abort(); + + for (i = 0; i < n; i++) + if (b[i] != i + n) + abort(); + + return 0; +} + +int main (void) +{ + main1 (N); + main1 (0); + main1 (1); + main1 (2); + main1 (N-1); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr29581-3.c b/gcc/testsuite/gcc.dg/graphite/pr29581-3.c new file mode 100644 index 000000000..c9d72ce28 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr29581-3.c @@ -0,0 +1,48 @@ +/* PR tree-optimization/29581 */ +/* Origin: gcc.dg/vect/vect-87.c */ +/* { dg-do run } */ +/* { dg-options "-O2 -ftree-loop-linear" } */ + +extern void abort (void); + +#define N 16 + +int main1 (int n, int *a) +{ + int i, j, k; + int b[N]; + + for (i = 0; i < n; i++) + { + for (j = 0; j < n; j++) + { + k = i + n; + a[j] = k; + } + b[i] = k; + } + + + for (j = 0; j < n; j++) + if (a[j] != i + n - 1) + abort(); + + for (j = 0; j < n; j++) + if (b[j] != j + n) + abort(); + + return 0; +} + +int main (void) +{ + int a[N] __attribute__ ((__aligned__(16))); + + main1 (N, a); + main1 (0, a); + main1 (1, a); + main1 (2, a); + main1 (N-1, a); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr29581-4.c b/gcc/testsuite/gcc.dg/graphite/pr29581-4.c new file mode 100644 index 000000000..c2d894c8d --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr29581-4.c @@ -0,0 +1,48 @@ +/* PR tree-optimization/29581 */ +/* Origin: gcc.dg/vect/vect-88.c */ +/* { dg-do run } */ +/* { dg-options "-O2 -ftree-loop-linear" } */ + +extern void abort (void); + +#define N 16 + +int main1 (int n, int *a) +{ + int i, j, k; + int b[N]; + + for (i = 0; i < n; i++) + { + for (j = 0; j < n; j++) + { + k = i + n; + a[j] = k; + } + b[i] = k; + } + + + for (j = 0; j < n; j++) + if (a[j] != i + n - 1) + abort(); + + for (j = 0; j < n; j++) + if (b[j] != j + n) + abort(); + + return 0; +} + +int main (void) +{ + int a[N+1] __attribute__ ((__aligned__(16))); + + main1 (N, a+1); + main1 (0, a+1); + main1 (1, a+1); + main1 (2, a+1); + main1 (N-1, a+1); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr30565.c b/gcc/testsuite/gcc.dg/graphite/pr30565.c new file mode 100644 index 000000000..802b7c2aa --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr30565.c @@ -0,0 +1,14 @@ +/* PR tree-optimization/30565 */ + +/* { dg-do compile } */ +/* { dg-options "-O1 -ftree-pre -ftree-loop-linear" } */ + +static double snrdef[32]; +void psycho_n1(double ltmin[2][32], int stereo) +{ + int i, k; + + for (k = 0; k < stereo; k++) + for (i = 0; i < 32; i++) + ltmin[k][i] = snrdef[i]; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr31183.c b/gcc/testsuite/gcc.dg/graphite/pr31183.c new file mode 100644 index 000000000..000d7b5bf --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr31183.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-loop-linear" } */ + +int buf[256 * 9]; +int f() +{ + int i, j; + + for (i = 0; i < 256; ++i) + for (j = 0; j < 8; ++j) + buf[j + 1] = buf[j] + 1; + + return buf[10]; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr33576.c b/gcc/testsuite/gcc.dg/graphite/pr33576.c new file mode 100644 index 000000000..2470762f7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr33576.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-loop-linear" } */ + +int a1[6][4][4]; +short b1[16]; + +int c1; +void CalculateQuantParam(void) +{ + int i, j, k, temp; + + for(k=0; k<6; k++) + for(j=0; j<4; j++) + for(i=0; i<4; i++) + { + temp = (i<<2)+j; + a1[k][j][i] = c1/b1[temp]; + } +} + diff --git a/gcc/testsuite/gcc.dg/graphite/pr33766.c b/gcc/testsuite/gcc.dg/graphite/pr33766.c new file mode 100644 index 000000000..f6bb50615 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr33766.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-loop-linear" } */ + +float +fxt1_quantize_ALPHA1() +{ + int j1; + int i; + float *tv; + for (j1 = 1; j1; j1++) { + float e; + for (i = 1; i; i++) + e = tv[i]; + if (e) + i = j1; + } + return tv[i]; +} + diff --git a/gcc/testsuite/gcc.dg/graphite/pr34016.c b/gcc/testsuite/gcc.dg/graphite/pr34016.c new file mode 100644 index 000000000..5ca84bb62 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr34016.c @@ -0,0 +1,19 @@ +/* PR tree-optimization/34016 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-loop-linear" } */ + +extern void bar (double *); + +void foo (void) +{ + double gr[36]; + int i, j; + for (i = 0; i <= 5; i++) + { + for (j = 0; j <= 5; j++) + gr[i + j * 6] = 0.0; + if (i <= 2) + gr[i + i * 6] = 1.0; + } + bar (gr); +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr34017.c b/gcc/testsuite/gcc.dg/graphite/pr34017.c new file mode 100644 index 000000000..ee279b7c8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr34017.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-loop-linear" } */ + +extern int s; + +void +foo (int *x, int y, int z) +{ + int m, n; + int o; + int p = x[0]; + o = s; + for (m = 0; m < s; m++) + for (n = 0; n < s; n++) + { + if (x[n] != p) + continue; + if (m > z) + z = m; + if (n < o) + o = n; + } + for (m = y; m <= z; m++) + { + } +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr34123.c b/gcc/testsuite/gcc.dg/graphite/pr34123.c new file mode 100644 index 000000000..81dbf3aac --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr34123.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -ftree-loop-linear" } */ + +/* Testcase by Martin Michlmayr <tbm@cyrius.com> */ + +static unsigned char sbox[256] = { +}; +void MD2Transform (unsigned char state[16]) +{ + unsigned char t = 0; + int i, j; + for (i = 0; i < 16; i++) + { + for (j = 0; j < 2; j++) + t = (state[j] ^= sbox[t]); + t += i; + } +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr35356-1.c b/gcc/testsuite/gcc.dg/graphite/pr35356-1.c new file mode 100644 index 000000000..2ba0c1b0f --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr35356-1.c @@ -0,0 +1,26 @@ +/* { dg-options "-O2 -fgraphite-identity -fdump-tree-graphite-all" } */ + +int a[100]; + +int +foo (int bar, int n, int k) +{ + int i; + + for (i = 0; i < n; i++) + if (i == k) + a[i] = bar; + + return a[bar]; +} + +/* There should be no loops generated for this testcase, instead we + should generate the following: + + | if (k >= 0 && k < n) + | a[k] = bar; + +*/ + +/* { dg-final { scan-tree-dump-times "loop_1" 0 "graphite" } } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/pr35356-2.c b/gcc/testsuite/gcc.dg/graphite/pr35356-2.c new file mode 100644 index 000000000..66cfdea5a --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr35356-2.c @@ -0,0 +1,44 @@ +/* { dg-options "-O2 -fgraphite-identity -fdump-tree-graphite-all" } */ + +int a[100]; + +int +foo (int bar, int n, int k) +{ + int i; + + for (i = 0; i < n; i++) + if (i == k) + a[i] = 1; + else + a[i] = i; + + return a[bar]; +} + +/* We should generate the following: + + | for (i = 0; i < min (n, k); i++) + | a[i] = i; + | if (k >= 0 && k < n) + | a[k] = 1; + | for (i = max(k+1,0); i < n; i++) + | a[i] = i; + + XXX: At the moment we generate to protect loops that are executed zero times. + + | if (0 < min (n, k) + 1) + | for (i = 0; i < min (n, k); i++) + | a[i] = i; + | if (k >= 0 && k < n) + | a[k] = 1; + | if (0 < max(n, k) + 1) + | for (i = max(k+1,0); i < n; i++) + | a[i] = i; + +*/ + + +/* { dg-final { scan-tree-dump-times "MIN_EXPR" 4 "graphite" } } */ +/* { dg-final { scan-tree-dump-times "MAX_EXPR" 4 "graphite" } } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/pr35356-3.c b/gcc/testsuite/gcc.dg/graphite/pr35356-3.c new file mode 100644 index 000000000..55a771aff --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr35356-3.c @@ -0,0 +1,40 @@ +/* { dg-options "-O2 -fgraphite-identity -fdump-tree-graphite-all" } */ + + +int winner, numf2s; +double **tds; +double d, tsum; + +typedef struct { + double y; +} xyz; + +xyz *Y; +int ti; + +double +match (void) +{ + int tj, tresult; + + for (tj = 0; tj < numf2s; tj++) + if (tj == winner + && Y[tj].y > 0) + tsum += tds[ti][tj] * d; + + return tsum; +} + +/* There should be no loops generated for this testcase, instead we + should generate the following: + + | if (winner >= 0 && winner < numf2s && Y[winner].y > 0) + | tsum += tds[ti][winner] * d; + + For the moment this is XFAILed as this loop is not detected as a + SCoP by graphite: we depend on data in one of the conditions, + "Y[winner].y > 0". This could be fixed when we will use predicates + for such cases. */ + +/* { dg-final { scan-tree-dump-times "loop_1" 0 "graphite" { xfail *-*-* } } } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/pr36287.c b/gcc/testsuite/gcc.dg/graphite/pr36287.c new file mode 100644 index 000000000..51b77c715 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr36287.c @@ -0,0 +1,22 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ftree-loop-linear" } */ + +int tab[2][2]; + +int foo () +{ + int i, j, k; + + for (i = 0; i < 2; ++i) + for (j = 0; j < 2; ++j) + for (k = 0; k < 2; ++k) + {} + + for (i = 0; i < 2; ++i) + for (j = 0; j < 2; ++j) + if (i == 0) + tab[i][j] = 0; + + return tab[0][1]; +} + diff --git a/gcc/testsuite/gcc.dg/graphite/pr37485.c b/gcc/testsuite/gcc.dg/graphite/pr37485.c new file mode 100644 index 000000000..7432aaa2a --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr37485.c @@ -0,0 +1,32 @@ +/* { dg-options "-O2 -floop-block -fno-loop-strip-mine -fno-loop-interchange -ffast-math -fdump-tree-graphite-all" } */ + +typedef unsigned char UChar; +typedef int Int32; +typedef unsigned int UInt32; + +void fallbackSort ( UInt32* fmap, + UInt32* eclass, + Int32 nblock, + Int32 verb ) +{ + Int32 ftab[257]; + Int32 ftabCopy[256]; + Int32 H, i, j, k, l, r, cc, cc1; + Int32 nNotDone; + Int32 nBhtab; + UChar* eclass8 = (UChar*)eclass; + + if (verb >= 4) + VPrintf0 ( " bucket sorting ...\n" ); + for (i = 0; i < 257; i++) ftab[i] = 0; + for (i = 0; i < nblock; i++) ftab[eclass8[i]]++; + for (i = 0; i < 256; i++) ftabCopy[i] = ftab[i]; + for (i = 1; i < 257; i++) ftab[i] += ftab[i-1]; + + for (i = 0; i < nblock; i++) { + j = eclass8[i] + ftab [i]; + } + AssertH ( j < 256, 1005 ); +} +/* { dg-final { scan-tree-dump-times "Loop blocked" 1 "graphite" { xfail *-*-* }} } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/pr37684.c b/gcc/testsuite/gcc.dg/graphite/pr37684.c new file mode 100644 index 000000000..ab5a68533 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr37684.c @@ -0,0 +1,67 @@ +/* { dg-options "-O2 -fdump-tree-graphite-all" } */ + +typedef struct _IO_FILE FILE; +struct _IO_marker { +}; +enum __codecvt_result +{ + __codecvt_noconv +}; +struct _IO_FILE { +}; +extern struct _IO_FILE *stderr; + +typedef + struct { + unsigned int avail_in; + unsigned int avail_out; + void *state; + void *(*bzalloc)(void *,int,int); + void *opaque; + } + bz_stream; +extern int BZ2_bzCompressInit ( + bz_stream* strm, + int blockSize100k, + int verbosity, + int workFactor + ); +typedef unsigned char Bool; +typedef int Int32; +typedef unsigned int UInt32; + +typedef + struct { + Int32 mode; + Int32 state; + UInt32* arr1; + UInt32* arr2; + UInt32* ftab; + Int32 nblock; + Int32 nblockMAX; + Bool inUse[256]; + Int32 blockNo; + } + EState; + +void prepare_new_block ( EState* s ) +{ + Int32 i; + for (i = 0; i < 256; i++) s->inUse[i] = ((Bool)0); + s->blockNo++; +} + +int BZ2_bzCompressInit + ( bz_stream* strm, + int blockSize100k, + int verbosity, + int workFactor ) +{ + EState* s; + s = (strm->bzalloc)(strm->opaque,(sizeof(EState)),1); + if (s->arr1 == ((void *)0) || s->arr2 == ((void *)0) || s->ftab == ((void *)0)) { + } + prepare_new_block ( s ); +} + +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/pr37686.c b/gcc/testsuite/gcc.dg/graphite/pr37686.c new file mode 100644 index 000000000..a5094bf97 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr37686.c @@ -0,0 +1,48 @@ +/* { dg-do compile { target powerpc*-*-* } } */ +/* { dg-options "-O3 -ftree-loop-linear" } */ + +unsigned char inUse[256]; +unsigned char len[6][258]; +int code[6][258]; +unsigned int crc32Table[256] = { }; + unsigned int getGlobalCRC (void) { } + int bsLive; +void bsW (int n, unsigned int v) { + while (bsLive >= 8) {} + } + void hbAssignCodes (int * code, unsigned char * length, int minLen, +int maxLen, int alphaSize) { + int n, vec, i; + for (n = minLen;n <= maxLen;n++) + for (i = 0; i < alphaSize;i++) + code[i] = vec; + } + void sendMTFValues (void) { + int v, t, i, j, gs, ge, totc, bt, bc, iter; + int nSelectors, alphaSize, minLen, maxLen, selCtr; + int nGroups, nBytes; + { + while (1) + { + break; + } + hbAssignCodes (&code[t][0], &len[t][0], minLen, maxLen, alphaSize); + unsigned char inUse16[16]; + for (i = 0;i < 16;i++) + if (inUse16[i]) + { + for (j = 0;j < 16;j++) + if (inUse[i * 16 + j]) { } + } + } + for (i = 0; i < nSelectors;i++) { } + for (t = 0; t < nGroups;t++) + { + int curr = len[t][0]; + for (i = 0; i < alphaSize;i++) + while (curr < len[t][i]) { } + } + while (1) + for (i = gs; i <= ge;i++) { } + } + diff --git a/gcc/testsuite/gcc.dg/graphite/pr37828.c b/gcc/testsuite/gcc.dg/graphite/pr37828.c new file mode 100644 index 000000000..df0ef7c0a --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr37828.c @@ -0,0 +1,25 @@ +/* { dg-options "-O2" } */ + +typedef struct foo +{ + struct foo **Node; +} foo; + +static int sort_and_split (foo **Root, foo **Finite, long first) +{ + foo *cd; + long i; + for (i = 0; i < first; i++) + cd->Node[i] = Finite[first+i]; + + sort_and_split(Root, Finite, first); + return (0); +} + + +void Build_foo(foo **Root, foo **Finite, foo **Infinite) +{ + long low, high; + while (sort_and_split(Root, Finite, low) == 0); +} + diff --git a/gcc/testsuite/gcc.dg/graphite/pr37883.c b/gcc/testsuite/gcc.dg/graphite/pr37883.c new file mode 100644 index 000000000..9b386561c --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr37883.c @@ -0,0 +1,11 @@ +/* { dg-options "-O3" } */ + +void test_sort() +{ + char *base; + register char c, *i, *hi; + + for (i = base; i < hi; i++) + *i++ = c; +} + diff --git a/gcc/testsuite/gcc.dg/graphite/pr37928.c b/gcc/testsuite/gcc.dg/graphite/pr37928.c new file mode 100644 index 000000000..3c33f3a46 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr37928.c @@ -0,0 +1,33 @@ +/* { dg-options "-O3" } */ + +int get_state(int size, int *node, int *hash) +{ + int i=0; + while(hash[i]) + { + if(node[hash[i]] == 0) + return hash[i]-1; + i++; + if(i==5) + i=0; + } + return -1; +} + +void foo (int); + +int gate1(int size, int *node, int *hash) +{ + int i, j ; + int add_size=0; + for(i=0; i<size; i++) + { + j = get_state(size,node, hash); + if(j == -1) + { + add_size++; + } + } + + foo (size+add_size); +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr37943.c b/gcc/testsuite/gcc.dg/graphite/pr37943.c new file mode 100644 index 000000000..4513d12c0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr37943.c @@ -0,0 +1,33 @@ +/* { dg-options "-O3 -fgraphite-identity -fdump-tree-graphite-all" } */ + +typedef struct +{ + int mode,state,num,state_out; + unsigned char* bits; + char *out; +}test; +unsigned char copy( test* s ) +{ + while(1) + { + if (s->mode == 0) break; + if (s->state_out >= s->num) break; + *(s->out) = s->bits[s->state_out]; + if (s->mode == 0) s->mode++; + } +} +unsigned char compress(test *in) +{ + unsigned char p_in, p_out; + while(1) + { + if (in->state == 1) + { + p_out |= copy(in); + if (in->state_out < in->num) break; + } + } + return p_in || p_out; +} +/* { dg-final { cleanup-tree-dump "graphite" } } */ + diff --git a/gcc/testsuite/gcc.dg/graphite/pr38073.c b/gcc/testsuite/gcc.dg/graphite/pr38073.c new file mode 100644 index 000000000..9c48d8d09 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr38073.c @@ -0,0 +1,9 @@ +/* { dg-options "-O3 -fgraphite-identity" } */ + +test_seg(int a, int b) +{ + int i,r=1; + for(i=0; i<b ;i++) + r*=a; + return r; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr38084.c b/gcc/testsuite/gcc.dg/graphite/pr38084.c new file mode 100644 index 000000000..7193f9600 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr38084.c @@ -0,0 +1,31 @@ +/* { dg-options "-O3 -fgraphite-identity" } */ + +typedef struct { + unsigned int avail_out; + void *state; +} stream; + +typedef struct { + stream* test; + int num; +} state_in; + +int test_in ( stream *test, int action ) +{ + state_in* tst; + if (test == ((void *)0)) return (-2); + if (tst == ((void *)0)) return (-2); + if (tst->test != test) return (-2); + jump_here: + switch (tst->num) { + case 1: + return (-1); + case 2: + if (action == 0) { + } + if (action == 1) { + goto jump_here; + } + } + return 0; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr38125.c b/gcc/testsuite/gcc.dg/graphite/pr38125.c new file mode 100644 index 000000000..780e6f643 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr38125.c @@ -0,0 +1,32 @@ +/* { dg-options "-O3 -fgraphite-identity" } */ + +typedef struct sv TEST_SV; +typedef struct av TEST_AV; +typedef struct magic TEST_MAGIC; +typedef struct xpvav TEST_XPVAV; +struct sv +{ + void* sv_any; +}; +struct av +{ + TEST_XPVAV* sv_any; +}; +struct xpvav +{ + char* xav_array; + long int xav_fill; + long int xav_max; +}; +struct magic { + TEST_SV* mg_obj; +}; +extern TEST_SV PL_sv_undef; +Perl_av_fill( register TEST_AV *av, int fill) +{ + TEST_MAGIC *mg; + int key = ((TEST_XPVAV*) (av)->sv_any)->xav_fill; + TEST_SV** ary = ((TEST_SV**)((TEST_XPVAV*) (av)->sv_any)->xav_array); + while (key < fill) + ary[++key] = &PL_sv_undef; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr38409.c b/gcc/testsuite/gcc.dg/graphite/pr38409.c new file mode 100644 index 000000000..5cdb4725d --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr38409.c @@ -0,0 +1,24 @@ +/* { dg-options "-O2" } */ + +typedef struct test input ; +struct test +{ + int type ; + int symflag ; +}; +Chv_copyEntriesToVector ( input *chv,double *dvec) +{ + double *entries ; + int mm, nent; + int first, i, k , stride ; + if ( ((chv)->type == 1) ) + { + for ( i = 0 ; i < 10 ; i++) + { + dvec[2*mm] = entries[2*k] ; + k += stride ; + stride -= 2 ; + } + } + return(mm) ; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr38413.c b/gcc/testsuite/gcc.dg/graphite/pr38413.c new file mode 100644 index 000000000..6c2b23a88 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr38413.c @@ -0,0 +1,14 @@ +/* { dg-options "-O2 -fgraphite-identity" } */ + +static int qsz; + +void specqsort(base, n, size, compar) + char *base; +{ + register char c, *i, *j, *lo, *hi; + qsz = size; + for (i = base, hi = base + qsz; i < hi; ) + { + *i++ = c; + } +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr38446.c b/gcc/testsuite/gcc.dg/graphite/pr38446.c new file mode 100644 index 000000000..b7b346cd9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr38446.c @@ -0,0 +1,14 @@ +/* { dg-options "-O2 -fgraphite-identity" } */ + +void copy_data() +{ + int ****source; + int ****dest; + + int i, j, k, l; + for (i = 0; i < 10; i++) + for (k = 0; k < 2; k++) + for (l = 0; l < 65; l++) + source[i][j][k][l] = dest[i][j][k][l]; +} + diff --git a/gcc/testsuite/gcc.dg/graphite/pr38498.c b/gcc/testsuite/gcc.dg/graphite/pr38498.c new file mode 100644 index 000000000..d20b4ae16 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr38498.c @@ -0,0 +1,19 @@ +/* { dg-options "-O2" } */ + +double test_vector (float **data, int rows, int cols, int vqrows,double epsilon, int maxiter,int **mean, int *map) +{ + int i, j, r, it; + double sqerr, prev_sqerr=0, t; + unsigned int *sel; + int *count; + for (it = 0;; it++) + { + if ((sqerr == 0.0) || (it >= maxiter-1) ||((it > 0) && ( ((prev_sqerr - sqerr) / prev_sqerr) < epsilon )) ) + for (i = 0; i < vqrows; i++) + { + for (j = 0; j < cols; j++) + mean[i][j] = 0.0; + count[i] = 0; + } + } +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr38500.c b/gcc/testsuite/gcc.dg/graphite/pr38500.c new file mode 100644 index 000000000..f5292d173 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr38500.c @@ -0,0 +1,29 @@ +/* { dg-options "-O3 -fgraphite-identity" } */ + +typedef unsigned char U8; +extern char test1; + +char *Perl_screaminstr (int, int, int); + +void +Perl_re_intuit_start( int minlen, char *strend, unsigned int flags, int i) +{ + register int start_shift = 0; + register int end_shift = 0; + register char *s; + char *strbeg; + char *t; + if(i > 0) + goto success_at_start; + int end = 0; + int eshift = (test1 ? Perl_utf8_distance((U8*)strend,(U8*)s) : (U8*)strend - (U8*)s) - end; + if (end_shift < eshift) + end_shift = eshift; + restart: + s = Perl_screaminstr(start_shift + (s - strbeg), end_shift, 0); + while( t < strend - minlen){ + } + success_at_start: + eshift = (test1 ? Perl_utf8_distance((U8*)strend,(U8*)s) : (U8*)strend - (U8*)s) - end; + goto restart; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr38510.c b/gcc/testsuite/gcc.dg/graphite/pr38510.c new file mode 100644 index 000000000..07ddb6ef1 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr38510.c @@ -0,0 +1,40 @@ +/* { dg-options "-O2 -fgraphite-identity" } */ +typedef long int integer; +typedef double doublereal; + +static int balanc_(nm, n, a, low, igh, scale) +doublereal *a; +{ + integer a_dim1, a_offset, i__1, i__2; + integer iexc; + integer i__, j, k, l, m; + integer jj; +goto L100; +L20: +if (j == m) { +goto L50; +} +for (i__ = 1; i__ <= i__1; ++i__) { +a[i__ + j * a_dim1] = a[i__ + m * a_dim1]; +} +L50: +switch ((int)iexc) { +case 2: goto L130; +} +L100: +for (jj = 1; jj <= i__1; ++jj) { +goto L20; +} +L130: +for (j = k; j <= i__1; ++j) { +goto L20; +} +} + +int pymol_rg_(integer *nm, integer *n, doublereal *a, doublereal *wr, + doublereal *fv1,integer *ierr) +{ + integer a_dim1, a_offset, z_dim1, z_offset; + integer is1, is2; + balanc_(nm, n, &a[a_offset], &is1, &is2, &fv1[1]); +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr38559.c b/gcc/testsuite/gcc.dg/graphite/pr38559.c new file mode 100644 index 000000000..7f90a50ac --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr38559.c @@ -0,0 +1,14 @@ +/* { dg-options "-O2" } */ + +int test() +{ + int offset, len; + register char *mid; + register char *midend; + register char *bigend; + long unsigned int curlen; + if (offset + len > curlen) { + while (midend > mid) + *--bigend = *--midend; + } +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr38786.c b/gcc/testsuite/gcc.dg/graphite/pr38786.c new file mode 100644 index 000000000..47df44789 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr38786.c @@ -0,0 +1,20 @@ +/* { dg-options "-O2 -fgraphite-identity" } */ + +typedef struct +{ + int ****cofAC; +} ImageParameters; +typedef struct +{ + int ****cofAC; +} RD_DATA; +extern RD_DATA *rdopt; +extern ImageParameters *img; +dummy_slice_too_big (int bits_slice) +{ + int i, j, k, l; + for (j = 0; j < 4; j++) + for (k = 0; k < 2; k++) + for (l = 0; l < 65; l++) + img->cofAC[i][j][k][l] = rdopt->cofAC[i][j][k][l]; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr39260.c b/gcc/testsuite/gcc.dg/graphite/pr39260.c new file mode 100644 index 000000000..066b5bde8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr39260.c @@ -0,0 +1,17 @@ +/* { dg-options "-O2 -fgraphite-identity -ffast-math" } */ + +VBR_encode_frame (int mode_gr, int channels_out, int max_bits[2][2]) +{ + int max_nbits_ch[2][2]; + int gr, ch; + for (gr = 0; gr < mode_gr; ++gr) + { + float f[2], s = 0; + for (ch = 0; ch < channels_out; ++ch) + if (max_nbits_ch[gr][ch] > 0) + s += f[ch]; + for (ch = 0; ch < channels_out; ++ch) + if (s > 0) + max_nbits_ch[gr][ch] = 7680 * f[ch] / s; + } +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr39335.c b/gcc/testsuite/gcc.dg/graphite/pr39335.c new file mode 100644 index 000000000..5b8fb5438 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr39335.c @@ -0,0 +1,20 @@ +/* { dg-options "-O2" } */ + +typedef unsigned char byte; +typedef struct gx_device_s gx_device; +typedef struct gs_devn_params_s gs_devn_params; +typedef struct gs_devn_params_s { + struct compressed_color_list_s * compressed_color_list; +} gs_devn_params_t; +int devn_unpack_row(gx_device * dev, int num_comp, + gs_devn_params * pdevn_params, int width, byte * in, + byte * out) +{ + int i, comp_num, pixel_num; + if (pdevn_params->compressed_color_list == ((void *)0)) + { + for (pixel_num = 0; pixel_num < width; pixel_num++) + for (i = 0; i < num_comp; i++) + *out++ = *in++; + } +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr39335_1.c b/gcc/testsuite/gcc.dg/graphite/pr39335_1.c new file mode 100644 index 000000000..dfa2465e3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr39335_1.c @@ -0,0 +1,9 @@ +/* { dg-options "-O2" } */ + +void crash_me(int num1, int num2, char * in, char * out) +{ + int i, j; + for (j = 0; j < num1; j++) + for (i = 0; i < num2; i++) + *out++ = *in++; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr40157.c b/gcc/testsuite/gcc.dg/graphite/pr40157.c new file mode 100644 index 000000000..513958fe5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr40157.c @@ -0,0 +1,13 @@ +/* { dg-require-effective-target int32plus } */ +/* { dg-options "-O2 -fgraphite-identity -floop-block" } */ + +int buffer[256*256]; +int main(void) +{ + int *dest = buffer; + int x, y; + for(x = 0; x < 256; x++) + for(y = 0; y < 256; y++) + *dest++ = 0; + return 0; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr40281.c b/gcc/testsuite/gcc.dg/graphite/pr40281.c new file mode 100644 index 000000000..255546b0c --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr40281.c @@ -0,0 +1,13 @@ +/* { dg-options "-O -fprefetch-loop-arrays -w" } */ +/* { dg-options "-O -fprefetch-loop-arrays -march=i686 -msse -w" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ +/* { dg-require-effective-target sse { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ + +void foo(int); +void bar(int n) +{ + int a[2], i, j = 0; + + for (i = 0; i < 2; i += j+1) + for (j = 0; j < (n ? 1 : 2); ++j) + foo(a[i] + a[j]); +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr41888.c b/gcc/testsuite/gcc.dg/graphite/pr41888.c new file mode 100644 index 000000000..45df7df28 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr41888.c @@ -0,0 +1,17 @@ +/* { 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/pr42205-1.c b/gcc/testsuite/gcc.dg/graphite/pr42205-1.c new file mode 100644 index 000000000..413b9f7ea --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr42205-1.c @@ -0,0 +1,17 @@ +/* { dg-options "-O1 -ffast-math -floop-interchange" } */ + +int adler32(int adler, char *buf, int n) +{ + int sum = 0; + do { + adler += buf[0]; + sum += adler; + adler += buf[1]; + sum += adler; + adler += buf[2]; + sum += adler; + adler += buf[3]; + sum += adler; + } while (--n); + return adler | (sum << 16); +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr42205-2.c b/gcc/testsuite/gcc.dg/graphite/pr42205-2.c new file mode 100644 index 000000000..595cedb90 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr42205-2.c @@ -0,0 +1,11 @@ +/* { dg-options "-O1 -funsafe-math-optimizations -floop-interchange" } */ + +double f(double x) +{ + double y = 0.0; + int i; + for (i = 0; i < 8; i++) { + y += x * i; + } + return y; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr42211.c b/gcc/testsuite/gcc.dg/graphite/pr42211.c new file mode 100644 index 000000000..d8fb915f3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr42211.c @@ -0,0 +1,22 @@ +/* { dg-options "-O3 -floop-interchange" } */ + +typedef unsigned char uint8_t; + +void border_mirror(uint8_t *outer_img, int w, int h, int rb, int border) +{ + uint8_t *img = outer_img + border * rb + border; + int x, y; + + for (y = -border; y < 0; y++) { + for (x = -border; x < 0; x++) + img[y*rb + x] = img[(-y)*rb + (-x)]; + + for (x = 0; x < w; x++) + img[y*rb + x] = img[(-y)*rb + x]; + } +} + +void border_mirror_480(uint8_t *outer_img) +{ + border_mirror(outer_img, 640, 480, 640 + 16*2, 16); +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr42221.c b/gcc/testsuite/gcc.dg/graphite/pr42221.c new file mode 100644 index 000000000..da8daa1e2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr42221.c @@ -0,0 +1,24 @@ +/* { dg-options "-Os -fgraphite-identity" } */ + +static void b2w(unsigned int *out, const unsigned char *in, unsigned int len) +{ + const unsigned char *bpend = in + len; + for (; in != bpend; in += 4, ++out) + { + *out = (unsigned int) (in[0] ) | + (unsigned int) (in[3] << 24); + } +} +static void md4step(unsigned int state[4], const unsigned char *data) +{ + unsigned int A, X[16]; + b2w(X, data, 64); + state[0] += A; +} +void md4sum(void) +{ + unsigned char final[128]; + unsigned int state[4]; + md4step(state, final); + md4step(state, final + 64); +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr42284.c b/gcc/testsuite/gcc.dg/graphite/pr42284.c new file mode 100644 index 000000000..854c2514f --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr42284.c @@ -0,0 +1,27 @@ +/* { dg-options "-O2 -fgraphite-identity" } */ + +int +huft_build (unsigned *b) +{ + int k; + for (k = 0; k <= 10; k++) + if (foo ()); +} +int +inflate_fixed () +{ + int i; + unsigned l[288]; + for (i = 0; i < 144; i++) + l[i] = 8; + for (; i < 256; i++) + l[i] = 9; + for (; i < 280; i++) + l[i] = 7; + for (; i < 288; i++) + l[i] = 8; + if ((i = huft_build (l)) != 0) + return i; + for (i = 0; i < 30; i++) + l[i] = 5; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr42326.c b/gcc/testsuite/gcc.dg/graphite/pr42326.c new file mode 100644 index 000000000..de5d56ec9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr42326.c @@ -0,0 +1,20 @@ +/* { dg-options "-O1 -floop-parallelize-all" } */ + +double lagrange(const double x[], + const double y[], + long n, + double xval) +{ + long i, j; + double yval = 0.; + + for( i=0; i < n; i++ ) + { + double l = 1.; + for( j=0; j < n; j++ ) + if( i != j ) + l *= (xval-x[j])/(x[i]-x[j]); + yval += y[i]*l; + } + return yval; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr42521.c b/gcc/testsuite/gcc.dg/graphite/pr42521.c new file mode 100644 index 000000000..2695df579 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr42521.c @@ -0,0 +1,18 @@ +/* { dg-options "-O3 -fgraphite-identity" } */ + +extern int *A; +extern int B[][4]; + +void foo(int im, int jm, int cond) +{ + int i, j; + if (cond) + for (i = 0; i < 256; i++) + A[i] = 0; + + for (i = 0; i < im; i++) + for (j = 1; j < jm; j++) + if (jm != 8 || j != jm >> 1) + B[j][0] ^= B[j-1][0]; + +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr42530.c b/gcc/testsuite/gcc.dg/graphite/pr42530.c new file mode 100644 index 000000000..c0fa299ce --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr42530.c @@ -0,0 +1,18 @@ +/* { dg-options "-O2 -g -ffast-math -floop-parallelize-all" } */ + +int array[2][2]; + +void foo(int *a) +{ + int i, j; + int sum, tmp = 0; + + for (i=0; i<2; i++) + for (j=0; j<2; j++) + sum += array[i][j]; + + if (sum > 0) { + tmp = sum; + *a = tmp; + } +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr42729.c b/gcc/testsuite/gcc.dg/graphite/pr42729.c new file mode 100644 index 000000000..a9f1e2dee --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr42729.c @@ -0,0 +1,14 @@ +/* { dg-options "-O1 -fgraphite-identity -fcompare-debug" } */ + +int A[10]; +int *foo () +{ + int *p1, *p2, i; + for (i = 0; i < 10; i++) + { + p1 = &A[i]; + *p1 = 0; + } + p2 = p1; + return p2; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr42771.c b/gcc/testsuite/gcc.dg/graphite/pr42771.c new file mode 100644 index 000000000..505fda7eb --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr42771.c @@ -0,0 +1,19 @@ +/* { dg-options "-O3 -fgraphite-identity" } */ + +extern int *A; +extern int B[][4]; +extern void bar(void); + +void foo(int im, int jm, int cond) +{ + int i, j; + if (cond) { + for (i = 0; i < 256; i++) + A[i] = 0; + bar(); + } + for (i = 0; i < im; i++) + for (j = 1; j < jm; j++) + if (jm != 8 || j != jm >> 1) + B[j][0] ^= B[j-1][0]; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr42914.c b/gcc/testsuite/gcc.dg/graphite/pr42914.c new file mode 100644 index 000000000..606ee0871 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr42914.c @@ -0,0 +1,21 @@ +/* { dg-options "-O2 -g -ffast-math -fgraphite-identity" } */ + +int find_sad_16x16(int *mode) +{ + int current, best; + int M1[16][16],M0[4][4][4][4],M3[4],M4[4][4]; + int i,j,k; + int ii,jj; + + for (jj=0;jj<4;jj++) + for (ii=0;ii<4;ii++) + for (j=0;j<4;j++) + for (j=0;j<4;j++) + current += abs(M0[i][ii][j][jj]); + + if(current < best) + { + best = current; + *mode = k; + } +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr42917.c b/gcc/testsuite/gcc.dg/graphite/pr42917.c new file mode 100644 index 000000000..eddff3b58 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr42917.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -ftree-loop-linear -fcompare-debug" } */ + +extern int A[]; + +void +foo () +{ + int i, j; + for (i = 0; i < 4; i++) + for (j = 255; j >= 0; j--) + A[j] = 0; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr43012.c b/gcc/testsuite/gcc.dg/graphite/pr43012.c new file mode 100644 index 000000000..6d0f3b041 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr43012.c @@ -0,0 +1,74 @@ +/* This testcase is from PR43012. + You will need CLooG-PPL 0.15.8 or later to have this testcase fixed. */ + +/* { dg-do run } */ +/* { dg-options "-O2 -floop-strip-mine" } */ + +extern void abort (void); + +#ifdef DBG +extern int printf (const char *, ...); +#endif + +#define LAST_TOKEN 534 +#define FLOAT_FUNCT_TOKEN 64 +#define VECTOR_FUNCT_TOKEN 77 +#define COLOUR_KEY_TOKEN 89 + +int Table[LAST_TOKEN]; + +void +pre_init_tokenizer () +{ + int i; + + for (i = 0; i < LAST_TOKEN; i++) + { + Table[i] = i; + if (i < FLOAT_FUNCT_TOKEN) + Table[i] = FLOAT_FUNCT_TOKEN; + else + { + if (i < VECTOR_FUNCT_TOKEN) + Table[i] = VECTOR_FUNCT_TOKEN; + else + { + if (i < COLOUR_KEY_TOKEN) + Table[i] = COLOUR_KEY_TOKEN; + } + } + } +} + +void +check () +{ + int i; + + for (i = 0; i < FLOAT_FUNCT_TOKEN; i++) + if (Table[i] != FLOAT_FUNCT_TOKEN) + abort (); + for (i = FLOAT_FUNCT_TOKEN; i < VECTOR_FUNCT_TOKEN; i++) + if (Table[i] != VECTOR_FUNCT_TOKEN) + abort (); + for (i = VECTOR_FUNCT_TOKEN; i < COLOUR_KEY_TOKEN; i++) + if (Table[i] != COLOUR_KEY_TOKEN) + abort (); + for (i = COLOUR_KEY_TOKEN; i < LAST_TOKEN; i++) + if (Table[i] != i) + abort (); +} + +int +main () +{ + int i; + + pre_init_tokenizer (); +#ifdef DBG + for (i = 0; i < LAST_TOKEN; i++) + printf ("%3d: %d\n", i, Table[i]); +#endif + check (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr43083.c b/gcc/testsuite/gcc.dg/graphite/pr43083.c new file mode 100644 index 000000000..afb97af94 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr43083.c @@ -0,0 +1,14 @@ +/* { dg-options "-O3 -fgraphite-identity" } */ + +extern void baz(void); + +static inline int bar(void) +{ + int i; + for (i = 0; i < 10; i++) baz(); +} + +int foo(void) +{ + if (bar() != 0) return 0; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr43306.c b/gcc/testsuite/gcc.dg/graphite/pr43306.c new file mode 100644 index 000000000..43195e489 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr43306.c @@ -0,0 +1,9 @@ +/* { dg-options "-O1 -fstrict-overflow -fgraphite-identity" } */ + +void foo(int x[]) +{ + int i, j; + for (i = 0; i < 2; i++) + for (j = 0; j < 2; j++) + x[i] = x[i*j]; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr43567.c b/gcc/testsuite/gcc.dg/graphite/pr43567.c new file mode 100644 index 000000000..1bb8042ab --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr43567.c @@ -0,0 +1,26 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -fno-inline -fno-tree-ch -ftree-loop-linear" } */ + +extern void abort (); + +int +test (int n, int *a) +{ + int i, j; + + for (i = 0; i < n; i++) + for (j = 0; j < n; j++) + a[j] = i + n; + + if (a[0] != 31 || i + n - 1 != 31) + abort (); + + return 0; +} + +int main (void) +{ + int a[16]; + test (16, a); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr43657.c b/gcc/testsuite/gcc.dg/graphite/pr43657.c new file mode 100644 index 000000000..18afe1e1c --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr43657.c @@ -0,0 +1,52 @@ +/* { dg-do run } */ +/* { dg-options "-O1 -ftree-loop-linear" } */ + +extern void abort (void); + +#define K 32 + +int cond_array[2*K][K]; +int a[K][K]; +int out[K]; +int check_result[K] = {2,2,2,2,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; + +__attribute__ ((noinline)) void +foo (int c) +{ + int res, i, j, k, next; + + for (k = 0; k < K; k++) + { + res = 0; + for (j = 0; j < K; j++) + for (i = 0; i < K; i++) + { + next = a[i][j]; + res = c > cond_array[i+k][j] ? next : res; + } + + out[k] = res; + } +} + +int main () +{ + int i, j, k; + + for (j = 0; j < K; j++) + { + for (i = 0; i < 2*K; i++) + cond_array[i][j] = i+j; + + for (i = 0; i < K; i++) + a[i][j] = i+2; + } + + foo(5); + + for (k = 0; k < K; k++) + if (out[k] != check_result[k]) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr44391.c b/gcc/testsuite/gcc.dg/graphite/pr44391.c new file mode 100644 index 000000000..de9889668 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr44391.c @@ -0,0 +1,7 @@ +/* { dg-options "-Os -fgraphite-identity -ffast-math" } */ + +void byte_insert_op1 (unsigned char *loc, unsigned char *end, unsigned *pto) +{ + while (end != loc) + *pto = *--end; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr45297.c b/gcc/testsuite/gcc.dg/graphite/pr45297.c new file mode 100644 index 000000000..faa653a57 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr45297.c @@ -0,0 +1,9 @@ +/* { dg-options "-Os -fgraphite-identity" } */ + +void +foo (int *p) +{ + int *q = p + 1024; + while (q != p) + *--q = *--q; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr46168.c b/gcc/testsuite/gcc.dg/graphite/pr46168.c new file mode 100644 index 000000000..28b48415d --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr46168.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O -ftree-loop-linear" } */ + +int +foo (int a[4096], int mi, int mj) +{ + int i, j, i16; + for (i = 0; i < mi; i++) + { + i16 = i + 16; + for (j = 0; j < mj; j++) + i16 = a[j] == i16; + } + return i16; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr46185.c b/gcc/testsuite/gcc.dg/graphite/pr46185.c new file mode 100644 index 000000000..36d46a41c --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr46185.c @@ -0,0 +1,46 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -floop-interchange -ffast-math -fno-ipa-cp" } */ + +#define DEBUG 0 +#if DEBUG +#include <stdio.h> +#endif + +double u[1782225]; + +static int __attribute__((noinline)) +foo (int N, int *res) +{ + int i, j; + double sum = 0; + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + sum = sum + u[i + 1335 * j]; + + for (i = 0; i < N; i++) + u[1336 * i] *= 2; + + *res = sum + N + u[1336 * 2] + u[1336]; +} + +extern void abort (); + +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 + + if (res != 3565793) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr46215.c b/gcc/testsuite/gcc.dg/graphite/pr46215.c new file mode 100644 index 000000000..cf7b07f20 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr46215.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fstrict-overflow -fno-tree-ch -ftree-loop-linear" } */ + +extern int y[], x1[], x2[]; +void +foo (long n) +{ + int i, j; + for (i = 0; i < n; i++) + for (j = 0; j < n; j += 2) + y[i] = x1[i + j] * x2[i + j]; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr46404-1.c b/gcc/testsuite/gcc.dg/graphite/pr46404-1.c new file mode 100644 index 000000000..c3e620cbc --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr46404-1.c @@ -0,0 +1,27 @@ +/* { dg-options "-O -fgraphite-identity -fno-tree-scev-cprop" } */ + +int +huft_build (unsigned *b) +{ + int k; + for (k = 0; k <= 10; k++) + if (foo ()); +} +int +inflate_fixed () +{ + int i; + unsigned l[288]; + for (i = 0; i < 144; i++) + l[i] = 8; + for (; i < 256; i++) + l[i] = 9; + for (; i < 280; i++) + l[i] = 7; + for (; i < 288; i++) + l[i] = 8; + if ((i = huft_build (l)) != 0) + return i; + for (i = 0; i < 30; i++) + l[i] = 5; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr46404.c b/gcc/testsuite/gcc.dg/graphite/pr46404.c new file mode 100644 index 000000000..9bdde4a64 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr46404.c @@ -0,0 +1,13 @@ +/* { dg-options "-O -fgraphite-identity -fno-tree-scev-cprop" } */ + +int l[200]; + +void +foo (void) +{ + int i = 0; + for (; i < 100; i++) + ; + for (; i; i--) + l[i]; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr46761.c b/gcc/testsuite/gcc.dg/graphite/pr46761.c new file mode 100644 index 000000000..f45398a2b --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr46761.c @@ -0,0 +1,22 @@ +/* { dg-do run } */ +/* { dg-options "-O -fgraphite-identity" } */ + +#define N 128 + +int +main () +{ + int arr[N], i, s = 0; + for (i = 0; i < N; i++) + arr[i] = i; + + for (i = 0; i < N; i++) + if (arr[i] != i) + __builtin_abort (); + + for (i = 0; i < N; i++) + s += arr[i]; + if (s != (N * (N - 1)) / 2) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr46924.c b/gcc/testsuite/gcc.dg/graphite/pr46924.c new file mode 100644 index 000000000..5788c2c00 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr46924.c @@ -0,0 +1,18 @@ +/* { dg-options "-O -fgraphite-identity -ffast-math -fno-tree-loop-im" } */ + +struct S +{ + int n; + float *a; +}; + +float foo (struct S *s) +{ + float f = 0, g=0; + int i; + for (i = 0; i < s->n; i++) + f += s->a[i]; + for (i = 0; i < s->n; i++) + ; + return f; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr46966.c b/gcc/testsuite/gcc.dg/graphite/pr46966.c new file mode 100644 index 000000000..ce2a93ca9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr46966.c @@ -0,0 +1,13 @@ +/* PR tree-optimization/46966 */ +/* { dg-do compile } */ +/* { dg-options "-O -floop-interchange -ffast-math -fno-tree-copy-prop -fno-tree-loop-im" } */ + +int a[1000][1000]; + +void foo () +{ + int i, j; + for (i = 0; i < 1000; i++) + for (j = 0; j < 1000; j++) + a[i][j] = 0; +} diff --git a/gcc/testsuite/gcc.dg/graphite/pr46970.c b/gcc/testsuite/gcc.dg/graphite/pr46970.c new file mode 100644 index 000000000..b1ef7d62b --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/pr46970.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ +/* { dg-options "-Os -ftree-loop-linear" } */ + +#define N 16 + +int +main1 (int n, int *a) +{ + int i, j; + + for (i = 0; i < n; i++) + for (j = 0; j < n; j++) + a[j] = i + n; + + for (j = 0; j < n; j++) + if (a[j] != i + n - 1) + __builtin_abort (); + + return 0; +} + +int +main () +{ + int a[N]; + main1 (N, a); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/graphite/run-id-1.c b/gcc/testsuite/gcc.dg/graphite/run-id-1.c new file mode 100644 index 000000000..776600835 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/run-id-1.c @@ -0,0 +1,26 @@ +/* { dg-require-effective-target size32plus } */ + +void abort (void); + +void foo (int N) +{ + int i, j; + int x[1000][1000]; + + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + x[i][j] = i + j + 3; + + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + if (x[i][j] != i + j + 3) + abort (); +} + +int main(void) +{ + foo (1000); + + return 0; +} + diff --git a/gcc/testsuite/gcc.dg/graphite/run-id-2.c b/gcc/testsuite/gcc.dg/graphite/run-id-2.c new file mode 100644 index 000000000..4a2361667 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/run-id-2.c @@ -0,0 +1,35 @@ +int a[1] = {1}; + +static int __attribute__((noinline)) +foo(int n) +{ + int i, c = 0; + for (i = 0; i < n; i++) + c += a[i]; + return c; +} + +int b[2] = {2, 3}; + +static int __attribute__((noinline)) bar(int n) +{ + int i, c = 0; + for (i = 0; i < n; i++) + c += b[i]; + return c; +} + +extern void abort (); + +int main() +{ + if (foo(0) != 0 + || foo(1) != 1 + || bar(0) != 0 + || bar(1) != 2 + || bar(2) != 5) + abort (); + + return 0; +} + diff --git a/gcc/testsuite/gcc.dg/graphite/run-id-3.c b/gcc/testsuite/gcc.dg/graphite/run-id-3.c new file mode 100644 index 000000000..e708ba0bd --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/run-id-3.c @@ -0,0 +1,24 @@ +extern void abort (void); + +__attribute__ ((noinline)) int +foo (int *zzz, unsigned int kk) +{ + int a, b, d; + + a = b = 0; + for (d = 0; d < 1000; d++) + { + if (kk != 0) + b = *zzz; + } + + return b; +} + +int +main (void) +{ + if (foo (0, 0) != 0) + abort(); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/graphite/run-id-4.c b/gcc/testsuite/gcc.dg/graphite/run-id-4.c new file mode 100644 index 000000000..143a449d0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/run-id-4.c @@ -0,0 +1,28 @@ +/* PR rtl-optimization/24899 */ + +extern void abort (void); + +__attribute__ ((noinline)) int +foo (int x, int y, int *z) +{ + int a, b, c, d; + + a = b = 0; + for (d = 0; d < y; d++) + { + if (z) + b = d * *z; + for (c = 0; c < x; c++) + a += b; + } + + return a; +} + +int +main (void) +{ + if (foo (3, 2, 0) != 0) + abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/graphite/run-id-5.c b/gcc/testsuite/gcc.dg/graphite/run-id-5.c new file mode 100644 index 000000000..9005c43fd --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/run-id-5.c @@ -0,0 +1,54 @@ +/* { dg-options "-O2 -ftree-vectorize -fno-vect-cost-model -fno-tree-scev-cprop -fgraphite-identity" } */ +/* { dg-require-effective-target vect_int } */ + +/* gcc.dg/vect/no-scevccp-outer-22.c was miscompiled by Graphite. + Adding it here to always test it with Graphite. */ + +#include <stdarg.h> + +extern void abort (); +#define N 40 + +int a[N]; + +__attribute__ ((noinline)) int +foo (int n){ + int i,j; + int sum; + + if (n<=0) + return 0; + + /* inner-loop index j used after the inner-loop */ + for (i = 0; i < N; i++) { + sum = 0; + for (j = 0; j < n; j+=2) { + sum += j; + } + a[i] = sum + j; + } +} + +int main (void) +{ + int i,j; + int sum; + + for (i=0; i<N; i++) + a[i] = i; + + foo (N); + + /* check results: */ + for (i=0; i<N; i++) + { + sum = 0; + for (j = 0; j < N; j+=2) + sum += j; + if (a[i] != sum + j) + abort(); + } + + return 0; +} + diff --git a/gcc/testsuite/gcc.dg/graphite/run-id-6.c b/gcc/testsuite/gcc.dg/graphite/run-id-6.c new file mode 100644 index 000000000..dafa7f8be --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/run-id-6.c @@ -0,0 +1,55 @@ +/* { dg-options "-O2 -ftree-vectorize -fno-vect-cost-model -fno-tree-scev-cprop -fgraphite-identity" } */ +/* { dg-require-effective-target vect_int } */ + +/* gcc.dg/vect/no-scevccp-outer-4.c was miscompiled by Graphite. + Adding it here to always test it with Graphite. */ + +#include <stdarg.h> + +extern void abort (); +#define N 40 + +int a[N]; + +/* induction variable k advances through inner and outer loops. */ + +__attribute__ ((noinline)) int +foo (int n){ + int i,j,k=0; + int sum; + + if (n<=0) + return 0; + + for (i = 0; i < N; i++) { + sum = 0; + for (j = 0; j < n; j+=2) { + sum += k++; + } + a[i] = sum + j; + } +} + +int main (void) +{ + int i,j,k=0; + int sum; + + for (i=0; i<N; i++) + a[i] = i; + + foo (N); + + /* check results: */ + for (i=0; i<N; i++) + { + sum = 0; + for (j = 0; j < N; j+=2) + sum += k++; + if (a[i] != sum + j) + abort(); + } + + return 0; +} + diff --git a/gcc/testsuite/gcc.dg/graphite/run-id-pr42644.c b/gcc/testsuite/gcc.dg/graphite/run-id-pr42644.c new file mode 100644 index 000000000..d134b5c30 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/run-id-pr42644.c @@ -0,0 +1,37 @@ +/* Testcase extracted from test 183.equake in SPEC CPU2000. */ +double Ke[2], ds[2]; + +void foo(double Ke[2], int i, double ds[], int column) +{ + double tt, ts; + int j; + + for (j = 0; j < 2; j++) + { + ++column; + ts = ds[i]; + if (i == j) + tt = 123; + else + tt = 0; + Ke[column] = Ke[column] + ts + tt; + } +} + +extern void abort (); + +int +main () +{ + int i, j; + + ds[0] = 1.0; + ds[1] = 1.0; + + foo(Ke, 0, ds, -1); + + if ((int) Ke[0] != 124) + abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/graphite/run-id-pr46758.c b/gcc/testsuite/gcc.dg/graphite/run-id-pr46758.c new file mode 100644 index 000000000..81411f570 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/run-id-pr46758.c @@ -0,0 +1,18 @@ +int +movegt (int y, long long a) +{ + int i; + int ret = 0; + for (i = 0; i < y; i++) + if (a == -1LL << 33) + ret = -1; + return ret; +} + +int +main () +{ + if (movegt (1, -1LL << 33) != -1) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/graphite/scop-0.c b/gcc/testsuite/gcc.dg/graphite/scop-0.c new file mode 100644 index 000000000..958285f8a --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/scop-0.c @@ -0,0 +1,22 @@ +int foo (void); +void bar (void); + +int toto() +{ + /* Scop 1. */ + int i, j, k; + int a[201][100]; + int b[100]; + int N = foo (); + + for (i = 0; i < 2*N+ 100; i++) + for (j = 0; j < 200; j++) + a[j][i] = a[j+1][10] + 2; + + return a[3][5] + b[1]; + /* End scop 1. */ +} + +/* { 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-1.c b/gcc/testsuite/gcc.dg/graphite/scop-1.c new file mode 100644 index 000000000..0fa51493e --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/scop-1.c @@ -0,0 +1,31 @@ +void bar (void); + +int toto() +{ + int i, j, k; + int a[101][100]; + int b[100]; + + for (i = 1; i < 100; i++) + { + for (j = 1; j < 100; j++) + a[j][i] = a[j+1][i-1] + 2; + + b[i] = b[i-1] + 2; + + bar (); + + for (j = 1; j < 100; j++) + a[j][i] = a[j+1][i-1] + 2; + + b[i] = a[i-1][i] + 2; + + for (j = 1; j < 100; j++) + a[j][i] = a[j+1][i-1] + 2; + } + + return a[3][5] + b[1]; +} + +/* { dg-final { scan-tree-dump-times "number of SCoPs: 3" 1 "graphite"} } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-10.c b/gcc/testsuite/gcc.dg/graphite/scop-10.c new file mode 100644 index 000000000..139f4c114 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/scop-10.c @@ -0,0 +1,31 @@ +void bar (void); + +int toto() +{ + int i, j, k; + int a[100][100]; + int b[100]; + + for (i = 1; i < 100; i++) + { + for (j = 1; j < 100; j++) + b[i+j] = b[i+j-1] + 2; + + if (i * 2 == i + 8) + bar (); + else + { + for (j = 1; j < 100; j++) + b[i+j] = b[i+j-1] + 2; + a[i][i] = 2; + } + + for (k = 1; k < 100; k++) + b[i+k] = b[i+k-5] + 2; + } + + return a[3][5] + b[1]; +} + +/* { dg-final { scan-tree-dump-times "number of SCoPs: 3" 1 "graphite"} } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-11.c b/gcc/testsuite/gcc.dg/graphite/scop-11.c new file mode 100644 index 000000000..544b36bd7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/scop-11.c @@ -0,0 +1,32 @@ +void bar (); + +int toto() +{ + int i,j, b; + int a[100]; + + if (i == 20) + { + for (j = 0; j <= 20; j++) + a[j] = b + i; + b = 3; + bar(); + } + else + { + if (i == 30) + { + for (j = 0; j <= 20; j++) + a[j] = b + i; + b = 5; + } + } + + for (j = 0; j <= 20; j++) + a[j] = b + i; + + return a[b]; +} + +/* { dg-final { scan-tree-dump-times "number of SCoPs: 3" 1 "graphite"} } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-12.c b/gcc/testsuite/gcc.dg/graphite/scop-12.c new file mode 100644 index 000000000..71d34b1db --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/scop-12.c @@ -0,0 +1,36 @@ +void bar (); + +int toto() +{ + int i,j, b; + int a[100]; + + switch (i) + { + + case 5: + for (j = 0; j <= 20; j++) + a[j] = b + i + 12; + break; + case 8: + for (j = 0; j <= 20; j++) + a[j] = b + i + 122; + break; + case 15: + for (j = 0; j <= 20; j++) + a[j] = b + i + 12; + break; + case 18: + for (j = 0; j <= 20; j++) + a[j] = b + i + 4; + break; + default: + for (j = 0; j <= 20; j++) + a[j] = b + i + 3; + } + + return a[b]; +} + +/* { dg-final { scan-tree-dump-times "number of SCoPs: 5" 1 "graphite"} } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-13.c b/gcc/testsuite/gcc.dg/graphite/scop-13.c new file mode 100644 index 000000000..b2ca5b400 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/scop-13.c @@ -0,0 +1,41 @@ +void bar (); + +int toto() +{ + int i,j, b; + int a[100]; + + if (i == 20) + { + b = 3; + goto B; + } + else + { + if (i == 30) + { + a[i] = b; + + + for (j = 0; j <= 20; j++) + a[j] = b + i; + + B: + + for (j = 0; j <= 20; j++) + a[j+b] = b + i; + + bar (); + } + else + { + a[i] = b + 3; + } + } + + + return a[b]; +} + +/* { dg-final { scan-tree-dump-times "number of SCoPs: 2" 1 "graphite"} } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-14.c b/gcc/testsuite/gcc.dg/graphite/scop-14.c new file mode 100644 index 000000000..867e293d6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/scop-14.c @@ -0,0 +1,25 @@ +void bar (); + +int toto() +{ + int i,j, b; + int a[100]; + + for (j = 0; j <= 20; j++) + { + a[j] = b + i; + + if (j * i == b) + break; + + a[j+b] = b + i; + } + + a[i] = b + 3; + + + return a[b]; +} + +/* { dg-final { scan-tree-dump-times "number of SCoPs: 0" 1 "graphite"} } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-15.c b/gcc/testsuite/gcc.dg/graphite/scop-15.c new file mode 100644 index 000000000..6b2c2bdc8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/scop-15.c @@ -0,0 +1,51 @@ +# define EXTERN(type, array) extern type array[] +typedef unsigned char uch; +typedef unsigned short ush; +EXTERN(uch, window); +EXTERN(ush, prev); +#ifndef WSIZE +# define WSIZE 0x8000 +#endif +#define MIN_MATCH 3 +#define MAX_MATCH 258 +#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) +#define MAX_DIST (WSIZE-MIN_LOOKAHEAD) +#define near +typedef unsigned IPos; +unsigned near max_chain_length; +extern unsigned near strstart; +unsigned int near prev_length; +#define NIL 0 +unsigned near good_match; +int near nice_match; +#define WMASK (WSIZE-1) +int longest_match(IPos cur_match) +{ + unsigned chain_length = max_chain_length; + register uch *scan = window + strstart; + register uch *match; + register int len; + int best_len = prev_length; + IPos limit = strstart > (IPos)MAX_DIST ? strstart - (IPos)MAX_DIST : NIL; + register uch *strend = window + strstart + MAX_MATCH; + register uch scan_end = scan[best_len]; + if (prev_length >= good_match) { + } + do { + if (match[best_len] != scan_end || + *++match != scan[1]) continue; + do { + } while (*++scan == *++match && *++scan == *++match && + scan < strend); + len = MAX_MATCH - (int)(strend - scan); + if (len > best_len) { + best_len = len; + if (len >= nice_match) break; + } + } while ((cur_match = prev[cur_match & WMASK]) > limit + && --chain_length != 0); + return best_len; +} + +/* { dg-final { scan-tree-dump-times "number of SCoPs: 0" 1 "graphite"} } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-16.c b/gcc/testsuite/gcc.dg/graphite/scop-16.c new file mode 100644 index 000000000..0849e86b8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/scop-16.c @@ -0,0 +1,25 @@ +/* { dg-require-effective-target size32plus } */ + +#define N 10000 +void foo (int); +int test () +{ + int a[N][N]; + int b[N][N]; + unsigned i, j; + + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + a[i][j] = i*j; + + for (j = 1; j < N; j++) + for (i = 0; i < N; i++) + a[i][j] = a[i][j-1] + b[i][j]; + + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + foo (a[i][j]); +} + +/* { dg-final { scan-tree-dump-times "number of SCoPs: 2" 1 "graphite"} } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-17.c b/gcc/testsuite/gcc.dg/graphite/scop-17.c new file mode 100644 index 000000000..ee37aea95 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/scop-17.c @@ -0,0 +1,24 @@ +/* { dg-require-effective-target size32plus } */ + +#define N 10000 +void foo (int); +int test () +{ + int a[N][N]; + unsigned i, j; + + for (i = 0; i < N; i++) + for (j = 0; j < N; j++) + a[i][j] = i*j; + + 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 (i = 0; i < N; i++) + for (j = 0; j < N; j++) + foo (a[i][j]); +} + +/* { dg-final { scan-tree-dump-times "number of SCoPs: 2" 1 "graphite"} } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-18.c b/gcc/testsuite/gcc.dg/graphite/scop-18.c new file mode 100644 index 000000000..4c2a8cdf6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/scop-18.c @@ -0,0 +1,26 @@ +/* { dg-require-effective-target size32plus } */ + +#define N 24 +#define M 1000 + +float A[1000][1000], B[1000][1000], C[1000][1000]; + +void test (void) +{ + int i, j, k; + + /* These loops contain too few iterations for being strip-mined by 64. */ + for (i = 0; i < 24; i++) + for (j = 0; j < 24; j++) + for (k = 0; k < 24; k++) + A[i][j] = B[i][k] * C[k][j]; + + /* These loops should still be strip mined. */ + for (i = 0; i < 1000; i++) + for (j = 0; j < 1000; j++) + for (k = 0; k < 1000; k++) + A[i][j] = B[i][k] * C[k][j]; +} + +/* { dg-final { scan-tree-dump-times "number of SCoPs: 2" 1 "graphite"} } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-19.c b/gcc/testsuite/gcc.dg/graphite/scop-19.c new file mode 100644 index 000000000..cfbf40164 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/scop-19.c @@ -0,0 +1,34 @@ +typedef unsigned int __uint32_t; +typedef __uint32_t __size_t; +typedef __size_t size_t; +struct demangle_component +{ + union + { + } u; +}; +enum d_builtin_type_print +{ + D_PRINT_VOID +}; +struct d_growable_string +{ + size_t alc; +}; +d_growable_string_resize (struct d_growable_string *dgs, size_t need) +{ + size_t newalc; + newalc = dgs->alc > 0 ? dgs->alc : 2; + while (newalc < need) + newalc <<= 1; +} +d_growable_string_append_buffer (struct d_growable_string *dgs, + const char *s, size_t l) +{ + size_t need; + if (need > dgs->alc) + d_growable_string_resize (dgs, need); +} +/* { dg-final { scan-tree-dump-times "number of SCoPs: 0" 2 "graphite"} } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ + diff --git a/gcc/testsuite/gcc.dg/graphite/scop-2.c b/gcc/testsuite/gcc.dg/graphite/scop-2.c new file mode 100644 index 000000000..8378361c6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/scop-2.c @@ -0,0 +1,39 @@ +void bar (void); + +int toto() +{ + int i, j, k; + int a[101][100]; + int b[100]; + + for (i = 1; i < 100; i++) + { + for (j = 1; j < 100; j++) + for (k = 1; k < 100; k++) + a[j][k] = a[j+1][i-1] + 2; + + b[i] = b[i-1] + 2; + + bar (); + + for (j = 1; j < 100; j++) + a[j][i] = a[j+1][i-1] + 2; + + b[i] = b[i-1] + 2; + + bar (); + + for (j = 1; j < 100; j++) + a[j][i] = a[j+1][i-1] + 2; + + b[i] = a[i-1][i] + 2; + + for (j = 1; j < 100; j++) + a[j][i] = a[j+1][i-1] + 2; + } + + return a[3][5] + b[1]; +} + +/* { dg-final { scan-tree-dump-times "number of SCoPs: 4" 1 "graphite"} } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-20.c b/gcc/testsuite/gcc.dg/graphite/scop-20.c new file mode 100644 index 000000000..cbba351b0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/scop-20.c @@ -0,0 +1,27 @@ +void bar (void); + +int toto() +{ + int i, j, k; + int a[101][100]; + int b[100]; + + for (i = 1; i < 100; i++) + { + for (j = 1; j < 100; j += i) + for (k = 1; k < 100; k++) + a[j][k] = a[j+1][i-1] + 2; + + b[i] = b[i-1] + 2; + + for (j = 1; j < 100; j++) + a[j][i] = a[j+1][i-1] + 2; + + b[i] = b[i-1] + 2; + } + + return a[3][5] + b[1]; +} + +/* { dg-final { scan-tree-dump-times "number of SCoPs: 2" 1 "graphite"} } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-21.c b/gcc/testsuite/gcc.dg/graphite/scop-21.c new file mode 100644 index 000000000..5e58834ca --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/scop-21.c @@ -0,0 +1,31 @@ +#define N 10000 +void foo (int); +int test () +{ + int a[N+6]; + unsigned i; + + for (i = 0; i < N; i++) + { + a[i] = i + 12; + + if (i == 40) + a[i] = i; + else + a[i] = i+1; + + + a[i] = i + 12; + a[i] = a[i+1]; + a[i] += a[i+2]; + a[i] += a[i+3]; + a[i] += a[i+4]; + a[i] += a[i+5]; + a[i] += a[i+6]; + + } + + return a[20]; +} +/* { 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 000000000..b77be22b1 --- /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" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-3.c b/gcc/testsuite/gcc.dg/graphite/scop-3.c new file mode 100644 index 000000000..e20bfdcb3 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/scop-3.c @@ -0,0 +1,28 @@ +int toto() +{ + int i, j, k; + int a[100][100]; + int b[100]; + + for (i = 1; i < 100; i++) + { + for (j = 1; j < 80; j++) + a[j][i] = a[j+1][2*i-1*j] + 12; + + b[i] = b[i-1] + 10; + + for (j = 1; j < 60; j++) + a[j][i] = a[j+1][i-1] + 8; + + if (i == 23) + b[i] = a[i-1][i] + 6; + + for (j = 1; j < 40; j++) + a[j][i] = a[j+1][i-1] + 4; + } + + return a[3][5] + b[1]; +} + +/* { 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-4.c b/gcc/testsuite/gcc.dg/graphite/scop-4.c new file mode 100644 index 000000000..4ab2d07f4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/scop-4.c @@ -0,0 +1,29 @@ +void bar (); + +int toto() +{ + int i, j, k; + int a[100][100]; + int b[100]; + + for (i = 1; i < 100; i++) + { + for (j = 1; j < 80; j++) + a[j][i] = a[j+1][2*i-1*j] + 12; + + b[i] = b[i-1] + 10; + + for (j = 1; j < 60; j++) + a[j][i] = a[j+1][i-1] + 8; + + bar (); + + if (i == 23) + b[i] = a[i-1][i] + 6; + } + + return a[3][5] + b[1]; +} + +/* { dg-final { scan-tree-dump-times "number of SCoPs: 2" 1 "graphite"} } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-5.c b/gcc/testsuite/gcc.dg/graphite/scop-5.c new file mode 100644 index 000000000..4f4b45b49 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/scop-5.c @@ -0,0 +1,35 @@ +void bar (); + +int toto() +{ + int i,j, b; + int a[100]; + + if (i == 20) + { + for (j = 0; j <= 20; j++) + a[j] = b + i; + b = 3; + bar(); + } + else + { + if (i == 30) + { + for (j = 0; j <= 20; j++) + a[j] = b + i; + b = 5; + } + else + { + for (j = 0; j <= 20; j++) + a[j] = b + i; + b = 8; + } + } + + return a[b]; +} + +/* { dg-final { scan-tree-dump-times "number of SCoPs: 3" 1 "graphite"} } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-6.c b/gcc/testsuite/gcc.dg/graphite/scop-6.c new file mode 100644 index 000000000..df208acb2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/scop-6.c @@ -0,0 +1,31 @@ +void bar (void); + +int toto() +{ + int i, j, k; + int a[100][100]; + int b[100]; + + for (i = 1; i < 100; i++) + { + for (j = 1; j < 100; j++) + b[i+j] = b[i+j-1] + 2; + + if (i * 2 == i + 8) + b[i+k] = b[i+k-1] + 2; + else + { + for (k = 1; k < 100; k++) + b[i+k] = b[i+k-1] + 2; + bar (); + } + + for (k = 1; k < 100; k++) + b[i+k] = b[i+k-5] + 2; + } + + return a[3][5] + b[1]; +} + +/* { dg-final { scan-tree-dump-times "number of SCoPs: 3" 1 "graphite"} } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-7.c b/gcc/testsuite/gcc.dg/graphite/scop-7.c new file mode 100644 index 000000000..c02748fa7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/scop-7.c @@ -0,0 +1,31 @@ +void bar (void); + +int toto() +{ + int i, j, k; + int a[100][100]; + int b[100]; + + for (i = 1; i < 100; i++) + { + for (j = 1; j < 100; j++) + b[i+j] = b[i+j-1] + 2; + + if (i * 2 == i + 8) + { + bar (); + for (j = 1; j < 100; j++) + b[i+j] = b[i+j-1] + 2; + } + else + a[i][i] = 2; + + for (k = 1; k < 100; k++) + b[i+k] = b[i+k-5] + 2; + } + + return a[3][5] + b[1]; +} + +/* { dg-final { scan-tree-dump-times "number of SCoPs: 3" 1 "graphite"} } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-8.c b/gcc/testsuite/gcc.dg/graphite/scop-8.c new file mode 100644 index 000000000..3f14e347a --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/scop-8.c @@ -0,0 +1,31 @@ +int bar (void); + +int toto() +{ + int i, j, k; + int a[100][100]; + int b[100]; + + for (i = 1; i < 100; i++) + { + for (j = 1; j < 100; j++) + b[i+j] = b[i+j-1] + 2; + + if (i * 2 == i + 8) + { + for (j = 1; j < 100; j++) + if (bar ()) + b[i+j] = b[i+j-1] + 2; + } + else + a[i][i] = 2; + + for (k = 1; k < 100; k++) + b[i+k] = b[i+k-5] + 2; + } + + return a[3][5] + b[1]; +} + +/* { dg-final { scan-tree-dump-times "number of SCoPs: 2" 1 "graphite"} } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-9.c b/gcc/testsuite/gcc.dg/graphite/scop-9.c new file mode 100644 index 000000000..a803d9217 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/scop-9.c @@ -0,0 +1,27 @@ +void bar (void); + +int toto() +{ + int i, j, k; + int a[100][100]; + int b[100]; + + for (i = 1; i < 100; i++) + { + for (j = 1; j < 100; j++) + b[i+j] = b[i+j-1] + 2; + + if (i * 2 == i + 8) + bar (); + else + a[i][i] = 2; + + for (k = 1; k < 100; k++) + b[i+k] = b[i+k-5] + 2; + } + + return a[3][5] + b[1]; +} + +/* { dg-final { scan-tree-dump-times "number of SCoPs: 2" 1 "graphite"} } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ diff --git a/gcc/testsuite/gcc.dg/graphite/scop-dsyr2k.c b/gcc/testsuite/gcc.dg/graphite/scop-dsyr2k.c new file mode 100644 index 000000000..f5d1df1ea --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/scop-dsyr2k.c @@ -0,0 +1,21 @@ +#define NMAX 3000 + +static double a[NMAX][NMAX], b[NMAX][NMAX], c[NMAX][NMAX]; + +void dsyr2k(long N) { + int i,j,k; + +#pragma scop + for (i=0; i<N; i++) { + for (j=0; j<N; j++) { + for (k=j; k<N; k++) { + c[j][k] += a[i][j] * b[i][k] + b[i][j] * a[i][k]; + } + } + } +#pragma endscop +} + +/* { 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-dsyrk.c b/gcc/testsuite/gcc.dg/graphite/scop-dsyrk.c new file mode 100644 index 000000000..a7bc5c498 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/scop-dsyrk.c @@ -0,0 +1,22 @@ +#define NMAX 3000 +#define MEASURE_TIME 1 + +static double a[NMAX][NMAX], c[NMAX][NMAX]; + +void dsyrk(long N) +{ + int i,j,k; + +#pragma scop + for (i=0; i<N; i++) { + for (j=0; j<N; j++) { + for (k=j; k<N; k++) { + c[j][k] += a[i][j] * a[i][k]; + } + } + } +#pragma endscop +} + +/* { 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-matmult.c b/gcc/testsuite/gcc.dg/graphite/scop-matmult.c new file mode 100644 index 000000000..018de2c4e --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/scop-matmult.c @@ -0,0 +1,20 @@ +/* { dg-require-effective-target size32plus } */ + +float A[1000][1000], B[1000][1000], C[1000][1000]; + +/* Multiply two n x n matrices A and B and store the result in C. */ + +void matmult (int n) +{ + int i,j,k; + + for (i = 0; i < n; i++) + for (j = 0; j < n; j++) + for (k = 0; k < n; k++) + A[i][j] += B[i][k] * C[k][j]; +} + +/* This one fails because the number of iterations cannot be + determined anymore for the outermost loop. */ +/* { 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-mvt.c b/gcc/testsuite/gcc.dg/graphite/scop-mvt.c new file mode 100644 index 000000000..1181cdad0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/scop-mvt.c @@ -0,0 +1,24 @@ +#define NMAX 2000 + +static double x1[NMAX], x2[NMAX], a[NMAX][NMAX], y_1[NMAX], y_2[NMAX]; + +void mvt(long N) { + + 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]; + } + } +} + +/* { dg-final { scan-tree-dump-times "number of SCoPs: 2" 1 "graphite" } } */ +/* { dg-final { cleanup-tree-dump "graphite" } } */ + diff --git a/gcc/testsuite/gcc.dg/graphite/scop-sor.c b/gcc/testsuite/gcc.dg/graphite/scop-sor.c new file mode 100644 index 000000000..32c120731 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/scop-sor.c @@ -0,0 +1,18 @@ +#define SIZE 10000 + +static double P[SIZE][SIZE]; + +void sor(int N1, int N2){ + int i, j, k; + +#pragma scop + for(i=1; i<N1-1; i++) { + for(j=1; j<N2-1; j++) { + P[i][j] = (P[i][j] + P[i][j-1] + P[i][j+1] + P[i-1][j] + P[i+1][j]) / 5; + } + } +#pragma endscop +} + +/* { 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/vect-pr43423.c b/gcc/testsuite/gcc.dg/graphite/vect-pr43423.c new file mode 100644 index 000000000..bd685a651 --- /dev/null +++ b/gcc/testsuite/gcc.dg/graphite/vect-pr43423.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ + +int a[100], b[100], c[100]; + +void foo(int n, int mid) +{ + int i; + for(i=0; i<n; i++) + { + if (i < mid) + a[i] = a[i] + b[i]; + else + a[i] = a[i] + c[i]; + } +} + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ |