aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/vect
diff options
context:
space:
mode:
authorIra Rosen <irar@il.ibm.com>2009-06-16 07:21:12 +0000
committerIra Rosen <irar@gcc.gnu.org>2009-06-16 07:21:12 +0000
commit7c5222ff1a2283b0f8c889da777c7dae5d4224ba (patch)
treeaaaf3e70f41a000974285e5e7f0db250fa701499 /gcc/testsuite/gcc.dg/vect
parent3ba558dba3cf0a581a1a70cf8e6de5c2d26dcf96 (diff)
downloadgcc-7c5222ff1a2283b0f8c889da777c7dae5d4224ba.zip
gcc-7c5222ff1a2283b0f8c889da777c7dae5d4224ba.tar.gz
gcc-7c5222ff1a2283b0f8c889da777c7dae5d4224ba.tar.bz2
tree-parloops.c (loop_parallel_p): Call vect_is_simple_reduction with additional parameter.
* tree-parloops.c (loop_parallel_p): Call vect_is_simple_reduction with additional parameter. * tree-vectorizer.h (enum vect_def_type): Add new value vect_nested_cycle. (enum vect_relevant): Add comments. (vect_is_simple_reduction): Add new argument. * tree-vect-loop.c (vect_analyze_scalar_cycles_1): Add comments. Detect nested cycles. (vect_is_simple_reduction): Update documentation, add an argument to distinguish inner-loop reduction from nested cycle, detect nested cycles, fix printings and indentation, don't swap operands in case of nested cycle. (get_initial_def_for_reduction): Handle subtraction. (vect_create_epilog_for_reduction): Add new argument to specify reduction variable. (vect_finalize_reduction): Handle subtraction, fix comments. (vectorizable_reduction): Handle nested cycles. In case of nested cycle keep track of the reduction variable position. Call vect_is_simple_reduction with additional parameter. Use original statement code in reduction epilogue for nested cycle. Call vect_create_epilog_for_reduction with additional parameter. * tree-vect-patterns.c (vect_recog_dot_prod_pattern): Assert inner-loop vectorization. (vect_recog_widen_sum_pattern): Likewise. * tree-vect-stmts.c (process_use): Distinguish between nested cycles and reductions. (vect_mark_stmts_to_be_vectorized): Likewise. (vect_get_vec_def_for_operand): Handle nested cycles. From-SVN: r148518
Diffstat (limited to 'gcc/testsuite/gcc.dg/vect')
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-nest-cycle-1.c48
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-nest-cycle-2.c48
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-nest-cycle-3.c57
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-outer-1a.c8
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-outer-4f.c1
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-outer-4g.c1
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-outer-4k.c1
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-outer-4l.c1
8 files changed, 155 insertions, 10 deletions
diff --git a/gcc/testsuite/gcc.dg/vect/vect-nest-cycle-1.c b/gcc/testsuite/gcc.dg/vect/vect-nest-cycle-1.c
new file mode 100644
index 0000000..0cf2ca0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-nest-cycle-1.c
@@ -0,0 +1,48 @@
+/* { dg-require-effective-target vect_float } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 16
+
+float in[N] = {232,132,32,432,532,321,327,323,321,324,322,329,432,832,932,232};
+float out[N];
+float check_res[N] = {112,-4,-120,264,348,121,111,91,73,60,42,33,120,504,588,-128};
+float a[2*N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31};
+
+/* Outer-loop vectorization. */
+
+__attribute__ ((noinline)) void
+foo ()
+{
+ int i, j;
+ float res;
+
+ for (i = 0; i < N; i++)
+ {
+ res = in[i];
+
+ for (j = 0; j < N; j++)
+ res = res - a[i+j];
+
+ out[i] = res;
+ }
+
+ for (i = 0; i < N; i++)
+ if (out[i] != check_res[i])
+ abort ();
+
+}
+
+int main ()
+{
+ check_vect ();
+
+ foo();
+
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
+
diff --git a/gcc/testsuite/gcc.dg/vect/vect-nest-cycle-2.c b/gcc/testsuite/gcc.dg/vect/vect-nest-cycle-2.c
new file mode 100644
index 0000000..fd63a78
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-nest-cycle-2.c
@@ -0,0 +1,48 @@
+/* { dg-require-effective-target vect_float } */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include "tree-vect.h"
+
+#define N 16
+
+float out[N];
+float check_res[N] = {880,864,848,832,816,800,784,768,752,736,720,704,688,672,656,640};
+float a[2*N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31};
+
+/* Outer-loop vectorization. */
+
+__attribute__ ((noinline)) void
+foo ()
+{
+ int i, j;
+ float res;
+
+ for (i = 0; i < N; i++)
+ {
+ res = 1000;
+
+ for (j = 0; j < N; j++)
+ res = res - a[i+j];
+
+ out[i] = res;
+ }
+
+ for (i = 0; i < N; i++)
+ if (out[i] != check_res[i])
+ abort ();
+
+}
+
+int main ()
+{
+ check_vect ();
+
+ foo();
+
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
+
diff --git a/gcc/testsuite/gcc.dg/vect/vect-nest-cycle-3.c b/gcc/testsuite/gcc.dg/vect/vect-nest-cycle-3.c
new file mode 100644
index 0000000..70fa6b8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-nest-cycle-3.c
@@ -0,0 +1,57 @@
+/* { dg-require-effective-target vect_float } */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include "tree-vect.h"
+
+#define N 16
+#define DIFF 82
+
+float c[N][N], b[N][N], a[N];
+
+__attribute__ ((noinline)) int
+main1 ()
+{
+ int i, j;
+ float diff;
+
+ /* In inner loop vectorization -funsafe-math-optimizations is needed to
+ vectorize the summation. But in outer loop vectorization the order of
+ calculation doesn't change, therefore, there is no need in that flag. */
+ for (i = 0; i < N; i++)
+ {
+ diff = 2;
+ for (j = 0; j < N; j++)
+ diff += (b[j][i] - c[j][i]);
+
+ a[i] = diff;
+ }
+
+ /* Check results: */
+ for (i = 0; i < N; i++)
+ if (a[i] != DIFF)
+ abort ();
+
+ return 0;
+}
+
+int main (void)
+{
+ int i, j;
+
+ for (i = 0; i < N; i++)
+ for (j = 0; j < N; j++)
+ {
+ b[i][j] = i+j+5;
+ c[i][j] = i+j;
+ }
+
+ check_vect ();
+
+ main1 ();
+
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-outer-1a.c b/gcc/testsuite/gcc.dg/vect/vect-outer-1a.c
index 3d237b7..f88dd21 100644
--- a/gcc/testsuite/gcc.dg/vect/vect-outer-1a.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-outer-1a.c
@@ -4,9 +4,7 @@
signed short image[N][N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
signed short block[N][N] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
-/* Can't do outer-loop vectorization because of non-consecutive access.
- Currently fails to vectorize because the reduction pattern is not
- recognized. */
+/* Can't do outer-loop vectorization because of non-consecutive access. */
int
foo (){
@@ -22,7 +20,5 @@ foo (){
}
/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail *-*-* } } } */
-/* FORNOW */
-/* { dg-final { scan-tree-dump-times "strided access in outer loop" 1 "vect" { xfail *-*-* } } } */
-/* { dg-final { scan-tree-dump-times "unexpected pattern" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "strided access in outer loop" 1 "vect" } } */
/* { dg-final { cleanup-tree-dump "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-outer-4f.c b/gcc/testsuite/gcc.dg/vect/vect-outer-4f.c
index 88d6b7a..c6cc4a8 100644
--- a/gcc/testsuite/gcc.dg/vect/vect-outer-4f.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-outer-4f.c
@@ -66,5 +66,4 @@ int main (void)
}
/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail *-*-* } } } */
-/* { dg-final { scan-tree-dump-times "vect_recog_widen_sum_pattern: not allowed" 1 "vect" } } */
/* { dg-final { cleanup-tree-dump "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-outer-4g.c b/gcc/testsuite/gcc.dg/vect/vect-outer-4g.c
index 88d6b7a..c6cc4a8 100644
--- a/gcc/testsuite/gcc.dg/vect/vect-outer-4g.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-outer-4g.c
@@ -66,5 +66,4 @@ int main (void)
}
/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail *-*-* } } } */
-/* { dg-final { scan-tree-dump-times "vect_recog_widen_sum_pattern: not allowed" 1 "vect" } } */
/* { dg-final { cleanup-tree-dump "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-outer-4k.c b/gcc/testsuite/gcc.dg/vect/vect-outer-4k.c
index 88d6b7a..c6cc4a8 100644
--- a/gcc/testsuite/gcc.dg/vect/vect-outer-4k.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-outer-4k.c
@@ -66,5 +66,4 @@ int main (void)
}
/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail *-*-* } } } */
-/* { dg-final { scan-tree-dump-times "vect_recog_widen_sum_pattern: not allowed" 1 "vect" } } */
/* { dg-final { cleanup-tree-dump "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-outer-4l.c b/gcc/testsuite/gcc.dg/vect/vect-outer-4l.c
index 88d6b7a..c6cc4a8 100644
--- a/gcc/testsuite/gcc.dg/vect/vect-outer-4l.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-outer-4l.c
@@ -66,5 +66,4 @@ int main (void)
}
/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail *-*-* } } } */
-/* { dg-final { scan-tree-dump-times "vect_recog_widen_sum_pattern: not allowed" 1 "vect" } } */
/* { dg-final { cleanup-tree-dump "vect" } } */