aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/vect
diff options
context:
space:
mode:
authorIra Rosen <irar@il.ibm.com>2009-07-12 07:09:07 +0000
committerIra Rosen <irar@gcc.gnu.org>2009-07-12 07:09:07 +0000
commit06066f92aaea9e9b0fff53a693b300bb9aa1121a (patch)
tree7547f479237ee79f26fd81c529e65dfa6d42573b /gcc/testsuite/gcc.dg/vect
parentb20231fe2437d57d4b97aba62a0c28a68c9719dd (diff)
downloadgcc-06066f92aaea9e9b0fff53a693b300bb9aa1121a.zip
gcc-06066f92aaea9e9b0fff53a693b300bb9aa1121a.tar.gz
gcc-06066f92aaea9e9b0fff53a693b300bb9aa1121a.tar.bz2
tree-parloops.c (loop_parallel_p): Call vect_is_simple_reduction with additional argument.
* tree-parloops.c (loop_parallel_p): Call vect_is_simple_reduction with additional argument. * tree-vectorizer.h (enum vect_def_type): Add vect_double_reduction_def. (vect_is_simple_reduction): Add argument. * tree-vect-loop.c (vect_determine_vectorization_factor): Fix indentation. (vect_analyze_scalar_cycles_1): Detect double reduction. Call vect_is_simple_reduction with additional argument. (vect_analyze_loop_operations): Handle exit phi nodes in case of double reduction. (reduction_code_for_scalar_code): Handle additional codes by returning ERROR_MARK for them. Fix comment and indentation. (vect_is_simple_reduction): Fix comment, add argument to specify double reduction. Detect double reduction. (get_initial_def_for_induction): Fix indentation. (get_initial_def_for_reduction): Fix comment and indentation. Handle double reduction. Create initial definitions that do not require adjustment if ADJUSTMENT_DEF is NULL. Handle additional cases. (vect_create_epilog_for_reduction): Fix comment, add argument to handle double reduction. Use PLUS_EXPR in case of MINUS_EXPR in epilogue result extraction. Create double reduction phi node and replace relevant uses. (vectorizable_reduction): Call vect_is_simple_reduction with additional argument. Fix indentation. Update epilogue code treatment according to the changes in reduction_code_for_scalar_code. Check for double reduction. Call vect_create_epilog_for_reduction with additional argument. * tree-vect-stmts.c (process_use): Handle double reduction, update documentation. (vect_mark_stmts_to_be_vectorized): Handle double reduction. (vect_get_vec_def_for_operand): Likewise. From-SVN: r149526
Diffstat (limited to 'gcc/testsuite/gcc.dg/vect')
-rw-r--r--gcc/testsuite/gcc.dg/vect/no-scevccp-outer-2.c4
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-double-reduc-1.c56
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-double-reduc-2.c56
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-double-reduc-3.c67
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-double-reduc-4.c56
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-double-reduc-5.c58
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-double-reduc-6.c50
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-double-reduc-7.c65
8 files changed, 411 insertions, 1 deletions
diff --git a/gcc/testsuite/gcc.dg/vect/no-scevccp-outer-2.c b/gcc/testsuite/gcc.dg/vect/no-scevccp-outer-2.c
index a9ac09c..13b3788 100644
--- a/gcc/testsuite/gcc.dg/vect/no-scevccp-outer-2.c
+++ b/gcc/testsuite/gcc.dg/vect/no-scevccp-outer-2.c
@@ -1,4 +1,6 @@
/* { dg-do compile } */
+/* { dg-require-effective-target vect_int } */
+
#define N 40
int
@@ -14,5 +16,5 @@ foo (){
return diff;
}
-/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail *-*-* } } } */
+/* { 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-double-reduc-1.c b/gcc/testsuite/gcc.dg/vect/vect-double-reduc-1.c
new file mode 100644
index 0000000..e335842
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-double-reduc-1.c
@@ -0,0 +1,56 @@
+/* { dg-require-effective-target vect_int_mult } */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include "tree-vect.h"
+
+#define K 32
+
+int in[2*K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
+int coeff[K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
+int out[K];
+int check_result[K] = {642816,660736,678656,696576,714496,732416,750336,768256,786176,804096,822016,839936,857856,875776,893696,911616,929536,947456,965376,983296,1001216,1019136,1037056,1054976,1072896,1090816,1108736,1126656,1144576,1162496,1180416,1198336};
+
+__attribute__ ((noinline)) void
+foo ()
+{
+ int sum = 0, i, j, k;
+
+ for (k = 0; k < K; k++)
+ {
+ sum = 0;
+ for (j = 0; j < K; j++)
+ for (i = 0; i < K; i++)
+ sum += in[i+k][j] * coeff[i][j];
+
+ out[k] = sum;
+ }
+}
+
+int main ()
+{
+ int i, j, k;
+
+ check_vect ();
+
+ for (j = 0; j < K; j++)
+ {
+ for (i = 0; i < 2*K; i++)
+ in[i][j] = i+j;
+
+ for (i = 0; i < K; i++)
+ coeff[i][j] = i+2;
+ }
+
+ foo();
+
+ for (k = 0; k < K; k++)
+ if (out[k] != check_result[k])
+ abort ();
+
+ 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-double-reduc-2.c b/gcc/testsuite/gcc.dg/vect/vect-double-reduc-2.c
new file mode 100644
index 0000000..be469be
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-double-reduc-2.c
@@ -0,0 +1,56 @@
+/* { dg-require-effective-target vect_int_mult } */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include "tree-vect.h"
+
+#define K 32
+
+int in[2*K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
+int coeff[K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
+int out[K];
+int check_result[K] = {357184,339264,321344,303424,285504,267584,249664,231744,213824,195904,177984,160064,142144,124224,106304,88384,70464,52544,34624,16704,-1216,-19136,-37056,-54976,-72896,-90816,-108736,-126656,-144576,-162496,-180416,-198336};
+
+__attribute__ ((noinline)) void
+foo ()
+{
+ int res = 0, i, j, k;
+
+ for (k = 0; k < K; k++)
+ {
+ res = 1000000;
+ for (j = 0; j < K; j++)
+ for (i = 0; i < K; i++)
+ res -= in[i+k][j] * coeff[i][j];
+
+ out[k] = res;
+ }
+}
+
+int main ()
+{
+ int i, j, k;
+
+ check_vect ();
+
+ for (j = 0; j < K; j++)
+ {
+ for (i = 0; i < 2*K; i++)
+ in[i][j] = i+j;
+
+ for (i = 0; i < K; i++)
+ coeff[i][j] = i+2;
+ }
+
+ foo();
+
+ for (k = 0; k < K; k++)
+ if (out[k] != check_result[k])
+ abort ();
+
+ 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-double-reduc-3.c b/gcc/testsuite/gcc.dg/vect/vect-double-reduc-3.c
new file mode 100644
index 0000000..87b5a04
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-double-reduc-3.c
@@ -0,0 +1,67 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include "tree-vect.h"
+
+#define K 32
+
+int in[2*K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
+int coeff[K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
+int out_max[K], out_min[K];
+int check_max[K] = {62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93};
+int check_min[K] = {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};
+
+__attribute__ ((noinline)) void
+foo (int x, int y)
+{
+ int max, min, i, j, k;
+
+ for (k = 0; k < K; k++)
+ {
+ max = x;
+ min = y;
+ for (j = 0; j < K; j++)
+ for (i = 0; i < K; i++)
+ {
+ max = max < in[i+k][j] ? in[i+k][j] : max;
+ min = min > in[i+k][j] ? in[i+k][j] : min;
+ }
+ out_max[k] = max;
+ out_min[k] = min;
+ }
+}
+
+int main ()
+{
+ int i, j, k;
+
+ check_vect ();
+
+ for (j = 0; j < K; j++)
+ {
+ for (i = 0; i < 2*K; i++)
+ in[i][j] = i+j;
+
+ for (i = 0; i < K; i++)
+ coeff[i][j] = i+2;
+ }
+
+ foo(0, 0);
+
+ for (k = 0; k < K; k++)
+ if (out_max[k] != check_max[k] || out_min[k] != 0)
+ abort ();
+
+ foo(100, 45);
+
+ for (k = 0; k < K; k++)
+ if (out_min[k] != check_min[k] || out_max[k] != 100)
+ abort ();
+
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail vect_no_int_max } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
+
diff --git a/gcc/testsuite/gcc.dg/vect/vect-double-reduc-4.c b/gcc/testsuite/gcc.dg/vect/vect-double-reduc-4.c
new file mode 100644
index 0000000..90e0da7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-double-reduc-4.c
@@ -0,0 +1,56 @@
+/* { dg-require-effective-target vect_int_mult } */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include "tree-vect.h"
+
+#define K 32
+
+int in[2*K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
+int coeff[K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
+int out[K];
+int check_result[K] = {652816,670736,688656,706576,724496,742416,760336,778256,796176,814096,832016,849936,867856,885776,903696,921616,939536,957456,975376,993296,1011216,1029136,1047056,1064976,1082896,1100816,1118736,1136656,1154576,1172496,1190416,1208336};
+
+__attribute__ ((noinline)) void
+foo ()
+{
+ int sum = 0, i, j, k;
+
+ for (k = 0; k < K; k++)
+ {
+ sum = 10000;
+ for (j = 0; j < K; j++)
+ for (i = 0; i < K; i++)
+ sum += in[i+k][j] * coeff[i][j];
+
+ out[k] = sum;
+ }
+}
+
+int main ()
+{
+ int i, j, k;
+
+ check_vect ();
+
+ for (j = 0; j < K; j++)
+ {
+ for (i = 0; i < 2*K; i++)
+ in[i][j] = i+j;
+
+ for (i = 0; i < K; i++)
+ coeff[i][j] = i+2;
+ }
+
+ foo();
+
+ for (k = 0; k < K; k++)
+ if (out[k] != check_result[k])
+ abort ();
+
+ 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-double-reduc-5.c b/gcc/testsuite/gcc.dg/vect/vect-double-reduc-5.c
new file mode 100644
index 0000000..f624d86
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-double-reduc-5.c
@@ -0,0 +1,58 @@
+/* { dg-require-effective-target vect_int_mult } */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include "tree-vect.h"
+
+#define K 32
+
+signed short in[2*K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
+signed short coeff[K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
+int out[K];
+int check_result[K] = {642816,660736,678656,696576,714496,732416,750336,768256,786176,804096,822016,839936,857856,875776,893696,911616,929536,947456,965376,983296,1001216,1019136,1037056,1054976,1072896,1090816,1108736,1126656,1144576,1162496,1180416,1198336};
+
+__attribute__ ((noinline)) void
+foo ()
+{
+ int sum = 0, i, j, k;
+
+ for (k = 0; k < K; k++)
+ {
+ sum = 0;
+ for (j = 0; j < K; j++)
+ for (i = 0; i < K; i++)
+ sum += in[i+k][j] * coeff[i][j];
+
+ out[k] = sum;
+ }
+}
+
+int main ()
+{
+ int i, j, k;
+
+ check_vect ();
+
+ for (j = 0; j < K; j++)
+ {
+ for (i = 0; i < 2*K; i++)
+ in[i][j] = i+j;
+
+ for (i = 0; i < K; i++)
+ coeff[i][j] = i+2;
+ }
+
+ foo();
+
+ for (k = 0; k < K; k++)
+ if (out[k] != check_result[k])
+ abort ();
+
+ return 0;
+}
+
+/* Vectorization of loops with multiple types and double reduction is not
+ supported yet. */
+/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 1 "vect" { xfail *-*-* } } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
+
diff --git a/gcc/testsuite/gcc.dg/vect/vect-double-reduc-6.c b/gcc/testsuite/gcc.dg/vect/vect-double-reduc-6.c
new file mode 100644
index 0000000..f52b32b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-double-reduc-6.c
@@ -0,0 +1,50 @@
+/* { dg-require-effective-target vect_int_mult } */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include "tree-vect.h"
+
+#define K 4
+
+int in[2*K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
+int out[K];
+int check_result[K] = {0,16,256,4096};
+
+__attribute__ ((noinline)) void
+foo ()
+{
+ int sum;
+ int i, j, k;
+
+ for (k = 0; k < K; k++)
+ {
+ sum = 1;
+ for (j = 0; j < K; j++)
+ for (i = 0; i < K; i++)
+ sum *= in[i+k][j];
+ out[k] = sum;
+ }
+}
+
+int main ()
+{
+ int i, j, k;
+
+ check_vect ();
+
+ for (i = 0; i < 2*K; i++)
+ for (j = 0; j < K; j++)
+ in[i][j] = (i+2)/3;
+
+ foo();
+
+ for (k = 0; k < K; k++)
+ if (out[k] != check_result[k])
+ abort ();
+
+ 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-double-reduc-7.c b/gcc/testsuite/gcc.dg/vect/vect-double-reduc-7.c
new file mode 100644
index 0000000..9e7ced7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-double-reduc-7.c
@@ -0,0 +1,65 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include "tree-vect.h"
+
+#define K 32
+
+int in[2*K][K] __attribute__ ((__aligned__(__BIGGEST_ALIGNMENT__)));
+int out[K];
+int check_result[K] = {63,63,191,191,127,127,191,191,127,127,191,191,127,127,191,191,127,127,191,191,127,127,191,191,127,127,191,191,127,127,191,191};
+
+__attribute__ ((noinline)) void
+foo ()
+{
+ int res_or, res_and, res_xor, i, j, k;
+
+ for (k = 0; k < K; k++)
+ {
+ res_or = 0;
+ for (j = 0; j < K; j++)
+ for (i = 0; i < K; i++)
+ res_or = res_or | in[i+k][j];
+
+ res_and = 1;
+ for (j = 0; j < K; j++)
+ for (i = 0; i < K; i++)
+ res_and = res_and & in[i+k][j];
+
+ res_xor = 0;
+ for (j = 0; j < K; j++)
+ for (i = 0; i < K; i++)
+ res_xor = res_xor ^ in[i+k][j];
+
+ out[k] = res_or + res_and + res_xor;
+ }
+}
+
+int main ()
+{
+ int i, j, k;
+
+ check_vect ();
+
+ for (j = 0; j < K; j++)
+ {
+ for (i = 0; i < 2*K; i++)
+ in[i][j] = i+j;
+
+ for (i = 0; i < K; i++)
+ out[i] = i+j;
+ }
+
+ foo();
+
+ for (k = 0; k < K; k++)
+ if (out[k] != check_result[k])
+ abort ();
+
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "OUTER LOOP VECTORIZED" 3 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
+