tree-vect-transform.c (get_initial_def_for_reduction): Use correct type for DEF and...
authorRichard Henderson <rth@redhat.com>
Tue, 28 Jun 2005 07:33:11 +0000 (00:33 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Tue, 28 Jun 2005 07:33:11 +0000 (00:33 -0700)
        * 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.

From-SVN: r101374

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/vect-reduc-1.c
gcc/testsuite/gcc.dg/vect/vect-reduc-1char.c
gcc/testsuite/gcc.dg/vect/vect-reduc-1short.c
gcc/testsuite/gcc.dg/vect/vect-reduc-2.c
gcc/testsuite/gcc.dg/vect/vect-reduc-2char.c
gcc/testsuite/gcc.dg/vect/vect-reduc-2short.c
gcc/tree-vect-transform.c

index 7bc4af658a3dbeaf9b39ce9e017521477b02d536..4a537759a9b86582eb0069a6bfbb5a139a99b761 100644 (file)
@@ -1,3 +1,8 @@
+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.
index 09e3e6564cfeabd98a3d31b70043655f855016ac..4110b33e9ea000a4134198c7596bc948f85e8426 100644 (file)
@@ -1,3 +1,12 @@
+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.
index bc87a5c62c861b0b2795211d19987bf3bac1b353..a58257993809724749e0999e593285a07f237414 100644 (file)
@@ -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-*-* } } } */
index e85fa4a20c0c44925bc901aa62cdde7d73c31446..418687dd23bfaec0ddb77b8a8e2969ad1ee9522a 100644 (file)
@@ -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;
 }
 
index 6212f4cfdcda844e47132e72aa1820eeff300945..91d7abd12759839437b1922cd859e4b02d501862 100644 (file)
@@ -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;
 }
 
index ca1a3da07e3660f2721e2ea3a791953e98d373ac..ef4499f761d1d54caaa9598d7f2750d592c971e6 100644 (file)
@@ -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;
 }
 
index cd8b1304956a3fc805335b5528870518ee19e8a6..f8a7b96fbc93be3b3562a58e68d507789e9035ae 100644 (file)
@@ -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" } } */
index f0880aab12af9187c3c8479b43b3a723656abaa9..d4ac128563c18691a26eca92e1001a3828b0ff42 100644 (file)
@@ -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;
 }
 
index cdd3acfbb6832ef31a4d911fdba02866b87f78d3..852ff19033c6f545090d6398a46248c594b67ea9 100644 (file)
@@ -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);
 }