diff options
author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-06-28 07:33:11 +0000 |
---|---|---|
committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-06-28 07:33:11 +0000 |
commit | a75805eb0744ed246089823f3c9b77f6e890e9a0 (patch) | |
tree | a76aa441f59535fd8bdbfeb92703378a73e5d240 /gcc | |
parent | 41b1d2cc881aff58b11757d5408abd2a60251d9c (diff) | |
download | gcc-a75805eb0744ed246089823f3c9b77f6e890e9a0.tar.gz |
* tree-vect-transform.c (get_initial_def_for_reduction): Use correct
type for DEF and INIT_VAL. Pretend MIN/MAX need epilogue adjustment.
* gcc.dg/vect/vect-reduc-1.c: Adjust test to properly validate MIN.
* gcc.dg/vect/vect-reduc-1char.c: Likewise.
* gcc.dg/vect/vect-reduc-1short.c: Likewise.
* gcc.dg/vect/vect-reduc-2.c: Likewise.
* gcc.dg/vect/vect-reduc-2char.c: Likewise.
* gcc.dg/vect/vect-reduc-2short.c: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@101374 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/vect/vect-reduc-1.c | 17 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/vect/vect-reduc-1char.c | 17 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/vect/vect-reduc-1short.c | 17 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/vect/vect-reduc-2.c | 16 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/vect/vect-reduc-2char.c | 22 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/vect/vect-reduc-2short.c | 19 | ||||
-rw-r--r-- | gcc/tree-vect-transform.c | 27 |
9 files changed, 79 insertions, 70 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7bc4af658a3..4a537759a9b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2005-06-27 Richard Henderson <rth@redhat.com> + * tree-vect-transform.c (get_initial_def_for_reduction): Use correct + type for DEF and INIT_VAL. Pretend MIN/MAX need epilogue adjustment. + +2005-06-27 Richard Henderson <rth@redhat.com> + * config/i386/sse.md (vec_shl_<SSEMODEI>, vec_shr_<SSEMODEI>): New. (smaxv16qi3, umaxv8hi3, sminv16qi3, uminv8hi3): New. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 09e3e6564cf..4110b33e9ea 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,14 @@ 2005-06-27 Richard Henderson <rth@redhat.com> + * gcc.dg/vect/vect-reduc-1.c: Adjust test to properly validate MIN. + * gcc.dg/vect/vect-reduc-1char.c: Likewise. + * gcc.dg/vect/vect-reduc-1short.c: Likewise. + * gcc.dg/vect/vect-reduc-2.c: Likewise. + * gcc.dg/vect/vect-reduc-2char.c: Likewise. + * gcc.dg/vect/vect-reduc-2short.c: Likewise. + +2005-06-27 Richard Henderson <rth@redhat.com> + * gcc.dg/vect/vect-reduc-1short.c: Remove XFAIL. * gcc.dg/vect/vect-reduc-2char.c: Remove XFAIL. diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-1.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-1.c index bc87a5c62c8..a5825799380 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-reduc-1.c +++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-1.c @@ -8,14 +8,14 @@ /* Test vectorization of reduction of unsigned-int. */ -int main1 (unsigned int x, unsigned int max_result) +void main1 (unsigned int x, unsigned int max_result, unsigned int min_result) { int i; - unsigned int ub[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; - unsigned int uc[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + unsigned int ub[N] = {1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + unsigned int uc[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; unsigned int udiff = 2; unsigned int umax = x; - unsigned int umin = 10; + unsigned int umin = x; /* Summation. */ for (i = 0; i < N; i++) { @@ -37,18 +37,17 @@ int main1 (unsigned int x, unsigned int max_result) abort (); if (umax != max_result) abort (); - if (umin != 0) + if (umin != min_result) abort (); - - return 0; } int main (void) { check_vect (); - main1 (100, 100); - main1 (0, 15); + main1 (100, 100, 1); + main1 (0, 15, 0); + return 0; } /* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" { xfail i?86-*-* x86_64-*-* } } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-1char.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-1char.c index e85fa4a20c0..418687dd23b 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-reduc-1char.c +++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-1char.c @@ -6,14 +6,15 @@ #define N 16 #define DIFF 242 -int main1 (unsigned char x, unsigned char max_result) +void +main1 (unsigned char x, unsigned char max_result, unsigned char min_result) { int i; - unsigned char ub[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; - unsigned char uc[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + unsigned char ub[N] = {1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + unsigned char uc[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; unsigned char udiff = 2; unsigned char umax = x; - unsigned char umin = 10; + unsigned char umin = x; for (i = 0; i < N; i++) { udiff += (unsigned char)(ub[i] - uc[i]); @@ -32,18 +33,16 @@ int main1 (unsigned char x, unsigned char max_result) abort (); if (umax != max_result) abort (); - if (umin != 0) + if (umin != min_result) abort (); - - return 0; } int main (void) { check_vect (); - main1 (100, 100); - main1 (0, 15); + main1 (100, 100, 1); + main1 (0, 15, 0); return 0; } diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-1short.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-1short.c index 6212f4cfdcd..91d7abd1275 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-reduc-1short.c +++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-1short.c @@ -6,14 +6,15 @@ #define N 16 #define DIFF 242 -int main1 (unsigned short x, unsigned short max_result) +void +main1 (unsigned short x, unsigned short max_result, unsigned short min_result) { int i; - unsigned short ub[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; - unsigned short uc[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + unsigned short ub[N] = {1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + unsigned short uc[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; unsigned short udiff = 2; unsigned short umax = x; - unsigned short umin = 10; + unsigned short umin = x; for (i = 0; i < N; i++) { udiff += (unsigned short)(ub[i] - uc[i]); @@ -32,18 +33,16 @@ int main1 (unsigned short x, unsigned short max_result) abort (); if (umax != max_result) abort (); - if (umin != 0) + if (umin != min_result) abort (); - - return 0; } int main (void) { check_vect (); - main1 (100, 100); - main1 (0, 15); + main1 (100, 100, 1); + main1 (0, 15, 0); return 0; } diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-2.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-2.c index ca1a3da07e3..ef4499f761d 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-reduc-2.c +++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-2.c @@ -8,14 +8,14 @@ /* Test vectorization of reduction of signed-int. */ -int main1 (int x, int max_result) +void main1 (int x, int max_result, int min_result) { int i; - int b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; - int c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + int b[N] = {1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + int c[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; int diff = 0; int max = x; - int min = 10; + int min = x; for (i = 0; i < N; i++) { diff += (b[i] - c[i]); @@ -34,18 +34,16 @@ int main1 (int x, int max_result) abort (); if (max != max_result) abort (); - if (min != 0) + if (min != min_result) abort (); - - return 0; } int main (void) { check_vect (); - main1 (100, 100); - main1 (0, 15); + main1 (100, 100, 1); + main1 (0, 15, 0); return 0; } diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-2char.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-2char.c index cd8b1304956..f8a7b96fbc9 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-reduc-2char.c +++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-2char.c @@ -6,17 +6,17 @@ #define N 16 #define DIFF 121 -int main1 (char x, char max_result) +void main1 (signed char x, signed char max_result, signed char min_result) { int i; - char b[N] = {0,2,3,6,8,10,12,14,16,18,20,22,24,26,28,30}; - char c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + signed char b[N] = {1,2,3,6,8,10,12,14,16,18,20,22,24,26,28,30}; + signed char c[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; signed char diff = 2; - char max = x; - char min = 10; + signed char max = x; + signed char min = x; for (i = 0; i < N; i++) { - diff += (b[i] - c[i]); + diff += (signed char)(b[i] - c[i]); } for (i = 0; i < N; i++) { @@ -32,19 +32,17 @@ int main1 (char x, char max_result) abort (); if (max != max_result) abort (); - if (min != 0) + if (min != min_result) abort (); - - return 0; } int main (void) { check_vect (); - main1 (100, 100); - main1 (0, 15); - return 0 ; + main1 (100, 100, 1); + main1 (0, 15, 0); + return 0; } /* { dg-final { scan-tree-dump-times "vectorized 3 loops" 1 "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-2short.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-2short.c index f0880aab12a..d4ac128563c 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-reduc-2short.c +++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-2short.c @@ -1,23 +1,22 @@ /* { dg-require-effective-target vect_int } */ #include <stdarg.h> -#include <stdio.h> #include "tree-vect.h" #define N 16 #define DIFF 242 -int main1 (short x, short max_result) +void main1 (short x, short max_result, short min_result) { int i; - short b[N] = {0,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; - short c[N] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; + short b[N] = {1,3,6,9,12,15,18,21,24,27,30,33,36,39,42,45}; + short c[N] = {1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; short diff = 2; short max = x; - short min = 10; + short min = x; for (i = 0; i < N; i++) { - diff += (b[i] - c[i]); + diff += (short)(b[i] - c[i]); } for (i = 0; i < N; i++) { max = max < c[i] ? c[i] : max; @@ -32,18 +31,16 @@ int main1 (short x, short max_result) abort (); if (max != max_result) abort (); - if (min != 0) + if (min != min_result) abort (); - - return 0; } int main (void) { check_vect (); - main1 (100, 100); - main1 (0, 15); + main1 (100, 100, 1); + main1 (0, 15, 0); return 0; } diff --git a/gcc/tree-vect-transform.c b/gcc/tree-vect-transform.c index cdd3acfbb68..852ff19033c 100644 --- a/gcc/tree-vect-transform.c +++ b/gcc/tree-vect-transform.c @@ -727,8 +727,11 @@ get_initial_def_for_reduction (tree stmt, tree init_val, tree *scalar_def) switch (code) { case PLUS_EXPR: - def = INTEGRAL_TYPE_P (type) ? integer_zero_node : - build_real (type, dconst0); + if (INTEGRAL_TYPE_P (type)) + def = build_int_cst (type, 0); + else + def = build_real (type, dconst0); + #ifdef ADJUST_IN_EPILOG /* All the 'nunits' elements are set to 0. The final result will be adjusted by 'init_val' at the loop epilog. */ @@ -746,7 +749,7 @@ get_initial_def_for_reduction (tree stmt, tree init_val, tree *scalar_def) case MAX_EXPR: def = init_val; nelements = nunits; - need_epilog_adjust = false; + need_epilog_adjust = true; break; default: @@ -754,9 +757,7 @@ get_initial_def_for_reduction (tree stmt, tree init_val, tree *scalar_def) } for (i = nelements - 1; i >= 0; --i) - { - t = tree_cons (NULL_TREE, def, t); - } + t = tree_cons (NULL_TREE, def, t); if (nelements == nunits - 1) { @@ -771,11 +772,15 @@ get_initial_def_for_reduction (tree stmt, tree init_val, tree *scalar_def) else vec = build_constructor (vectype, t); - if (need_epilog_adjust) - *scalar_def = init_val; - else - *scalar_def = INTEGRAL_TYPE_P (type) ? integer_zero_node - : build_real (type, dconst0); + if (!need_epilog_adjust) + { + if (INTEGRAL_TYPE_P (type)) + init_val = build_int_cst (type, 0); + else + init_val = build_real (type, dconst0); + } + *scalar_def = init_val; + return vect_init_vector (stmt, vec); } |