targhooks.c (default_builtin_vectorized_conversion): Handle vec_construct, using...
authorBill Schmidt <wschmidt@linux.ibm.com>
Wed, 13 Jun 2012 12:27:57 +0000 (12:27 +0000)
committerWilliam Schmidt <wschmidt@gcc.gnu.org>
Wed, 13 Jun 2012 12:27:57 +0000 (12:27 +0000)
2012-06-13  Bill Schmidt  <wschmidt@linux.ibm.com>

* targhooks.c (default_builtin_vectorized_conversion): Handle
vec_construct, using vectype to base cost on subparts.
* target.h (enum vect_cost_for_stmt): Add vec_construct.
* tree-vect-stmts.c (vect_model_load_cost): Use vec_construct
instead of scalar_to-vec.
* config/spu/spu.c (spu_builtin_vectorization_cost): Handle
vec_construct in same way as default for now.
* config/i386/i386.c (ix86_builtin_vectorization_cost): Likewise.
* config/rs6000/rs6000.c (rs6000_builtin_vectorization_cost):
Handle vec_construct, including special case for 32-bit loads.

From-SVN: r188508

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/config/rs6000/rs6000.c
gcc/config/spu/spu.c
gcc/target.h
gcc/targhooks.c
gcc/tree-vect-stmts.c

index 2a9e97dfa42b866a92b53b4a4e46d49048c3c0d9..f2959dd7e87013ff304ee2216a9eb685bf9cc137 100644 (file)
@@ -1,3 +1,16 @@
+2012-06-13  Bill Schmidt  <wschmidt@linux.ibm.com>
+
+       * targhooks.c (default_builtin_vectorized_conversion): Handle
+       vec_construct, using vectype to base cost on subparts.
+       * target.h (enum vect_cost_for_stmt): Add vec_construct.
+       * tree-vect-stmts.c (vect_model_load_cost): Use vec_construct
+       instead of scalar_to-vec.
+       * config/spu/spu.c (spu_builtin_vectorization_cost): Handle
+       vec_construct in same way as default for now.
+       * config/i386/i386.c (ix86_builtin_vectorization_cost): Likewise.
+       * config/rs6000/rs6000.c (rs6000_builtin_vectorization_cost):
+       Handle vec_construct, including special case for 32-bit loads.
+
 2012-06-13  Xinyu Qi <xyqi@marvell.com>
 
        * config/arm/arm.c (FL_IWMMXT2): New define.
index 13755f4f8233041c34d81a8e1127e1792071e4c8..d10bf160fe5f62cfcf1c93879450b68525a3e1c9 100644 (file)
@@ -36072,9 +36072,11 @@ static const struct attribute_spec ix86_attribute_table[] =
 /* Implement targetm.vectorize.builtin_vectorization_cost.  */
 static int
 ix86_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost,
