tree-vectorizer.c (get_vectype_for_scalar_type): Added debug prinouts.
authorDorit Naishlos <dorit@il.ibm.com>
Thu, 14 Oct 2004 08:36:09 +0000 (08:36 +0000)
committerDorit Nuzman <dorit@gcc.gnu.org>
Thu, 14 Oct 2004 08:36:09 +0000 (08:36 +0000)
        * tree-vectorizer.c (get_vectype_for_scalar_type): Added debug prinouts.
        Added check that vectype is VECTOR_MODE_P, instead of check for BLKmode.
        (vect_analyze_operations): Make sure the vectorization factor > 1. Add
        gcc_assert under ENABLE_CHECKING.
        (vectorizable_operation): Remove check for VECTOR_MODE_P (moved to
        get_vectype_for_scalar_type).

        (vect_get_vec_def_for_operand): Remove redundant variables.
        (vect_transform_loop): Likewise.

From-SVN: r89032

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/vect-82.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/vect-82_64.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/vect-83.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/vect-83_64.c [new file with mode: 0644]
gcc/tree-vectorizer.c

index bc9ad2a90426f6fe193925b6c950870d51c45993..e17ef50c710e501440e8f9a31a691d7dc7a882df 100644 (file)
@@ -1,3 +1,15 @@
+2004-10-14  Dorit Naishlos  <dorit@il.bim.com>
+
+       * tree-vectorizer.c (get_vectype_for_scalar_type): Added debug prinouts.
+       Added check that vectype is VECTOR_MODE_P, instead of check for BLKmode.
+       (vect_analyze_operations): Make sure the vectorization factor > 1. Add
+       gcc_assert under ENABLE_CHECKING.
+       (vectorizable_operation): Remove check for VECTOR_MODE_P (moved to
+       get_vectype_for_scalar_type).
+
+       (vect_get_vec_def_for_operand): Remove redundant variables.
+       (vect_transform_loop): Likewise.
+
 2004-10-14  Richard Sandiford  <rsandifo@redhat.com>
 
        * config/arm/arm.h (CONDITIONAL_REGISTER_USAGE): Make r11 fixed and
index 07e4c0794cd098cf60ad159244675f8abceadfa6..141024acf0700824f749d6312d5a37a21b225e43 100644 (file)
@@ -1,3 +1,10 @@
+2004-10-14  Dorit Naishlos  <dorit@il.ibm.com>
+
+       * gcc.dg/vect/vect-82.c: New testcase.  
+       * gcc.dg/vect/vect-82_64.c: New testcase.       
+       * gcc.dg/vect/vect-83.c: New testcase.  
+       * gcc.dg/vect/vect-83_64.c: New testcase.       
+
 2004-10-14  Joseph S. Myers  <jsm@polyomino.org.uk>
 
        * gcc.dg/cpp/error-1.c: New test.
diff --git a/gcc/testsuite/gcc.dg/vect/vect-82.c b/gcc/testsuite/gcc.dg/vect/vect-82.c
new file mode 100644 (file)
index 0000000..133005c
--- /dev/null
@@ -0,0 +1,36 @@
+/* { dg-do run { target powerpc*-*-* } } */
+/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 16
+int main1 ()
+{  
+  long long unsigned int ca[N];
+  int i;
+
+  for (i = 0; i < N; i++)
+    {
+      ca[i] = 0;
+    }
+
+  /* check results:  */
+  for (i = 0; i < N; i++)
+    {
+      if (ca[i] != 0)
+        abort ();
+    }
+
+  return 0;
+}
+
+int main (void)
+{ 
+  check_vect ();
+  
+  return main1 ();
+} 
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-82_64.c b/gcc/testsuite/gcc.dg/vect/vect-82_64.c
new file mode 100644 (file)
index 0000000..088e5d8
--- /dev/null
@@ -0,0 +1,36 @@
+/* { dg-do run { target powerpc*-*-* } } */
+/* { dg-options "-O2 -ftree-vectorize -mpowerpc64 -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 16
+int main1 ()
+{  
+  long long unsigned int ca[N];
+  int i;
+
+  for (i = 0; i < N; i++)
+    {
+      ca[i] = 0;
+    }
+
+  /* check results:  */
+  for (i = 0; i < N; i++)
+    {
+      if (ca[i] != 0)
+        abort ();
+    }
+
+  return 0;
+}
+
+int main (void)
+{ 
+  check_vect ();
+  
+  return main1 ();
+} 
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { xfail *-*-* } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-83.c b/gcc/testsuite/gcc.dg/vect/vect-83.c
new file mode 100644 (file)
index 0000000..0b65f76
--- /dev/null
@@ -0,0 +1,36 @@
+/* { dg-do run { target powerpc*-*-* } } */
+/* { dg-options "-O2 -ftree-vectorize -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 16
+int main1 ()
+{  
+  long long unsigned int ca[N];
+  int i;
+
+  for (i = 0; i < N; i++)
+    {
+      ca[i] = 2;
+    }
+
+  /* check results:  */
+  for (i = 0; i < N; i++)
+    {
+      if (ca[i] != 2)
+        abort ();
+    }
+
+  return 0;
+}
+
+int main (void)
+{ 
+  check_vect ();
+  
+  return main1 ();
+} 
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-83_64.c b/gcc/testsuite/gcc.dg/vect/vect-83_64.c
new file mode 100644 (file)
index 0000000..f74d699
--- /dev/null
@@ -0,0 +1,36 @@
+/* { dg-do run { target powerpc*-*-* } } */
+/* { dg-options "-O2 -ftree-vectorize -mpowerpc64 -fdump-tree-vect-stats -maltivec" { target powerpc*-*-* } } */
+
+#include <stdarg.h>
+#include "tree-vect.h"
+
+#define N 16
+int main1 ()
+{  
+  long long unsigned int ca[N];
+  int i;
+
+  for (i = 0; i < N; i++)
+    {
+      ca[i] = 2;
+    }
+
+  /* check results:  */
+  for (i = 0; i < N; i++)
+    {
+      if (ca[i] != 2)
+        abort ();
+    }
+
+  return 0;
+}
+
+int main (void)
+{ 
+  check_vect ();
+  
+  return main1 ();
+} 
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } } */
index e4de78637d3ac34dc1e22b9e95628f66fae36bda..dc93116303a20eca82d86945e65411fc9df6d70a 100644 (file)
@@ -848,8 +848,31 @@ get_vectype_for_scalar_type (tree scalar_type)
   nunits = UNITS_PER_SIMD_WORD / nbytes;
 
   vectype = build_vector_type (scalar_type, nunits);
