re PR target/32893 (zlib segfault in inflate_table() compiled w/ -O -msse2 ftree...
authorDorit Nuzman <dorit@il.ibm.com>
Tue, 30 Oct 2007 05:25:10 +0000 (05:25 +0000)
committerDorit Nuzman <dorit@gcc.gnu.org>
Tue, 30 Oct 2007 05:25:10 +0000 (05:25 +0000)
        PR tree-optimization/32893
        * tree-vectorize.c (vect_can_force_dr_alignment_p): Check
        STACK_BOUNDARY instead of PREFERRED_STACK_BOUNDARY.

From-SVN: r129764

51 files changed:
gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/costmodel/i386/costmodel-vect-31.c
gcc/testsuite/gcc.dg/vect/costmodel/x86_64/costmodel-vect-31.c
gcc/testsuite/gcc.dg/vect/no-scevccp-outer-6-global.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/no-scevccp-outer-6.c
gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-31.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-34.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-36.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-64.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-65.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-66.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-68.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/slp-25.c
gcc/testsuite/gcc.dg/vect/vect-13.c
gcc/testsuite/gcc.dg/vect/vect-17.c
gcc/testsuite/gcc.dg/vect/vect-18.c
gcc/testsuite/gcc.dg/vect/vect-19.c
gcc/testsuite/gcc.dg/vect/vect-2.c
gcc/testsuite/gcc.dg/vect/vect-20.c
gcc/testsuite/gcc.dg/vect/vect-21.c
gcc/testsuite/gcc.dg/vect/vect-22.c
gcc/testsuite/gcc.dg/vect/vect-27.c
gcc/testsuite/gcc.dg/vect/vect-29.c
gcc/testsuite/gcc.dg/vect/vect-3.c
gcc/testsuite/gcc.dg/vect/vect-31.c
gcc/testsuite/gcc.dg/vect/vect-34.c
gcc/testsuite/gcc.dg/vect/vect-36.c
gcc/testsuite/gcc.dg/vect/vect-4.c
gcc/testsuite/gcc.dg/vect/vect-5.c
gcc/testsuite/gcc.dg/vect/vect-6.c
gcc/testsuite/gcc.dg/vect/vect-64.c
gcc/testsuite/gcc.dg/vect/vect-65.c
gcc/testsuite/gcc.dg/vect/vect-66.c
gcc/testsuite/gcc.dg/vect/vect-68.c
gcc/testsuite/gcc.dg/vect/vect-7.c
gcc/testsuite/gcc.dg/vect/vect-72.c
gcc/testsuite/gcc.dg/vect/vect-73.c
gcc/testsuite/gcc.dg/vect/vect-76.c
gcc/testsuite/gcc.dg/vect/vect-77-alignchecks.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/vect-77-global.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/vect-77.c
gcc/testsuite/gcc.dg/vect/vect-78-alignchecks.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/vect-78-global.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/vect-78.c
gcc/testsuite/gcc.dg/vect/vect-86.c
gcc/testsuite/gcc.dg/vect/vect-all.c
gcc/testsuite/gcc.dg/vect/vect.exp
gcc/testsuite/gcc.dg/vect/wrapv-vect-7.c
gcc/testsuite/lib/target-supports.exp
gcc/tree-vectorizer.c

index 8e85aae9a07fbc76e007ac613897cbb76416f179..9e7199f0bb3a5b2a7b2b00eb9639e4737e8c7f1b 100644 (file)
@@ -1,3 +1,9 @@
+2007-10-29  Dorit Nuzman  <dorit@il.ibm.com>
+
+       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  <rask@sygehus.dk>
 
        * longlong.h (add_ssaaaa): Support Intel asm syntax in i386 and
index b60bf928784f6cdff4f35b8326287e4266c04bfc..5befb1c01dc11575fede982639d7e76ec4be29c9 100644 (file)
@@ -1,3 +1,63 @@
+2007-10-29  Dorit Nuzman  <dorit@il.ibm.com>
+
+       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  <jakub@redhat.com>
 
        PR tree-optimization/33723
index efab30d4ac6c5a08c7d9766f996b100c5518d444..c61517aab42884329c26c9abf0242779b6bbb004 100644 (file)
@@ -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++)
index efab30d4ac6c5a08c7d9766f996b100c5518d444..c61517aab42884329c26c9abf0242779b6bbb004 100644 (file)
@@ -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 (file)
index 0000000..a87367b
--- /dev/null
@@ -0,0 +1,58 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#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<N; i++)
+    b[i] = i + 2;
+
+  for (i=0; i<N; i++)
+    a[i] = foo (b,i);
+
+    /* check results:  */
+  for (i=0; i<N; i++)
+    {
+      sum = b[i];
+      for (j = 0; j < N; j++){
+        sum += j;
+      }
+      if (a[i] != sum)
+        abort();
+    }
+
+  return 0;
+}
+
+/* "Too many BBs in loop"  */
+/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED." 1 "vect" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-times "vect_recog_widen_mult_pattern: detected" 1 "vect" { xfail *-*-* } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
index 58edfb5b129ee4924e6cade58a97d8bcbf9f4170..70cf520d950062aff454bfda2fbb68ba0faa47f0 100644 (file)
@@ -51,6 +51,6 @@ int main (void)
   return 0;
 }
 