-                                 tree vectype ATTRIBUTE_UNUSED,
+                                 tree vectype,
                                  int misalign ATTRIBUTE_UNUSED)
 {
+  unsigned elements;
+
   switch (type_of_cost)
     {
       case scalar_stmt:
@@ -36115,6 +36117,10 @@ ix86_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost,
       case vec_promote_demote:
         return ix86_cost->vec_stmt_cost;
 
+      case vec_construct:
+       elements = TYPE_VECTOR_SUBPARTS (vectype);
+       return elements / 2 + 1;
+
       default:
         gcc_unreachable ();
     }
index 11c4bf725ee25bc03f946f8e7224e2c26b176446..ad9d4389d9ba72c524155f504400fdfa3b9050dc 100644 (file)
@@ -3405,6 +3405,7 @@ rs6000_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost,
                                    tree vectype, int misalign)
 {
   unsigned elements;
+  tree elem_type;
 
   switch (type_of_cost)
     {
@@ -3504,6 +3505,18 @@ rs6000_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost,
 
         return 2;
 
+      case vec_construct:
+       elements = TYPE_VECTOR_SUBPARTS (vectype);
+       elem_type = TREE_TYPE (vectype);
+       /* 32-bit vectors loaded into registers are stored as double
+          precision, so we need n/2 converts in addition to the usual
+          n/2 merges to construct a vector of short floats from them.  */
+       if (SCALAR_FLOAT_TYPE_P (elem_type)
+           && TYPE_PRECISION (elem_type) == 32)
+         return elements + 1;
+       else
+         return elements / 2 + 1;
+
       default:
         gcc_unreachable ();
     }
index b81bf5e8f2d075a825b9f732c21cc49ef01f0db5..5310ba7f2f0f65752175eccd530bad966ebd0c15 100644 (file)
@@ -6908,9 +6908,11 @@ spu_builtin_mask_for_load (void)
 /* Implement targetm.vectorize.builtin_vectorization_cost.  */
 static int 
 spu_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost,
-                                tree vectype ATTRIBUTE_UNUSED,
+                                tree vectype,
                                 int misalign ATTRIBUTE_UNUSED)
 {
+  unsigned elements;
+
   switch (type_of_cost)
     {
       case scalar_stmt:
@@ -6937,6 +6939,10 @@ spu_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost,
       case cond_branch_taken:
         return 6;
 
+      case vec_construct:
+       elements = TYPE_VECTOR_SUBPARTS (vectype);
+       return elements / 2 + 1;
+
       default:
         gcc_unreachable ();
     }
index e3307e8ead27b5bfd89c05331f86f2f66bb0e136..252793f2a0f9838152e7ad7e0ad8fc5708909009 100644 (file)
@@ -146,7 +146,8 @@ enum vect_cost_for_stmt
   cond_branch_not_taken,
   cond_branch_taken,
   vec_perm,
-  vec_promote_demote
+  vec_promote_demote,
+  vec_construct
 };
 
 /* The target structure.  This holds all the backend hooks.  */
index da0b029cdbe64022a69f3dde60e17500376f5b94..5bbec5a110a205d77524380c8d6c95f59b2720f1 100644 (file)
@@ -499,9 +499,11 @@ default_builtin_vectorized_conversion (unsigned int code ATTRIBUTE_UNUSED,
 
 int
 default_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost,
-                                    tree vectype ATTRIBUTE_UNUSED,
+                                    tree vectype,
                                     int misalign ATTRIBUTE_UNUSED)
 {
+  unsigned elements;
+
   switch (type_of_cost)
     {
       case scalar_stmt:
@@ -524,6 +526,10 @@ default_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost,
       case cond_branch_taken:
         return 3;
 
+      case vec_construct:
+       elements = TYPE_VECTOR_SUBPARTS (vectype);
+       return elements / 2 + 1;
+
       default:
         gcc_unreachable ();
     }
index 0aa42577c09777dfef22d0a35cce769a9d8b6910..46edf1019babf16442f6adff3e2d78f9929deb92 100644 (file)
@@ -1031,11 +1031,13 @@ vect_model_load_cost (stmt_vec_info stmt_info, int ncopies, bool load_lanes_p,
   /* The loads themselves.  */
   if (STMT_VINFO_STRIDE_LOAD_P (stmt_info))
     {
-      /* N scalar loads plus gathering them into a vector.
-         ???  scalar_to_vec isn't the cost for that.  */
+      /* N scalar loads plus gathering them into a vector.  */
+      tree vectype = STMT_VINFO_VECTYPE (stmt_info);
       inside_cost += (vect_get_stmt_cost (scalar_load) * ncopies
-                     * TYPE_VECTOR_SUBPARTS (STMT_VINFO_VECTYPE (stmt_info)));
-      inside_cost += ncopies * vect_get_stmt_cost (scalar_to_vec);
+                     * TYPE_VECTOR_SUBPARTS (vectype));
+      inside_cost += ncopies
+       * targetm.vectorize.builtin_vectorization_cost (vec_construct,
+                                                       vectype, 0);
     }
   else
     vect_get_load_cost (first_dr, ncopies,