From a96681aaee89f85afacb8172be5ca6dd3342f9c0 Mon Sep 17 00:00:00 2001 From: Dorit Nuzman Date: Tue, 30 Oct 2007 05:25:10 +0000 Subject: re PR target/32893 (zlib segfault in inflate_table() compiled w/ -O -msse2 ftree-vectorize) PR tree-optimization/32893 * tree-vectorize.c (vect_can_force_dr_alignment_p): Check STACK_BOUNDARY instead of PREFERRED_STACK_BOUNDARY. From-SVN: r129764 --- gcc/ChangeLog | 6 ++ gcc/testsuite/ChangeLog | 60 ++++++++++++++ .../gcc.dg/vect/costmodel/i386/costmodel-vect-31.c | 3 +- .../vect/costmodel/x86_64/costmodel-vect-31.c | 3 +- .../gcc.dg/vect/no-scevccp-outer-6-global.c | 58 ++++++++++++++ gcc/testsuite/gcc.dg/vect/no-scevccp-outer-6.c | 2 +- .../gcc.dg/vect/no-section-anchors-vect-31.c | 92 ++++++++++++++++++++++ .../gcc.dg/vect/no-section-anchors-vect-34.c | 42 ++++++++++ .../gcc.dg/vect/no-section-anchors-vect-36.c | 48 +++++++++++ .../gcc.dg/vect/no-section-anchors-vect-64.c | 88 +++++++++++++++++++++ .../gcc.dg/vect/no-section-anchors-vect-65.c | 85 ++++++++++++++++++++ .../gcc.dg/vect/no-section-anchors-vect-66.c | 84 ++++++++++++++++++++ .../gcc.dg/vect/no-section-anchors-vect-68.c | 92 ++++++++++++++++++++++ gcc/testsuite/gcc.dg/vect/slp-25.c | 5 +- gcc/testsuite/gcc.dg/vect/vect-13.c | 2 +- gcc/testsuite/gcc.dg/vect/vect-17.c | 8 +- gcc/testsuite/gcc.dg/vect/vect-18.c | 8 +- gcc/testsuite/gcc.dg/vect/vect-19.c | 8 +- gcc/testsuite/gcc.dg/vect/vect-2.c | 5 +- gcc/testsuite/gcc.dg/vect/vect-20.c | 8 +- gcc/testsuite/gcc.dg/vect/vect-21.c | 8 +- gcc/testsuite/gcc.dg/vect/vect-22.c | 8 +- gcc/testsuite/gcc.dg/vect/vect-27.c | 5 +- gcc/testsuite/gcc.dg/vect/vect-29.c | 5 +- gcc/testsuite/gcc.dg/vect/vect-3.c | 17 ++-- gcc/testsuite/gcc.dg/vect/vect-31.c | 2 - gcc/testsuite/gcc.dg/vect/vect-34.c | 3 +- gcc/testsuite/gcc.dg/vect/vect-36.c | 5 +- gcc/testsuite/gcc.dg/vect/vect-4.c | 7 +- gcc/testsuite/gcc.dg/vect/vect-5.c | 7 +- gcc/testsuite/gcc.dg/vect/vect-6.c | 8 +- gcc/testsuite/gcc.dg/vect/vect-64.c | 5 +- gcc/testsuite/gcc.dg/vect/vect-65.c | 1 - gcc/testsuite/gcc.dg/vect/vect-66.c | 2 - gcc/testsuite/gcc.dg/vect/vect-68.c | 2 - gcc/testsuite/gcc.dg/vect/vect-7.c | 5 +- gcc/testsuite/gcc.dg/vect/vect-72.c | 5 +- gcc/testsuite/gcc.dg/vect/vect-73.c | 2 +- gcc/testsuite/gcc.dg/vect/vect-76.c | 1 - gcc/testsuite/gcc.dg/vect/vect-77-alignchecks.c | 56 +++++++++++++ gcc/testsuite/gcc.dg/vect/vect-77-global.c | 53 +++++++++++++ gcc/testsuite/gcc.dg/vect/vect-77.c | 6 -- gcc/testsuite/gcc.dg/vect/vect-78-alignchecks.c | 57 ++++++++++++++ gcc/testsuite/gcc.dg/vect/vect-78-global.c | 53 +++++++++++++ gcc/testsuite/gcc.dg/vect/vect-78.c | 7 -- gcc/testsuite/gcc.dg/vect/vect-86.c | 4 +- gcc/testsuite/gcc.dg/vect/vect-all.c | 22 +++--- gcc/testsuite/gcc.dg/vect/vect.exp | 2 +- gcc/testsuite/gcc.dg/vect/wrapv-vect-7.c | 5 +- gcc/testsuite/lib/target-supports.exp | 21 +++++ gcc/tree-vectorizer.c | 9 +-- 51 files changed, 991 insertions(+), 109 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/vect/no-scevccp-outer-6-global.c create mode 100644 gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-31.c create mode 100644 gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-34.c create mode 100644 gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-36.c create mode 100644 gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-64.c create mode 100644 gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-65.c create mode 100644 gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-66.c create mode 100644 gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-68.c create mode 100644 gcc/testsuite/gcc.dg/vect/vect-77-alignchecks.c create mode 100644 gcc/testsuite/gcc.dg/vect/vect-77-global.c create mode 100644 gcc/testsuite/gcc.dg/vect/vect-78-alignchecks.c create mode 100644 gcc/testsuite/gcc.dg/vect/vect-78-global.c (limited to 'gcc') diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8e85aae..9e7199f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2007-10-29 Dorit Nuzman + + PR tree-optimization/32893 + * tree-vectorize.c (vect_can_force_dr_alignment_p): Check + STACK_BOUNDARY instead of PREFERRED_STACK_BOUNDARY. + 2007-10-29 Rask Ingemann Lambertsen * longlong.h (add_ssaaaa): Support Intel asm syntax in i386 and diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b60bf92..5befb1c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,63 @@ +2007-10-29 Dorit Nuzman + + PR tree-optimization/32893 + * testsuite/lib/target-supports.exp + (check_effective_target_unaligned_stack): new keyword. + * testsuite/gcc.dg/vect/vect-2.c: Globalize arrays to make the test + not sensitive to unaligned_stack. + * testsuite/gcc.dg/vect/vect-3.c: Likewise. + * testsuite/gcc.dg/vect/vect-4.c: Likewise. + * testsuite/gcc.dg/vect/vect-5.c: Likewise. + * testsuite/gcc.dg/vect/vect-6.c: Likewise. + * testsuite/gcc.dg/vect/vect-7.c: Likewise. + * testsuite/gcc.dg/vect/vect-13.c: Likewise. + * testsuite/gcc.dg/vect/vect-17.c: Likewise. + * testsuite/gcc.dg/vect/vect-18.c: Likewise. + * testsuite/gcc.dg/vect/vect-19.c: Likewise. + * testsuite/gcc.dg/vect/vect-20.c: Likewise. + * testsuite/gcc.dg/vect/vect-21.c: Likewise. + * testsuite/gcc.dg/vect/vect-22.c: Likewise. + * testsuite/gcc.dg/vect/vect-27.c: Likewise. + * testsuite/gcc.dg/vect/vect-29.c: Likewise. + * testsuite/gcc.dg/vect/vect-64.c: Likewise. + * testsuite/gcc.dg/vect/vect-65.c: Likewise. + * testsuite/gcc.dg/vect/vect-66.c: Likewise. + * testsuite/gcc.dg/vect/vect-72.c: Likewise. + * testsuite/gcc.dg/vect/vect-73.c: Likewise. + * testsuite/gcc.dg/vect/vect-86.c: Likewise. + * testsuite/gcc.dg/vect/vect-all.c: Likewise. + * testsuite/gcc.dg/vect/slp-25.c: Likewise. + * testsuite/gcc.dg/vect/wrapv-vect-7.c: Likewise. + * testsuite/gcc.dg/vect/costmodel/i386/costmodel-vect-31.c: Likewise. + * testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-vect-31.c: Likewise. + + * testsuite/gcc.dg/vect/vect-31.c: Removed alignment checks. + * testsuite/gcc.dg/vect/vect-34.c: Likewise. + * testsuite/gcc.dg/vect/vect-36.c: Likewise. + * testsuite/gcc.dg/vect/vect-64.c: Likewise. + * testsuite/gcc.dg/vect/vect-65.c: Likewise. + * testsuite/gcc.dg/vect/vect-66.c: Likewise. + * testsuite/gcc.dg/vect/vect-68.c: Likewise. + * testsuite/gcc.dg/vect/vect-76.c: Likewise. + * testsuite/gcc.dg/vect/vect-77.c: Likewise. + * testsuite/gcc.dg/vect/vect-78.c: Likewise. + + * testsuite/gcc.dg/vect/no-section-anchors-vect-31.c: New test, Like the + original testcase (without no-section-anchors prefix) but with global arrays. + * testsuite/gcc.dg/vect/no-section-anchors-vect-34.c: Likewise. + * testsuite/gcc.dg/vect/no-section-anchors-vect-36.c: Likewsie. + * testsuite/gcc.dg/vect/no-section-anchors-vect-64.c: Likewise. + * testsuite/gcc.dg/vect/no-section-anchors-vect-65.c: Likewise. + * testsuite/gcc.dg/vect/no-section-anchors-vect-66.c: Likewise. + * testsuite/gcc.dg/vect/no-section-anchors-vect-68.c: Likewise. + * testsuite/gcc.dg/vect/vect-77-global.c: Likewise. + * testsuite/gcc.dg/vect/vect-78-global.c: Likewise. + + * testsuite/gcc.dg/vect/vect-77-alignchecks.c: New test. Like the + original testcase (without no-section-anchors prefix) but fix alignment checks + to also consider unaligned_stack targets. + * testsuite/gcc.dg/vect/vect-78-alignchecks.c: Likewise. + 2007-10-29 Jakub Jelinek PR tree-optimization/33723 diff --git a/gcc/testsuite/gcc.dg/vect/costmodel/i386/costmodel-vect-31.c b/gcc/testsuite/gcc.dg/vect/costmodel/i386/costmodel-vect-31.c index efab30d..c61517a 100644 --- a/gcc/testsuite/gcc.dg/vect/costmodel/i386/costmodel-vect-31.c +++ b/gcc/testsuite/gcc.dg/vect/costmodel/i386/costmodel-vect-31.c @@ -18,10 +18,11 @@ struct s{ struct t e; /* unaligned (offset 2N+4N+4 B) */ }; +struct s tmp; + int main1 () { int i; - struct s tmp; /* unaligned */ for (i = 0; i < N/2; i++) diff --git a/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-vect-31.c b/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-vect-31.c index efab30d..c61517a 100644 --- a/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-vect-31.c +++ b/gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-vect-31.c @@ -18,10 +18,11 @@ struct s{ struct t e; /* unaligned (offset 2N+4N+4 B) */ }; +struct s tmp; + int main1 () { int i; - struct s tmp; /* unaligned */ for (i = 0; i < N/2; i++) diff --git a/gcc/testsuite/gcc.dg/vect/no-scevccp-outer-6-global.c b/gcc/testsuite/gcc.dg/vect/no-scevccp-outer-6-global.c new file mode 100644 index 0000000..a87367b --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/no-scevccp-outer-6-global.c @@ -0,0 +1,58 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 40 + +int a[N]; + +__attribute__ ((noinline)) int +foo (int * __restrict__ b, int k){ + int i,j; + int sum,x; + + for (i = 0; i < N; i++) { + sum = b[i]; + for (j = 0; j < N; j++) { + sum += j; + } + a[i] = sum; + } + + return a[k]; +} + +int main (void) +{ + int i,j; + int sum; + int b[N]; + int a[N]; + + check_vect (); + + for (i=0; i +#include "tree-vect.h" + +#define N 32 + +struct t{ + int k[N]; + int l; +}; + +struct s{ + char a; /* aligned */ + char b[N-1]; /* unaligned (offset 1B) */ + char c[N]; /* aligned (offset NB) */ + struct t d; /* aligned (offset 2NB) */ + struct t e; /* unaligned (offset 2N+4N+4 B) */ +}; + +struct s tmp; +__attribute__ ((noinline)) +int main1 () +{ + int i; + + /* unaligned */ + for (i = 0; i < N/2; i++) + { + tmp.b[i] = 5; + } + + /* check results: */ + for (i = 0; i +#include "tree-vect.h" + +#define N 16 + +struct { + char ca[N]; +} s; +char cb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + + for (i = 0; i < N; i++) + { + s.ca[i] = cb[i]; + } + + /* check results: */ + for (i = 0; i < N; i++) + { + if (s.ca[i] != cb[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-36.c b/gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-36.c new file mode 100644 index 0000000..351463b --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-36.c @@ -0,0 +1,48 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +struct { + char ca[N]; + char cb[N]; +} s; + +__attribute__ ((noinline)) +int main1 () +{ + int i; + + for (i = 0; i < N; i++) + { + s.cb[i] = 3*i; + } + + for (i = 0; i < N; i++) + { + s.ca[i] = s.cb[i]; + } + + /* check results: */ + for (i = 0; i < N; i++) + { + if (s.ca[i] != s.cb[i]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 0 "vect" } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-64.c b/gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-64.c new file mode 100644 index 0000000..1ce3fa7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-64.c @@ -0,0 +1,88 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +int ia[N][4][N+1]; +int ic[N][N][3][13]; +int id[N][N][N]; + +__attribute__ ((noinline)) +int main1 () +{ + int i, j; + + /* Multidimensional array. Not aligned: vectorizable. */ + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) + { + ia[i][1][j] = ib[i]; + } + } + + /* Multidimensional array. Aligned: vectorizable. */ + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) + { + ic[i][1][1][j] = ib[i]; + } + } + + /* Multidimensional array. Not aligned: vectorizable. */ + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) + { + id[i][1][j+1] = ib[i]; + } + } + + /* check results: */ + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) + { + if (ia[i][1][j] != ib[i]) + abort(); + } + } + + /* check results: */ + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) + { + if (ic[i][1][1][j] != ib[i]) + abort(); + } + } + + /* check results: */ + for (i = 0; i < N; i++) + { + for (j = 0; j < N; j++) + { + if (id[i][1][j+1] != ib[i]) + abort(); + } + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 2 "vect" } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-65.c b/gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-65.c new file mode 100644 index 0000000..b1e74a9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-65.c @@ -0,0 +1,85 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 +#define M 4 + +int ib[M][M][N] = {{{0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}}, + {{0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}}, + {{0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}}, + {{0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}, + {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}}}; +int ia[M][M][N]; +int ic[N]; + +__attribute__ ((noinline)) +int main1 () +{ + int i, j; + + /* Multidimensional array. Aligned. The "inner" dimensions + are invariant in the inner loop. Load and store. */ + for (i = 0; i < M; i++) + { + for (j = 0; j < N; j++) + { + ia[i][1][j] = ib[2][i][j]; + } + } + + /* check results: */ + for (i = 0; i < M; i++) + { + for (j = 0; j < N; j++) + { + if (ia[i][1][j] != ib[2][i][j]) + abort(); + } + } + + /* Multidimensional array. Aligned. The "inner" dimensions + are invariant in the inner loop. Load. */ + for (i = 0; i < M; i++) + { + for (j = 0; j < N; j++) + { + ic[j] = ib[2][i][j]; + } + } + + /* check results: */ + for (i = 0; i < M; i++) + { + for (j = 0; j < N; j++) + { + if (ic[j] != ib[2][i][j]) + abort(); + } + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-66.c b/gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-66.c new file mode 100644 index 0000000..2be14ea --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-66.c @@ -0,0 +1,84 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 16 + +int ib[6] = {0,3,6,9,12,15}; +int ia[8][5][6]; +int ic[16][16][5][6]; + +__attribute__ ((noinline)) +int main1 () +{ + int i, j; + + /* Multidimensional array. Aligned. */ + for (i = 0; i < 16; i++) + { + for (j = 0; j < 4; j++) + { + ia[2][6][j] = 5; + } + } + + /* check results: */ + for (i = 0; i < 16; i++) + { + for (j = 0; j < 4; j++) + { + if (ia[2][6][j] != 5) + abort(); + } + } + /* Multidimensional array. Aligned. */ + for (i = 0; i < 16; i++) + { + for (j = 0; j < 4; j++) + ia[3][6][j+2] = 5; + } + + /* check results: */ + for (i = 0; i < 16; i++) + { + for (j = 2; j < 6; j++) + { + if (ia[3][6][j] != 5) + abort(); + } + } + + /* Multidimensional array. Not aligned. */ + for (i = 0; i < 16; i++) + { + for (j = 0; j < 4; j++) + { + ic[2][1][6][j+1] = 5; + } + } + + /* check results: */ + for (i = 0; i < 16; i++) + { + for (j = 0; j < 4; j++) + { + if (ic[2][1][6][j+1] != 5) + abort(); + } + } + + return 0; +} + +int main (void) +{ + check_vect (); + + return main1 (); +} + +/* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-68.c b/gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-68.c new file mode 100644 index 0000000..de036e8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-68.c @@ -0,0 +1,92 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 32 + +struct s{ + int m; + int n[N][N][N]; +}; + +struct test1{ + struct s a; /* array a.n is unaligned */ + int b; + int c; + struct s e; /* array e.n is aligned */ +}; + +struct test1 tmp1; + +__attribute__ ((noinline)) +int main1 () +{ + int i,j; + + /* 1. unaligned */ + for (i = 0; i < N; i++) + { + tmp1.a.n[1][2][i] = 5; + } + + /* check results: */ + for (i = 0; i +#include "tree-vect.h" + +#define N 8 +#define OFF 8 + +/* Check handling of accesses for which the "initial condition" - + the expression that represents the first location accessed - is + more involved than just an ssa_name. */ + +int ib[N+OFF] __attribute__ ((__aligned__(16))) = {0, 1, 3, 5, 7, 11, 13, 17, 0, 2, 6, 10, 14, 22, 26, 34}; + +__attribute__ ((noinline)) +int main1 (int *ib, int off) +{ + int i; + int ia[N]; + + for (i = 0; i < N; i++) + { + ia[i] = ib[i+off]; + } + + + /* check results: */ + for (i = 0; i < N; i++) + { + if (ia[i] != ib[i+off]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (ib, 8); + return 0; +} + +/* For targets that don't support misaligned loads we version for the load. + The store is aligned if alignment can be forced on the stack. Otherwise, we need to + peel the loop in order to align the store. For targets that can't align variables + using peeling (don't guarantee natural alignment) versioning the loop is required + both for the load and the store. */ + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { xfail { vect_no_align } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { target { {! vect_no_align} && { unaligned_stack && vector_alignment_reachable } } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 1 "vect" { target { { {! unaligned_stack} && vect_no_align } || {unaligned_stack && { {! vector_alignment_reachable} && {! vect_no_align} } } } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 2 "vect" { target { { unaligned_stack && { vector_alignment_reachable && vect_no_align } } || {unaligned_stack && { {! vector_alignment_reachable} && vect_no_align } } } } } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-77-global.c b/gcc/testsuite/gcc.dg/vect/vect-77-global.c new file mode 100644 index 0000000..38f1443 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-77-global.c @@ -0,0 +1,53 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 8 +#define OFF 8 + +/* Check handling of accesses for which the "initial condition" - + the expression that represents the first location accessed - is + more involved than just an ssa_name. */ + +int ib[N+OFF] __attribute__ ((__aligned__(16))) = {0, 1, 3, 5, 7, 11, 13, 17, 0, 2, 6, 10, 14, 22, 26, 34}; +int ia[N]; + +__attribute__ ((noinline)) +int main1 (int *ib, int off) +{ + int i; + + for (i = 0; i < N; i++) + { + ia[i] = ib[i+off]; + } + + + /* check results: */ + for (i = 0; i < N; i++) + { + if (ia[i] != ib[i+off]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (ib, 8); + return 0; +} + +/* For targets that don't support misaligned loads we version for the load. + (The store is aligned). */ +/* Requires versioning for aliasing. */ + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { xfail { vect_no_align } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 1 "vect" { target vect_no_align } } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-77.c b/gcc/testsuite/gcc.dg/vect/vect-77.c index d443804..a6eb2ad 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-77.c +++ b/gcc/testsuite/gcc.dg/vect/vect-77.c @@ -42,11 +42,5 @@ int main (void) return 0; } -/* For targets that don't support misaligned loads we version for the load. - (The store is aligned). */ - /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ -/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { xfail { vect_no_align } } } } */ -/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 0 "vect" } } */ -/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 1 "vect" { target vect_no_align } } } */ /* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-78-alignchecks.c b/gcc/testsuite/gcc.dg/vect/vect-78-alignchecks.c new file mode 100644 index 0000000..5c97b41 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-78-alignchecks.c @@ -0,0 +1,57 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 8 +#define OFF 8 + +/* Check handling of accesses for which the "initial condition" - + the expression that represents the first location accessed - is + more involved than just an ssa_name. */ + +int ib[N+OFF] __attribute__ ((__aligned__(16))) = {0, 1, 3, 5, 7, 11, 13, 17, 0, 2, 6, 10, 14, 22, 26, 34}; +int off = 8; + +__attribute__ ((noinline)) +int main1 (int *ib) +{ + int i; + int ia[N]; + + for (i = 0; i < N; i++) + { + ia[i] = ib[i+off]; + } + + + /* check results: */ + for (i = 0; i < N; i++) + { + if (ia[i] != ib[i+off]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (ib); + return 0; +} + +/* For targets that don't support misaligned loads we version for the load. + The store is aligned if alignment can be forced on the stack. Otherwise, we need to + peel the loop in order to align the store. For targets that can't align variables + using peeling (don't guarantee natural alignment) versioning the loop is required + both for the load and the store. */ + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { xfail { vect_no_align } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 1 "vect" { target { {! vect_no_align} && { unaligned_stack && vector_alignment_reachable } } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 1 "vect" { target { { {! unaligned_stack} && vect_no_align } || {unaligned_stack && { {! vector_alignment_reachable} && {! vect_no_align} } } } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 2 "vect" { target { { unaligned_stack && { vector_alignment_reachable && vect_no_align } } || {unaligned_stack && { {! vector_alignment_reachable} && vect_no_align } } } } } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-78-global.c b/gcc/testsuite/gcc.dg/vect/vect-78-global.c new file mode 100644 index 0000000..dccc839 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-78-global.c @@ -0,0 +1,53 @@ +/* { dg-require-effective-target vect_int } */ + +#include +#include "tree-vect.h" + +#define N 8 +#define OFF 8 + +/* Check handling of accesses for which the "initial condition" - + the expression that represents the first location accessed - is + more involved than just an ssa_name. */ + +int ia[N]; +int ib[N+OFF] __attribute__ ((__aligned__(16))) = {0, 1, 3, 5, 7, 11, 13, 17, 0, 2, 6, 10, 14, 22, 26, 34}; +int off = 8; + +__attribute__ ((noinline)) +int main1 (int *ib) +{ + int i; + + for (i = 0; i < N; i++) + { + ia[i] = ib[i+off]; + } + + + /* check results: */ + for (i = 0; i < N; i++) + { + if (ia[i] != ib[i+off]) + abort (); + } + + return 0; +} + +int main (void) +{ + check_vect (); + + main1 (ib); + return 0; +} + +/* For targets that don't support misaligned loads we version for the load. + (The store is aligned). */ + +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { xfail { vect_no_align } } } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 0 "vect" } } */ +/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 1 "vect" { target vect_no_align } } } */ +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-78.c b/gcc/testsuite/gcc.dg/vect/vect-78.c index bcf8858..67ce20f 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-78.c +++ b/gcc/testsuite/gcc.dg/vect/vect-78.c @@ -24,7 +24,6 @@ int main1 (int *ib) ia[i] = ib[i+off]; } - /* check results: */ for (i = 0; i < N; i++) { @@ -43,11 +42,5 @@ int main (void) return 0; } -/* For targets that don't support misaligned loads we version for the load. - (The store is aligned). */ - /* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ -/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 1 "vect" { xfail { vect_no_align } } } } */ -/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 0 "vect" } } */ -/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning." 1 "vect" { target vect_no_align } } } */ /* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-86.c b/gcc/testsuite/gcc.dg/vect/vect-86.c index a1183b5..334e54e 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-86.c +++ b/gcc/testsuite/gcc.dg/vect/vect-86.c @@ -5,11 +5,13 @@ #define N 16 +int a[N]; + __attribute__ ((noinline)) int main1 (int n) { int i, j, k; - int a[N], b[N]; + int b[N]; for (i = 0; i < n; i++) { diff --git a/gcc/testsuite/gcc.dg/vect/vect-all.c b/gcc/testsuite/gcc.dg/vect/vect-all.c index 29bd3ea..6adb7bf 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-all.c +++ b/gcc/testsuite/gcc.dg/vect/vect-all.c @@ -65,6 +65,17 @@ fbar2 (float *a) fcheck_results (a, fresults2); } +float a[N]; +float e[N]; +float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; +float d[N] = {0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30}; +int ic[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +int ia[N]; +char cb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; +char ca[N]; +short sa[N]; /* All of the loops below are currently vectorizable. */ @@ -72,17 +83,6 @@ __attribute__ ((noinline)) int main1 () { int i,j; - float a[N]; - float e[N]; - float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; - float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; - float d[N] = {0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30}; - int ic[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; - int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; - int ia[N]; - char cb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; - char ca[N]; - short sa[N]; /* Test 1: copy chars. */ for (i = 0; i < N; i++) diff --git a/gcc/testsuite/gcc.dg/vect/vect.exp b/gcc/testsuite/gcc.dg/vect/vect.exp index e58f580..ad76833 100644 --- a/gcc/testsuite/gcc.dg/vect/vect.exp +++ b/gcc/testsuite/gcc.dg/vect/vect.exp @@ -109,7 +109,7 @@ lappend DEFAULT_VECTCFLAGS "-O2" dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/nodump-*.\[cS\]]] \ "" $DEFAULT_VECTCFLAGS -lappend DEFAULT_VECTCFLAGS "-fdump-tree-vect-details" +lappend DEFAULT_VECTCFLAGS "-fdump-tree-vect-details" # Main loop. dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/pr*.\[cS\]]] \ diff --git a/gcc/testsuite/gcc.dg/vect/wrapv-vect-7.c b/gcc/testsuite/gcc.dg/vect/wrapv-vect-7.c index ffc5eac..5d49544 100644 --- a/gcc/testsuite/gcc.dg/vect/wrapv-vect-7.c +++ b/gcc/testsuite/gcc.dg/vect/wrapv-vect-7.c @@ -5,11 +5,12 @@ #define N 128 +short sa[N]; +short sb[N]; + int main1 () { int i; - short sa[N]; - short sb[N]; for (i = 0; i < N; i++) { diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index e4e9c58..5fe2059 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -2109,6 +2109,27 @@ proc check_effective_target_vect_unpack { } { return $et_vect_unpack_saved } +# Return 1 if the target plus current options does not guarantee +# that its STACK_BOUNDARY is >= the reguired vector alignment. +# +# This won't change for different subtargets so cache the result. + +proc check_effective_target_unaligned_stack { } { + global et_unaligned_stack_saved + + if [info exists et_unaligned_stack_saved] { + verbose "check_effective_target_unaligned_stack: using cached result" 2 + } else { + set et_unaligned_stack_saved 0 + if { ( [istarget i?86-*-*] || [istarget x86_64-*-*] ) + && (! [istarget *-*-darwin*] ) } { + set et_unaligned_stack_saved 1 + } + } + verbose "check_effective_target_unaligned_stack: returning $et_unaligned_stack_saved" 2 + return $et_unaligned_stack_saved +} + # Return 1 if the target plus current options does not support a vector # alignment mechanism, 0 otherwise. # diff --git a/gcc/tree-vectorizer.c b/gcc/tree-vectorizer.c index 29acfac..43b51a7 100644 --- a/gcc/tree-vectorizer.c +++ b/gcc/tree-vectorizer.c @@ -1606,12 +1606,9 @@ vect_can_force_dr_alignment_p (const_tree decl, unsigned int alignment) if (TREE_STATIC (decl)) return (alignment <= MAX_OFILE_ALIGNMENT); else - /* This is not 100% correct. The absolute correct stack alignment - is STACK_BOUNDARY. We're supposed to hope, but not assume, that - PREFERRED_STACK_BOUNDARY is honored by all translation units. - However, until someone implements forced stack alignment, SSE - isn't really usable without this. */ - return (alignment <= PREFERRED_STACK_BOUNDARY); + /* This used to be PREFERRED_STACK_BOUNDARY, however, that is not 100% + correct until someone implements forced stack alignment. */ + return (alignment <= STACK_BOUNDARY); } -- cgit v1.1