-/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED." 1 "vect" { xfail vect_no_align } } } */
+/* { 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" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-31.c b/gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-31.c
new file mode 100644 (file)
index 0000000..21b87a3
--- /dev/null
@@ -0,0 +1,92 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#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 <N/2; i++)
+    {
+      if (tmp.b[i] != 5)
+        abort ();
+    }
+
+  /* aligned */
+  for (i = 0; i < N/2; i++)
+    {
+      tmp.c[i] = 6;
+    }
+
+  /* check results:  */
+  for (i = 0; i <N/2; i++)
+    {
+      if (tmp.c[i] != 6)
+        abort ();
+    }
+
+  /* aligned */
+  for (i = 0; i < N/2; i++)
+    {
+      tmp.d.k[i] = 7;
+    }
+
+  /* check results:  */
+  for (i = 0; i <N/2; i++)
+    {
+      if (tmp.d.k[i] != 7)
+        abort ();
+    }
+
+  /* unaligned */
+  for (i = 0; i < N/2; i++)
+    {
+      tmp.e.k[i] = 8;
+    }
+
+  /* check results:  */
+  for (i = 0; i <N/2; i++)
+    {
+      if (tmp.e.k[i] != 8)
+        abort ();
+    }
+
+  return 0;
+}
+
+int main (void)
+{ 
+  check_vect ();
+  
+  return main1 ();
+} 
+
+/* { 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" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-34.c b/gcc/testsuite/gcc.dg/vect/no-section-anchors-vect-34.c
new file mode 100644 (file)
index 0000000..2eac33e
--- /dev/null
@@ -0,0 +1,42 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#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 (file)
index 0000000..351463b
--- /dev/null
@@ -0,0 +1,48 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#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 (file)
index 0000000..1ce3fa7
--- /dev/null
@@ -0,0 +1,88 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#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 (file)
index 0000000..b1e74a9
--- /dev/null
@@ -0,0 +1,85 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#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 (file)
index 0000000..2be14ea
--- /dev/null
@@ -0,0 +1,84 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#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 (file)
index 0000000..de036e8
--- /dev/null
@@ -0,0 +1,92 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#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 <N; i++)
+    {
+      if (tmp1.a.n[1][2][i] != 5)
+        abort ();
+    }
+
+  /* 2. aligned */
+  for (i = 3; i < N-1; i++)
+    {
+      tmp1.a.n[1][2][i] = 6;
+    }
+
+  /* check results:  */
+  for (i = 3; i < N-1; i++)
+    {
+      if (tmp1.a.n[1][2][i] != 6)
+        abort ();
+    }
+
+  /* 3. aligned */
+  for (i = 0; i < N; i++)
+    {
+      tmp1.e.n[1][2][i] = 7;
+    }
+
+  /* check results:  */
+  for (i = 0; i < N; i++)
+    {
+      if (tmp1.e.n[1][2][i] != 7)
+        abort ();
+    }
+
+  /* 4. unaligned */
+  for (i = 3; i < N-3; i++)
+    {
+      tmp1.e.n[1][2][i] = 8;
+    }
+  /* check results:  */
+  for (i = 3; i <N-3; i++)
+    {
+      if (tmp1.e.n[1][2][i] != 8)
+        abort ();
+    }
+
+  return 0;
+}
+
+int main (void)
+{ 
+  check_vect ();
+  
+  return main1 ();
+} 
+
+/* { 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" } } */
index 21f1900dc206fcda595f364cc24a0310e91ed5f3..0b62a29bf68f8a3cc5186d1978b0474e140245a1 100644 (file)
@@ -7,11 +7,12 @@
 
 /* Unaligned stores.  */
 