-  if (TYPE_MODE (vectype) == BLKmode)
+  if (vect_debug_details (NULL))
+    {
+      fprintf (dump_file, "get vectype with %d units of type ", nunits);
+      print_generic_expr (dump_file, scalar_type, TDF_SLIM);
+    }
+
+  if (!vectype)
     return NULL_TREE;
+
+  if (vect_debug_details (NULL))
+    {
+      fprintf (dump_file, "vectype: ");
+      print_generic_expr (dump_file, vectype, TDF_SLIM);
+    }
+
+  if (!VECTOR_MODE_P (TYPE_MODE (vectype)))
+    {
+      /* TODO: tree-complex.c sometimes can parallelize operations
+         on generic vectors.  We can vectorize the loop in that case,
+         but then we should re-run the lowering pass.  */
+      if (vect_debug_details (NULL))
+        fprintf (dump_file, "mode not supported by target.");
+      return NULL_TREE;
+    }
+
   return vectype;
 }
 
@@ -1157,11 +1180,6 @@ vect_get_vec_def_for_operand (tree op, tree stmt)
       /* Create 'vect_cst_ = {cst,cst,...,cst}'  */
 
       tree vec_cst;
-      stmt_vec_info stmt_vinfo = vinfo_for_stmt (stmt);
-      tree vectype = STMT_VINFO_VECTYPE (stmt_vinfo);
-      int nunits = GET_MODE_NUNITS (TYPE_MODE (vectype));
-      tree t = NULL_TREE;
-      int i;
 
       /* Build a tree with vector elements.  */
       if (vect_debug_details (NULL))
@@ -1408,16 +1426,6 @@ vectorizable_operation (tree stmt, block_stmt_iterator *bsi, tree *vec_stmt)
       return false;
     }
   vec_mode = TYPE_MODE (vectype);
-  if (!VECTOR_MODE_P (vec_mode))
-    {
-      /* TODO: tree-complex.c sometimes can parallelize operations
-        on generic vectors.  We can vectorize the loop in that case,
-        but then we should re-run the lowering pass.  */
-      if (vect_debug_details (NULL))
-       fprintf (dump_file, "mode not supported by target.");
-      return false;
-    }
-
   if (optab->handlers[(int) vec_mode].insn_code == CODE_FOR_nothing)
     {
       if (vect_debug_details (NULL))
@@ -1905,9 +1913,6 @@ vect_transform_loop (loop_vec_info loop_vinfo,
          tree stmt = bsi_stmt (si);
          stmt_vec_info stmt_info;
          bool is_store;
-#ifdef ENABLE_CHECKING
-         tree vectype;
-#endif
 
          if (vect_debug_details (NULL))
            {
@@ -1924,8 +1929,7 @@ vect_transform_loop (loop_vec_info loop_vinfo,
 #ifdef ENABLE_CHECKING
          /* FORNOW: Verify that all stmts operate on the same number of
                     units and no inner unrolling is necessary.  */
-         vectype = STMT_VINFO_VECTYPE (stmt_info);
-         gcc_assert (GET_MODE_NUNITS (TYPE_MODE (vectype))
+         gcc_assert (GET_MODE_NUNITS (TYPE_MODE (STMT_VINFO_VECTYPE (stmt_info)))
                      == vectorization_factor);
 #endif
          /* -------- vectorize statement ------------ */
@@ -2155,11 +2159,17 @@ vect_analyze_operations (loop_vec_info loop_vinfo)
            }
          else
            vectorization_factor = nunits;
+
+#ifdef ENABLE_CHECKING
+         gcc_assert (GET_MODE_SIZE (TYPE_MODE (scalar_type))
+                       * vectorization_factor == UNITS_PER_SIMD_WORD);
+#endif
        }
     }
 
   /* TODO: Analyze cost. Decide if worth while to vectorize.  */
-  if (!vectorization_factor)
+
+  if (vectorization_factor <= 1)
     {
       if (vect_debug_stats (loop) || vect_debug_details (loop))
         fprintf (dump_file, "not vectorized: unsupported data-type");