Index: testsuite/gcc.dg/vect/no-section-anchors-vect-36.c =================================================================== *** testsuite/gcc.dg/vect/no-section-anchors-vect-36.c (revision 0) --- testsuite/gcc.dg/vect/no-section-anchors-vect-36.c (revision 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" } } */ Index: testsuite/gcc.dg/vect/slp-25.c =================================================================== *** testsuite/gcc.dg/vect/slp-25.c (revision 129723) --- testsuite/gcc.dg/vect/slp-25.c (working copy) *************** *** 7,17 **** /* Unaligned stores. */ int main1 (int n) { int i; - int ia[N+1]; - short sa[N+1]; for (i = 1; i <= N/2; i++) { --- 7,18 ---- /* Unaligned stores. */ + int ia[N+1]; + short sa[N+1]; + int main1 (int n) { int i; for (i = 1; i <= N/2; i++) { Index: testsuite/gcc.dg/vect/vect-34.c =================================================================== *** testsuite/gcc.dg/vect/vect-34.c (revision 129723) --- testsuite/gcc.dg/vect/vect-34.c (working copy) *************** *** 8,18 **** __attribute__ ((noinline)) int main1 () { struct { char ca[N]; } s; char cb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; - int i; for (i = 0; i < N; i++) { --- 8,18 ---- __attribute__ ((noinline)) int main1 () { + int i; struct { char ca[N]; } s; char cb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; for (i = 0; i < N; i++) { *************** int main (void) *** 37,41 **** } /* { 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" } } */ --- 37,40 ---- Index: testsuite/gcc.dg/vect/vect-17.c =================================================================== *** testsuite/gcc.dg/vect/vect-17.c (revision 129723) --- testsuite/gcc.dg/vect/vect-17.c (working copy) *************** *** 5,14 **** #define N 64 - __attribute__ ((noinline)) int - main1 () - { - int i; int ia[N]; int ib[N]= {1,1,0,0,1,0,1,0, --- 5,10 ---- *************** main1 () *** 72,77 **** --- 68,77 ---- 1,1,0,0,1,0,1,0, 1,1,0,0,1,0,1,0}; + __attribute__ ((noinline)) int + main1 () + { + int i; /* Check ints. */ for (i = 0; i < N; i++) Index: testsuite/gcc.dg/vect/vect-76.c =================================================================== *** testsuite/gcc.dg/vect/vect-76.c (revision 129723) --- testsuite/gcc.dg/vect/vect-76.c (working copy) *************** int main (void) *** 71,75 **** /* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } */ - /* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 2 "vect" { xfail vect_no_align } } } */ /* { dg-final { cleanup-tree-dump "vect" } } */ --- 71,74 ---- Index: testsuite/gcc.dg/vect/no-scevccp-outer-6-global.c =================================================================== *** testsuite/gcc.dg/vect/no-scevccp-outer-6-global.c (revision 0) --- testsuite/gcc.dg/vect/no-scevccp-outer-6-global.c (revision 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 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" } } */ Index: testsuite/gcc.dg/vect/vect-68.c =================================================================== *** testsuite/gcc.dg/vect/vect-68.c (revision 129723) --- testsuite/gcc.dg/vect/vect-68.c (working copy) *************** int main (void) *** 86,91 **** } /* { dg-final { scan-tree-dump-times "vectorized 4 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" } } */ --- 86,89 ---- Index: testsuite/gcc.dg/vect/vect-18.c =================================================================== *** testsuite/gcc.dg/vect/vect-18.c (revision 129723) --- testsuite/gcc.dg/vect/vect-18.c (working copy) *************** *** 5,14 **** #define N 64 - __attribute__ ((noinline)) int - main1 () - { - int i; int ia[N]; int ib[N]= {1,1,0,0,1,0,1,0, --- 5,10 ---- *************** main1 () *** 71,76 **** --- 67,76 ---- 1,1,0,0,1,0,1,0, 1,1,0,0,1,0,1,0}; + __attribute__ ((noinline)) int + main1 () + { + int i; /* Check ints. */ for (i = 0; i < N; i++) Index: testsuite/gcc.dg/vect/vect-77.c =================================================================== *** testsuite/gcc.dg/vect/vect-77.c (revision 129723) --- testsuite/gcc.dg/vect/vect-77.c (working copy) *************** int main (void) *** 42,52 **** 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" } } */ --- 42,46 ---- Index: testsuite/gcc.dg/vect/vect-2.c =================================================================== *** testsuite/gcc.dg/vect/vect-2.c (revision 129723) --- testsuite/gcc.dg/vect/vect-2.c (working copy) *************** *** 5,15 **** #define N 16 __attribute__ ((noinline)) int main1 () { - char cb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; - char ca[N]; int i; for (i = 0; i < N; i++) --- 5,16 ---- #define N 16 + char cb[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + char ca[N]; + __attribute__ ((noinline)) int main1 () { int i; for (i = 0; i < N; i++) Index: testsuite/gcc.dg/vect/vect-27.c =================================================================== *** testsuite/gcc.dg/vect/vect-27.c (revision 129723) --- testsuite/gcc.dg/vect/vect-27.c (working copy) *************** *** 7,18 **** /* unaligned load. */ __attribute__ ((noinline)) int main1 () { int i; - int ia[N]; - int ib[N+1]; for (i=0; i <= N; i++) { --- 7,19 ---- /* unaligned load. */ + int ia[N]; + int ib[N+1]; + __attribute__ ((noinline)) int main1 () { int i; for (i=0; i <= N; i++) { Index: testsuite/gcc.dg/vect/vect-86.c =================================================================== *** testsuite/gcc.dg/vect/vect-86.c (revision 129723) --- testsuite/gcc.dg/vect/vect-86.c (working copy) *************** *** 5,15 **** #define N 16 __attribute__ ((noinline)) int main1 (int n) { int i, j, k; ! int a[N], b[N]; for (i = 0; i < n; i++) { --- 5,17 ---- #define N 16 + int a[N]; + __attribute__ ((noinline)) int main1 (int n) { int i, j, k; ! int b[N]; for (i = 0; i < n; i++) { Index: testsuite/gcc.dg/vect/vect-36.c =================================================================== *** testsuite/gcc.dg/vect/vect-36.c (revision 129723) --- testsuite/gcc.dg/vect/vect-36.c (working copy) *************** *** 8,18 **** __attribute__ ((noinline)) int main1 () { struct { char ca[N]; char cb[N]; } s; ! int i; for (i = 0; i < N; i++) { --- 8,19 ---- __attribute__ ((noinline)) int main1 () { + int i; struct { char ca[N]; char cb[N]; } s; ! for (i = 0; i < N; i++) { *************** int main (void) *** 42,47 **** } /* { 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" } } */ --- 43,46 ---- Index: testsuite/gcc.dg/vect/vect-19.c =================================================================== *** testsuite/gcc.dg/vect/vect-19.c (revision 129723) --- testsuite/gcc.dg/vect/vect-19.c (working copy) *************** *** 5,14 **** #define N 64 - __attribute__ ((noinline)) int - main1 () - { - int i; int ia[N]; int ib[N]= {1,1,0,0,1,0,1,0, --- 5,10 ---- *************** main1 () *** 71,76 **** --- 67,76 ---- 1,1,0,0,1,0,1,0, 1,1,0,0,1,0,1,0}; + __attribute__ ((noinline)) int + main1 () + { + int i; /* Check ints. */ for (i = 0; i < N; i++) Index: testsuite/gcc.dg/vect/vect-78.c =================================================================== *** testsuite/gcc.dg/vect/vect-78.c (revision 129723) --- testsuite/gcc.dg/vect/vect-78.c (working copy) *************** int main1 (int *ib) *** 24,30 **** ia[i] = ib[i+off]; } - /* check results: */ for (i = 0; i < N; i++) { --- 24,29 ---- *************** int main (void) *** 43,53 **** 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" } } */ --- 42,46 ---- Index: testsuite/gcc.dg/vect/no-section-anchors-vect-64.c =================================================================== *** testsuite/gcc.dg/vect/no-section-anchors-vect-64.c (revision 0) --- testsuite/gcc.dg/vect/no-section-anchors-vect-64.c (revision 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" } } */ Index: testsuite/gcc.dg/vect/vect-3.c =================================================================== *** testsuite/gcc.dg/vect/vect-3.c (revision 129723) --- testsuite/gcc.dg/vect/vect-3.c (working copy) *************** *** 6,23 **** #define N 20 __attribute__ ((noinline)) int main1 () { int i; - 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]; for (i = 0; i < N; i++) { --- 6,24 ---- #define N 20 + 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]; + __attribute__ ((noinline)) int main1 () { int i; for (i = 0; i < N; i++) { Index: testsuite/gcc.dg/vect/vect-78-alignchecks.c =================================================================== *** testsuite/gcc.dg/vect/vect-78-alignchecks.c (revision 0) --- testsuite/gcc.dg/vect/vect-78-alignchecks.c (revision 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" } } */ Index: testsuite/gcc.dg/vect/vect-all.c =================================================================== *** testsuite/gcc.dg/vect/vect-all.c (revision 129723) --- testsuite/gcc.dg/vect/vect-all.c (working copy) *************** fbar2 (float *a) *** 65,70 **** --- 65,81 ---- 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. */ *************** __attribute__ ((noinline)) int *** 72,88 **** 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++) --- 83,88 ---- Index: testsuite/gcc.dg/vect/vect-20.c =================================================================== *** testsuite/gcc.dg/vect/vect-20.c (revision 129723) --- testsuite/gcc.dg/vect/vect-20.c (working copy) *************** *** 5,14 **** #define N 64 - __attribute__ ((noinline)) int - main1 () - { - int i; int ia[N]; int ib[N]= {1,1,0,0,1,0,1,0, --- 5,10 ---- *************** main1 () *** 42,47 **** --- 38,47 ---- 1,1,0,0,1,0,1,0, 1,1,0,0,1,0,1,0}; + __attribute__ ((noinline)) int + main1 () + { + int i; /* Check ints. */ Index: testsuite/gcc.dg/vect/no-section-anchors-vect-31.c =================================================================== *** testsuite/gcc.dg/vect/no-section-anchors-vect-31.c (revision 0) --- testsuite/gcc.dg/vect/no-section-anchors-vect-31.c (revision 0) *************** *** 0 **** --- 1,92 ---- + /* { dg-require-effective-target vect_int } */ + + #include + #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 + #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" } } */ Index: testsuite/gcc.dg/vect/vect-4.c =================================================================== *** testsuite/gcc.dg/vect/vect-4.c (revision 129723) --- testsuite/gcc.dg/vect/vect-4.c (working copy) *************** *** 5,17 **** #define N 20 __attribute__ ((noinline)) int main1 () { int i; - float a[N]; - float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57}; - float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; for (i = 0; i < N; i++) { --- 5,18 ---- #define N 20 + float a[N]; + float b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45,48,51,54,57}; + float c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; + __attribute__ ((noinline)) int main1 () { int i; for (i = 0; i < N; i++) { Index: testsuite/gcc.dg/vect/vect-77-alignchecks.c =================================================================== *** testsuite/gcc.dg/vect/vect-77-alignchecks.c (revision 0) --- testsuite/gcc.dg/vect/vect-77-alignchecks.c (revision 0) *************** *** 0 **** --- 1,56 ---- + /* { 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}; + + __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" } } */ Index: testsuite/gcc.dg/vect/vect-21.c =================================================================== *** testsuite/gcc.dg/vect/vect-21.c (revision 129723) --- testsuite/gcc.dg/vect/vect-21.c (working copy) *************** *** 5,14 **** #define N 64 - __attribute__ ((noinline)) int - main1 () - { - int i; int ia[N]; int ib[N]= {1,1,0,0,1,0,1,0, --- 5,10 ---- *************** main1 () *** 71,76 **** --- 67,76 ---- 1,1,0,0,1,0,1,0, 1,1,0,0,1,0,1,0}; + __attribute__ ((noinline)) int + main1 () + { + int i; /* Check ints. */ for (i = 0; i < N; i++) Index: testsuite/gcc.dg/vect/vect-29.c =================================================================== *** testsuite/gcc.dg/vect/vect-29.c (revision 129723) --- testsuite/gcc.dg/vect/vect-29.c (working copy) *************** *** 8,19 **** /* unaligned load. */ __attribute__ ((noinline)) int main1 (int off) { int i; - int ia[N]; - int ib[N+OFF]; for (i = 0; i < N+OFF; i++) { --- 8,20 ---- /* unaligned load. */ + int ia[N]; + int ib[N+OFF]; + __attribute__ ((noinline)) int main1 (int off) { int i; for (i = 0; i < N+OFF; i++) { Index: testsuite/gcc.dg/vect/vect-13.c =================================================================== *** testsuite/gcc.dg/vect/vect-13.c (revision 129723) --- testsuite/gcc.dg/vect/vect-13.c (working copy) *************** *** 7,18 **** int a[N]; int results[N] = {0,1,2,3,0,0,0,0,0,0,0,0,12,13,14,15}; __attribute__ ((noinline)) int main1() { int i; - int b[N] = {0,1,2,3,-4,-5,-6,-7,-8,-9,-10,-11,12,13,14,15}; /* Max pattern. */ for (i = 0; i < N; i++) --- 7,18 ---- int a[N]; int results[N] = {0,1,2,3,0,0,0,0,0,0,0,0,12,13,14,15}; + int b[N] = {0,1,2,3,-4,-5,-6,-7,-8,-9,-10,-11,12,13,14,15}; __attribute__ ((noinline)) int main1() { int i; /* Max pattern. */ for (i = 0; i < N; i++) Index: testsuite/gcc.dg/vect/vect-72.c =================================================================== *** testsuite/gcc.dg/vect/vect-72.c (revision 129723) --- testsuite/gcc.dg/vect/vect-72.c (working copy) *************** *** 7,18 **** /* unaligned load. */ __attribute__ ((noinline)) int main1 () { int i; - char ia[N]; - char ib[N+1]; for (i=0; i < N+1; i++) { --- 7,19 ---- /* unaligned load. */ + char ia[N]; + char ib[N+1]; + __attribute__ ((noinline)) int main1 () { int i; for (i=0; i < N+1; i++) { Index: testsuite/gcc.dg/vect/no-section-anchors-vect-66.c =================================================================== *** testsuite/gcc.dg/vect/no-section-anchors-vect-66.c (revision 0) --- testsuite/gcc.dg/vect/no-section-anchors-vect-66.c (revision 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" } } */ Index: testsuite/gcc.dg/vect/vect-5.c =================================================================== *** testsuite/gcc.dg/vect/vect-5.c (revision 129723) --- testsuite/gcc.dg/vect/vect-5.c (working copy) *************** *** 5,17 **** #define N 16 __attribute__ ((noinline)) int main1 () { int i, j; - float a[N]; - 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}; i = 0; j = 0; --- 5,18 ---- #define N 16 + float a[N]; + 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}; + __attribute__ ((noinline)) int main1 () { int i, j; i = 0; j = 0; Index: testsuite/gcc.dg/vect/vect-22.c =================================================================== *** testsuite/gcc.dg/vect/vect-22.c (revision 129723) --- testsuite/gcc.dg/vect/vect-22.c (working copy) *************** *** 6,15 **** #define N 64 - __attribute__ ((noinline)) int - main1 () - { - int i; int ia[N]; int ib[N]= {1,1,0,0,1,0,1,0, --- 6,11 ---- *************** main1 () *** 54,59 **** --- 50,59 ---- 1,1,0,0,1,0,1,0, 1,1,0,0,1,0,1,0}; + __attribute__ ((noinline)) int + main1 () + { + int i; /* Check ints. */ for (i = 0; i < N; i++) Index: testsuite/gcc.dg/vect/vect-64.c =================================================================== *** testsuite/gcc.dg/vect/vect-64.c (revision 129723) --- testsuite/gcc.dg/vect/vect-64.c (working copy) *************** *** 5,15 **** #define N 16 __attribute__ ((noinline)) int main1 () { int i, j; - 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]; --- 5,16 ---- #define N 16 + int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + __attribute__ ((noinline)) int main1 () { int i, j; int ia[N][4][N+1]; int ic[N][N][3][13]; int id[N][N][N]; *************** int main (void) *** 82,87 **** } /* { 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" } } */ --- 83,86 ---- Index: testsuite/gcc.dg/vect/vect.exp =================================================================== *** testsuite/gcc.dg/vect/vect.exp (revision 129723) --- testsuite/gcc.dg/vect/vect.exp (working copy) *************** lappend DEFAULT_VECTCFLAGS "-O2" *** 109,115 **** dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/nodump-*.\[cS\]]] \ "" $DEFAULT_VECTCFLAGS ! lappend DEFAULT_VECTCFLAGS "-fdump-tree-vect-details" # Main loop. dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/pr*.\[cS\]]] \ --- 109,115 ---- dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/nodump-*.\[cS\]]] \ "" $DEFAULT_VECTCFLAGS ! lappend DEFAULT_VECTCFLAGS "-fdump-tree-vect-details" # Main loop. dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/pr*.\[cS\]]] \ Index: testsuite/gcc.dg/vect/vect-31.c =================================================================== *** testsuite/gcc.dg/vect/vect-31.c (revision 129723) --- testsuite/gcc.dg/vect/vect-31.c (working copy) *************** int main (void) *** 87,92 **** } /* { dg-final { scan-tree-dump-times "vectorized 4 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" } } */ --- 87,90 ---- Index: testsuite/gcc.dg/vect/vect-73.c =================================================================== *** testsuite/gcc.dg/vect/vect-73.c (revision 129723) --- testsuite/gcc.dg/vect/vect-73.c (working copy) *************** *** 6,11 **** --- 6,12 ---- #define N 16 int ic[N*2]; + int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; #define ia (ic+N) *************** __attribute__ ((noinline)) *** 13,19 **** int main1 () { int i, j; - int ib[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; for (i = 0; i < N; i++) { --- 14,19 ---- Index: testsuite/gcc.dg/vect/vect-78-global.c =================================================================== *** testsuite/gcc.dg/vect/vect-78-global.c (revision 0) --- testsuite/gcc.dg/vect/vect-78-global.c (revision 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" } } */ Index: testsuite/gcc.dg/vect/vect-6.c =================================================================== *** testsuite/gcc.dg/vect/vect-6.c (revision 129723) --- testsuite/gcc.dg/vect/vect-6.c (working copy) *************** *** 7,21 **** float results1[N] = {192.00,240.00,288.00,336.00,384.00,432.00,480.00,528.00,0.00}; float results2[N] = {0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,54.00,120.00,198.00,288.00,390.00,504.00,630.00}; __attribute__ ((noinline)) int main1 () { int i; - float a[N] = {0}; - float e[N] = {0}; - 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}; for (i = 0; i < N/2; i++) { --- 7,21 ---- float results1[N] = {192.00,240.00,288.00,336.00,384.00,432.00,480.00,528.00,0.00}; float results2[N] = {0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,54.00,120.00,198.00,288.00,390.00,504.00,630.00}; + float a[N] = {0}; + float e[N] = {0}; + 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}; __attribute__ ((noinline)) int main1 () { int i; for (i = 0; i < N/2; i++) { Index: testsuite/gcc.dg/vect/vect-65.c =================================================================== *** testsuite/gcc.dg/vect/vect-65.c (revision 129723) --- testsuite/gcc.dg/vect/vect-65.c (working copy) *************** int main (void) *** 80,84 **** } /* { 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" } } */ --- 80,83 ---- Index: testsuite/gcc.dg/vect/no-section-anchors-vect-34.c =================================================================== *** testsuite/gcc.dg/vect/no-section-anchors-vect-34.c (revision 0) --- testsuite/gcc.dg/vect/no-section-anchors-vect-34.c (revision 0) *************** *** 0 **** --- 1,42 ---- + /* { dg-require-effective-target vect_int } */ + + #include + #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" } } */ Index: testsuite/gcc.dg/vect/wrapv-vect-7.c =================================================================== *** testsuite/gcc.dg/vect/wrapv-vect-7.c (revision 129723) --- testsuite/gcc.dg/vect/wrapv-vect-7.c (working copy) *************** *** 5,15 **** #define N 128 int main1 () { int i; - short sa[N]; - short sb[N]; for (i = 0; i < N; i++) { --- 5,16 ---- #define N 128 + short sa[N]; + short sb[N]; + int main1 () { int i; for (i = 0; i < N; i++) { Index: testsuite/gcc.dg/vect/no-scevccp-outer-6.c =================================================================== *** testsuite/gcc.dg/vect/no-scevccp-outer-6.c (revision 129723) --- testsuite/gcc.dg/vect/no-scevccp-outer-6.c (working copy) *************** int main (void) *** 51,56 **** return 0; } ! /* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED." 1 "vect" { xfail vect_no_align } } } */ /* { dg-final { scan-tree-dump-times "vect_recog_widen_mult_pattern: detected" 1 "vect" { xfail *-*-* } } } */ /* { dg-final { cleanup-tree-dump "vect" } } */ --- 51,56 ---- return 0; } ! /* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED." 1 "vect" { xfail { unaligned_stack || vect_no_align } } } } */ /* { dg-final { scan-tree-dump-times "vect_recog_widen_mult_pattern: detected" 1 "vect" { xfail *-*-* } } } */ /* { dg-final { cleanup-tree-dump "vect" } } */ Index: testsuite/gcc.dg/vect/no-section-anchors-vect-68.c =================================================================== *** testsuite/gcc.dg/vect/no-section-anchors-vect-68.c (revision 0) --- testsuite/gcc.dg/vect/no-section-anchors-vect-68.c (revision 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 = 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. # Index: tree-vectorizer.c =================================================================== *** tree-vectorizer.c (revision 129723) --- tree-vectorizer.c (working copy) *************** vect_can_force_dr_alignment_p (const_tre *** 1606,1617 **** 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); } --- 1606,1614 ---- if (TREE_STATIC (decl)) return (alignment <= MAX_OFILE_ALIGNMENT); else ! /* This used to be PREFERRED_STACK_BOUNDARY, however, that is not 100% ! correct until someone implements forced stack alignment. */ ! return (alignment <= STACK_BOUNDARY); }