+int ia[N+1];
+short sa[N+1];
+
 int main1 (int n)
 {
   int i;
-  int ia[N+1];
-  short sa[N+1];
 
   for (i = 1; i <= N/2; i++)
     {
index 5cbec8753ad14662f91b5b6e9c77683c292e2baf..ba8665bdc07b7861547c64092d2c624febe5f380 100644 (file)
@@ -7,12 +7,12 @@
 
 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;
-  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++)
index 57c72413e1b7770744b76b6f30385f5929ad08e7..f1bef7f49f2625e49f9756b89494512c9820ceb7 100644 (file)
@@ -5,10 +5,6 @@
 
 #define N 64
 
-__attribute__ ((noinline)) int
-main1 ()
-{
-  int i;
   int ia[N];
   int ib[N]= 
     {1,1,0,0,1,0,1,0,
@@ -72,6 +68,10 @@ main1 ()
      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 caf6952c3bb876335766c90189e9cc15f0b325ed..8a2baab3a8ef8d477623324e95e92b7b96844478 100644 (file)
@@ -5,10 +5,6 @@
 
 #define N 64
 
-__attribute__ ((noinline)) int
-main1 ()
-{
-  int i;
   int ia[N];
   int ib[N]= 
     {1,1,0,0,1,0,1,0,
@@ -71,6 +67,10 @@ main1 ()
      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 6a2df60aef09f6d4edeac62d8e4b5bc8e0a51055..022ba1f756546d13692d7111fe0660918cb15bb8 100644 (file)
@@ -5,10 +5,6 @@
 
 #define N 64
 
-__attribute__ ((noinline)) int
-main1 ()
-{
-  int i;
   int ia[N];
   int ib[N]= 
     {1,1,0,0,1,0,1,0,
@@ -71,6 +67,10 @@ main1 ()
      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 21daf79b37973ff62c67e4c98518089a888acf55..5d4fc914a970dd6ee73d1581dd30153a5aac8b3d 100644 (file)
@@ -5,11 +5,12 @@
 
 #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 ()
 {  
-  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++)
index 33479b170c0149ba74d8d8a7db05b0d55e3fe2fa..deed2da44721b14b5c4d955ed5476d212587afd2 100644 (file)
@@ -5,10 +5,6 @@
 
 #define N 64
 
-__attribute__ ((noinline)) int
-main1 ()
-{
-  int i;
   int ia[N];
   int ib[N]= 
     {1,1,0,0,1,0,1,0,
@@ -42,6 +38,10 @@ main1 ()
      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 d0d9c2c6df38fa08c7c1f2276229d0e15fc92a0c..7a57506a208738e2beef6835618839cb80fd46b1 100644 (file)
@@ -5,10 +5,6 @@
 
 #define N 64
 
-__attribute__ ((noinline)) int
-main1 ()
-{
-  int i;
   int ia[N];
   int ib[N]= 
     {1,1,0,0,1,0,1,0,
@@ -71,6 +67,10 @@ main1 ()
      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 c7fe6bf59e9b7da22b562eb5f035f1377d5239bf..369fab112e5a5f902eddc828be8a656e5952672a 100644 (file)
@@ -6,10 +6,6 @@
 
 #define N 64
 
-__attribute__ ((noinline)) int
-main1 ()
-{
-  int i;
   int ia[N];
   int ib[N]= 
     {1,1,0,0,1,0,1,0,
@@ -54,6 +50,10 @@ main1 ()
      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 376d6d49425ff428484489f03b37b16953eb94b6..4a2da227e3c5804f2273a2680fe733c3753cfaca 100644 (file)
@@ -7,12 +7,13 @@
 
 /* unaligned load.  */
 
+int ia[N];
+int ib[N+1];
+
 __attribute__ ((noinline))
 int main1 ()
 {
   int i;
-  int ia[N];
-  int ib[N+1];
 
   for (i=0; i <= N; i++)
     {
index ac12c8225dbbb8d5adb41d7ec9caac1c226e80fa..0ad28488056a65827b6b19ab7127404b8ecec0b5 100644 (file)
@@ -8,12 +8,13 @@
 
 /* unaligned load.  */
 
+int ia[N];
+int ib[N+OFF];
+
 __attribute__ ((noinline))
 int main1 (int off)
 {
   int i;
-  int ia[N];
-  int ib[N+OFF];
 
   for (i = 0; i < N+OFF; i++)
     {
index 026c2a4cbae279ebcb5ff21d58437fcc57881df0..d494deb8507011dbf632e9d58aa97d24c78baaec 100644 (file)
@@ -6,18 +6,19 @@
 
 #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;
-  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++)
     {
index 67bb0de68b860c545c125b99de357a232155783b..8719fc9d27ef9cae46d0ee70c64ef8ac40566b54 100644 (file)
@@ -87,6 +87,4 @@ int main (void)
 } 
 
 /* { 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" } } */
index 7dc176bcfef75b3ab50b86ab2deaf2c2085289b2..4e80bd4cbf20778378d8a66a1f27fdb489cc1128 100644 (file)
@@ -8,11 +8,11 @@
 __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};
-  int i;
 
   for (i = 0; i < N; i++)
     {
@@ -37,5 +37,4 @@ int main (void)
 } 
 
 /* { 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 65a1d30a7a2dd00919acb2d95c639e6df6e60a68..bc6232dd111133396a8cf3989f9f7af462ff8817 100644 (file)
@@ -8,11 +8,12 @@
 __attribute__ ((noinline))
 int main1 ()
 {  
+  int i;
   struct {
     char ca[N];
     char cb[N];
   } s;
-  int i;
+
 
   for (i = 0; i < N; i++)
     {
@@ -42,6 +43,4 @@ int main (void)
 } 
 
 /* { 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 17ae2879f54efc6b5e827c2431c0efeeb60a0ee1..d86fea11e7967b2c2e0ed08f599d6b1e0e7b9f0f 100644 (file)
@@ -5,13 +5,14 @@
 
 #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;
-  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++)
     {
index 291a05ee12910fa6d39ca40fa990e039553844cc..b5938ceae8dac2145d87cd594191aa5ac4c09157 100644 (file)
@@ -5,13 +5,14 @@
 
 #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;
-  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;
index 7ad5192d71e885be063081e5bc8d14e3dbeafeb1..5f2e0ea59364cabb817d01dec61f1eacc5f3027b 100644 (file)
@@ -7,15 +7,15 @@
 
 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;
-  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++)
     { 
index e3d6855530793f8d8c5f2494319028bdf81ea3dd..4f9d97bbb2ba8796da1e730122d642fe849d6aed 100644 (file)
@@ -5,11 +5,12 @@
 
 #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 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];
@@ -82,6 +83,4 @@ int main (void)
 }
 
 /* { 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 614b8f75a8e0df6b84be14b08bd16dbfa4c07991..ba3ab3a9b15750ec53129e130fe3eb0872286ce1 100644 (file)
@@ -80,5 +80,4 @@ int main (void)
 }
 
 /* { 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 6d37d05bc46f018ef8cb9256241254504429df5b..4f93bc05d675348ed00c8f90316602f2ff77f7ac 100644 (file)
@@ -78,6 +78,4 @@ int main (void)
 }
 
 /* { 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 511de7bc422f89d9ae1a43039c9fe3c8ed96af4e..c4f8857ba8adbc6325ac525fb24b8e3a08a4b3e1 100644 (file)
@@ -86,6 +86,4 @@ int main (void)
 } 
 
 /* { 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" } } */
index 3b31a629519588f9c5c66d542bd2c1b0f80078dd..35dc08bbd2cb7ecbde0fa32ee82905f8488649fb 100644 (file)
@@ -5,12 +5,13 @@
 
 #define N 128
 
+short sa[N];
+short sb[N];
+
 __attribute__ ((noinline))
 int main1 ()
 {
   int i;
-  short sa[N];
-  short sb[N];
   
   for (i = 0; i < N; i++)
     {
index 3d678a8c58c8174cdaa766ff353ee60bfe29f0a6..95bc7caede07b5b32fe537828c46a11545e38c96 100644 (file)
@@ -7,12 +7,13 @@
 
 /* unaligned load.  */
 
+char ia[N];
+char ib[N+1];
+
 __attribute__ ((noinline))
 int main1 ()
 {
   int i;
-  char ia[N];
-  char ib[N+1];
 
   for (i=0; i < N+1; i++)
     {
index a19d198456355705453616986af466668d80796f..ee3c6e60e15be974b387d8c101f7ad19a38b209a 100644 (file)
@@ -6,6 +6,7 @@
 #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)
 
@@ -13,7 +14,6 @@ __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};
 
   for (i = 0; i < N; i++)
     {
index 1902f0c648d164142dac6f892aacca052ef67dd5..908ccd249c3f2dec53e3cb38687f4cd297151fb9 100644 (file)
@@ -71,5 +71,4 @@ int main (void)
 
 
 /* { 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" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-77-alignchecks.c b/gcc/testsuite/gcc.dg/vect/vect-77-alignchecks.c
new file mode 100644 (file)
index 0000000..a3d1b4c
--- /dev/null
@@ -0,0 +1,56 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#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 (file)
index 0000000..38f1443
--- /dev/null
@@ -0,0 +1,53 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#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 d443804133ca4560788f5cd6f35981cc214c29f6..a6eb2ad8f23b9f0e6d993b150ff9d757b0872582 100644 (file)
@@ -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 (file)
index 0000000..5c97b41
--- /dev/null
@@ -0,0 +1,57 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#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 (file)
index 0000000..dccc839
--- /dev/null
@@ -0,0 +1,53 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#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 bcf885816883aedeebc2856f7372e2f2919a02df..67ce20fda1bcaf50ec88328b80dd941e6d03d27c 100644 (file)
@@ -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" } } */
index a1183b55ecd8b59ca9a6b0e447ce97721d3158c5..334e54ee46ddf88fa4d78e9f79ceb1a6daf5d061 100644 (file)
@@ -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++)
     {
index 29bd3ea2f6ed951fdcd1fa6f447c0202f7bcf687..6adb7bf88bd09ea50cc6141259502e89f55975f5 100644 (file)
@@ -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++)
index e58f5809d095e30253d16a928af4a132f46eb020..ad7683381fc027d42c87cd92823babea041f8c9f 100644 (file)
@@ -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\]]]  \
index ffc5eaca5cafbfdb5630b7fd51afccf28c311188..5d495440f364c853eeea308293ace82b3c306768 100644 (file)
@@ -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++)
     {
index e4e9c589e2f275d0a0b2a3dac456cd5c32430ee5..5fe2059dc1e9c184e7e608b127b6145902888530 100644 (file)
@@ -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.
 #
index 29acfac5289f467a69d22bbdcc1e59f13a5d3c36..43b51a7da195f63de10a24fbb60b28bd9145e7e6 100644 (file)
@@ -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); 
 }