]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-vect-stmts.c (vectorizable_assignment): Support multiple types.
authorIra Rosen <irar@il.ibm.com>
Mon, 30 Nov 2009 12:17:43 +0000 (12:17 +0000)
committerIra Rosen <irar@gcc.gnu.org>
Mon, 30 Nov 2009 12:17:43 +0000 (12:17 +0000)
* tree-vect-stmts.c (vectorizable_assignment): Support
multiple types.

From-SVN: r154794

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/vect/vect-7.f90 [new file with mode: 0644]
gcc/tree-vect-stmts.c

index d38d8a7a6d88dc5ea30496507d8b5517d0c50a4f..c015dd4ecbcf3ddcf54abaa689e9e0da8b45339a 100644 (file)
@@ -1,3 +1,8 @@
+2009-11-30  Ira Rosen  <irar@il.ibm.com>
+
+       * tree-vect-stmts.c (vectorizable_assignment): Support
+       multiple types.
+
 2009-11-30  Richard Guenther  <rguenther@suse.de>
 
        * doc/contrib.texi (Contributors): Add myself.
index 6d75d60e37d39d71fa9cdf6f711c8b304a31a6a9..4320d65045b46b6e12d628088658be69f196d837 100644 (file)
@@ -1,3 +1,7 @@
+2009-11-30  Ira Rosen  <irar@il.ibm.com>
+
+       * gfortran.dg/vect/vect-7.f90: New test.
+
 2009-11-30  Richard Guenther  <rguenther@suse.de>
 
        PR middle-end/42119
diff --git a/gcc/testsuite/gfortran.dg/vect/vect-7.f90 b/gcc/testsuite/gfortran.dg/vect/vect-7.f90
new file mode 100644 (file)
index 0000000..adf0137
--- /dev/null
@@ -0,0 +1,16 @@
+! { dg-do compile } 
+! { dg-require-effective-target vect_double } 
+
+subroutine foo (x,nnd)
+  dimension x(nnd) 
+  integer i
+  
+  do i=1,nnd
+    x(i) = 1.d0 + (1.d0*i)/nnd
+  end do
+
+end subroutine foo 
+
+! { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" { target vect_unpack } } } 
+! { dg-final { cleanup-tree-dump "vect" } } 
+
index 7ce91cadb34fe3f61786a80f7b2c01ffafa5bcd1..99230909d7d955518a6ad73cef3853d37d6c6a10 100644 (file)
@@ -1809,10 +1809,12 @@ vectorizable_assignment (gimple stmt, gimple_stmt_iterator *gsi,
   enum vect_def_type dt[2] = {vect_unknown_def_type, vect_unknown_def_type};
   int nunits = TYPE_VECTOR_SUBPARTS (vectype);
   int ncopies;
-  int i;
+  int i, j;
   VEC(tree,heap) *vec_oprnds = NULL;
   tree vop;
   bb_vec_info bb_vinfo = STMT_VINFO_BB_VINFO (stmt_info);
+  gimple new_stmt = NULL;
+  stmt_vec_info prev_stmt_info = NULL;
 
   /* Multiple types in SLP are handled by creating the appropriate number of
      vectorized stmts for each SLP node. Hence, NCOPIES is always 1 in
@@ -1823,8 +1825,6 @@ vectorizable_assignment (gimple stmt, gimple_stmt_iterator *gsi,
     ncopies = LOOP_VINFO_VECT_FACTOR (loop_vinfo) / nunits;
 
   gcc_assert (ncopies >= 1);
-  if (ncopies > 1)
-    return false; /* FORNOW */
 
   if (!STMT_VINFO_RELEVANT_P (stmt_info) && !bb_vinfo)
     return false;
@@ -1870,20 +1870,35 @@ vectorizable_assignment (gimple stmt, gimple_stmt_iterator *gsi,
   vec_dest = vect_create_destination_var (scalar_dest, vectype);
 
   /* Handle use.  */
-  vect_get_vec_defs (op, NULL, stmt, &vec_oprnds, NULL, slp_node);
-
-  /* Arguments are ready. create the new vector stmt.  */
-  for (i = 0; VEC_iterate (tree, vec_oprnds, i, vop); i++)
+  for (j = 0; j < ncopies; j++)
     {
-      *vec_stmt = gimple_build_assign (vec_dest, vop);
-      new_temp = make_ssa_name (vec_dest, *vec_stmt);
-      gimple_assign_set_lhs (*vec_stmt, new_temp);
-      vect_finish_stmt_generation (stmt, *vec_stmt, gsi);
-      STMT_VINFO_VEC_STMT (stmt_info) = *vec_stmt;
+      /* Handle uses.  */
+      if (j == 0)
+        vect_get_vec_defs (op, NULL, stmt, &vec_oprnds, NULL, slp_node);
+      else
+        vect_get_vec_defs_for_stmt_copy (dt, &vec_oprnds, NULL);
+
+      /* Arguments are ready. create the new vector stmt.  */
+      for (i = 0; VEC_iterate (tree, vec_oprnds, i, vop); i++)
+       {
+         new_stmt = gimple_build_assign (vec_dest, vop);
+         new_temp = make_ssa_name (vec_dest, new_stmt);
+         gimple_assign_set_lhs (new_stmt, new_temp);
+         vect_finish_stmt_generation (stmt, new_stmt, gsi);
+         if (slp_node)
+           VEC_quick_push (gimple, SLP_TREE_VEC_STMTS (slp_node), new_stmt);
+       }
 
       if (slp_node)
-       VEC_quick_push (gimple, SLP_TREE_VEC_STMTS (slp_node), *vec_stmt);
-   }
+        continue;
+
+      if (j == 0)
+        STMT_VINFO_VEC_STMT (stmt_info) = *vec_stmt = new_stmt;
+      else
+        STMT_VINFO_RELATED_STMT (prev_stmt_info) = new_stmt;
+
+      prev_stmt_info = vinfo_for_stmt (new_stmt);
+    }
 
   VEC_free (tree, heap, vec_oprnds);
   return true;