OSDN Git Service

PR tree-optimization/33993
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 6 Nov 2007 08:28:37 +0000 (08:28 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 6 Nov 2007 08:28:37 +0000 (08:28 +0000)
* tree-vect-transform.c (vect_get_constant_vectors): Use build_vector
rather than build_constructor_from_list if all list values are
constants.
(get_initial_def_for_induction): Use build_vector instead of
build_constructor_from_list.

* gcc.c-torture/compile/20071105-1.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@129920 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/20071105-1.c [new file with mode: 0644]
gcc/tree-vect-transform.c

index b9d370e..38237bf 100644 (file)
@@ -1,3 +1,12 @@
+2007-11-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/33993
+       * tree-vect-transform.c (vect_get_constant_vectors): Use build_vector
+       rather than build_constructor_from_list if all list values are
+       constants.
+       (get_initial_def_for_induction): Use build_vector instead of
+       build_constructor_from_list.
+
 2007-11-05  Mark Mitchell  <mark@codesourcery.com>
 
        PR target/33579
index e08a6f3..54974ac 100644 (file)
@@ -1,3 +1,8 @@
+2007-11-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/33993
+       * gcc.c-torture/compile/20071105-1.c: New test.
+
 2007-11-05  Jakub Jelinek  <jakub@redhat.com>
 
        PR rtl-optimization/33648
diff --git a/gcc/testsuite/gcc.c-torture/compile/20071105-1.c b/gcc/testsuite/gcc.c-torture/compile/20071105-1.c
new file mode 100644 (file)
index 0000000..952b1bd
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR tree-optimization/33993 */
+/* Testcase by Martin Michlmayr <tbm@cyrius.com> */
+
+void
+init_full (char *array, int ny)
+{
+  int j;
+  char acc = 128;
+  for (j = 0; j < ny; j++)
+    *array++ = acc++;
+}
index 2cdc79b..736f0c9 100644 (file)
@@ -1318,6 +1318,7 @@ vect_get_constant_vectors (slp_tree slp_node, VEC(tree,heap) **vec_oprnds,
   bool is_store = false;
   unsigned int number_of_vectors = SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node);
   VEC (tree, heap) *voprnds = VEC_alloc (tree, heap, number_of_vectors);
+  bool constant_p;
 
   if (STMT_VINFO_DATA_REF (stmt_vinfo))
     is_store = true;
@@ -1341,6 +1342,7 @@ vect_get_constant_vectors (slp_tree slp_node, VEC(tree,heap) **vec_oprnds,
   number_of_copies = least_common_multiple (nunits, group_size) / group_size;
 
   number_of_places_left_in_vector = nunits;
+  constant_p = true;
   for (j = 0; j < number_of_copies; j++)
     {
       for (i = group_size - 1; VEC_iterate (tree, stmts, i, stmt); i--)
@@ -1350,6 +1352,8 @@ vect_get_constant_vectors (slp_tree slp_node, VEC(tree,heap) **vec_oprnds,
            op = operation;
          else
            op = TREE_OPERAND (operation, op_num);
+         if (!CONSTANT_CLASS_P (op))
+           constant_p = false;
 
           /* Create 'vect_ = {op0,op1,...,opn}'.  */
           t = tree_cons (NULL_TREE, op, t);
@@ -1362,7 +1366,11 @@ vect_get_constant_vectors (slp_tree slp_node, VEC(tree,heap) **vec_oprnds,
 
              vector_type = get_vectype_for_scalar_type (TREE_TYPE (op));
               gcc_assert (vector_type);
-              vec_cst = build_constructor_from_list (vector_type, t);
+             if (constant_p)
+               vec_cst = build_vector (vector_type, t);
+             else
+               vec_cst = build_constructor_from_list (vector_type, t);
+             constant_p = true;
               VEC_quick_push (tree, voprnds,
                               vect_init_vector (stmt, vec_cst, vector_type,
                                                NULL));
@@ -1617,7 +1625,8 @@ get_initial_def_for_induction (tree iv_phi)
   t = NULL_TREE;
   for (i = 0; i < nunits; i++)
     t = tree_cons (NULL_TREE, unshare_expr (new_name), t);
-  vec = build_constructor_from_list (vectype, t);
+  gcc_assert (CONSTANT_CLASS_P (new_name));
+  vec = build_vector (vectype, t);
   vec_step = vect_init_vector (iv_phi, vec, vectype, NULL);
 
 
@@ -1673,7 +1682,8 @@ get_initial_def_for_induction (tree iv_phi)
       t = NULL_TREE;
       for (i = 0; i < nunits; i++)
        t = tree_cons (NULL_TREE, unshare_expr (new_name), t);
-      vec = build_constructor_from_list (vectype, t);
+      gcc_assert (CONSTANT_CLASS_P (new_name));
+      vec = build_vector (vectype, t);
       vec_step = vect_init_vector (iv_phi, vec, vectype, NULL);
 
       vec_def = induc_def;