aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog14
-rw-r--r--gcc/expr.c2
-rw-r--r--gcc/tree-cfg.c74
-rw-r--r--gcc/tree-ssa-sccvn.c10
-rw-r--r--gcc/tree-vect-slp.c34
5 files changed, 126 insertions, 8 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a40549f..c4bd0a4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,17 @@
+2012-10-02 Jakub Jelinek <jakub@redhat.com>
+
+ PR tree-optimization/54713
+ * expr.c (categorize_ctor_elements_1): Don't assume purpose is
+ non-NULL.
+ * tree-cfg.c (verify_gimple_assign_single): Add verification of
+ vector CONSTRUCTORs.
+ * tree-ssa-sccvn.c (vn_reference_lookup_3): For VECTOR_TYPE
+ CONSTRUCTORs, don't do anything if element type is VECTOR_TYPE,
+ and don't check index.
+ * tree-vect-slp.c (vect_get_constant_vectors): VIEW_CONVERT_EXPR
+ ctor elements first if their type isn't compatible with vector
+ element type.
+
2012-10-02 Eric Botcazou <ebotcazou@adacore.com>
* tree.h (DECL_NONLOCAL_FRAME): New macro.
diff --git a/gcc/expr.c b/gcc/expr.c
index c180e8d..1adea93 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -5491,7 +5491,7 @@ categorize_ctor_elements_1 (const_tree ctor, HOST_WIDE_INT *p_nz_elts,
{
HOST_WIDE_INT mult = 1;
- if (TREE_CODE (purpose) == RANGE_EXPR)
+ if (purpose && TREE_CODE (purpose) == RANGE_EXPR)
{
tree lo_index = TREE_OPERAND (purpose, 0);
tree hi_index = TREE_OPERAND (purpose, 1);
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 774e74f..b14a3b9 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -4000,6 +4000,80 @@ verify_gimple_assign_single (gimple stmt)
return res;
case CONSTRUCTOR:
+ if (TREE_CODE (rhs1_type) == VECTOR_TYPE)
+ {
+ unsigned int i;
+ tree elt_i, elt_v, elt_t = NULL_TREE;
+
+ if (CONSTRUCTOR_NELTS (rhs1) == 0)
+ return res;
+ /* For vector CONSTRUCTORs we require that either it is empty
+ CONSTRUCTOR, or it is a CONSTRUCTOR of smaller vector elements
+ (then the element count must be correct to cover the whole
+ outer vector and index must be NULL on all elements, or it is
+ a CONSTRUCTOR of scalar elements, where we as an exception allow
+ smaller number of elements (assuming zero filling) and
+ consecutive indexes as compared to NULL indexes (such
+ CONSTRUCTORs can appear in the IL from FEs). */
+ FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (rhs1), i, elt_i, elt_v)
+ {
+ if (elt_t == NULL_TREE)
+ {
+ elt_t = TREE_TYPE (elt_v);
+ if (TREE_CODE (elt_t) == VECTOR_TYPE)
+ {
+ tree elt_t = TREE_TYPE (elt_v);
+ if (!useless_type_conversion_p (TREE_TYPE (rhs1_type),
+ TREE_TYPE (elt_t)))
+ {
+ error ("incorrect type of vector CONSTRUCTOR"
+ " elements");
+ debug_generic_stmt (rhs1);
+ return true;
+ }
+ else if (CONSTRUCTOR_NELTS (rhs1)
+ * TYPE_VECTOR_SUBPARTS (elt_t)
+ != TYPE_VECTOR_SUBPARTS (rhs1_type))
+ {
+ error ("incorrect number of vector CONSTRUCTOR"
+ " elements");
+ debug_generic_stmt (rhs1);
+ return true;
+ }
+ }
+ else if (!useless_type_conversion_p (TREE_TYPE (rhs1_type),
+ elt_t))
+ {
+ error ("incorrect type of vector CONSTRUCTOR elements");
+ debug_generic_stmt (rhs1);
+ return true;
+ }
+ else if (CONSTRUCTOR_NELTS (rhs1)
+ > TYPE_VECTOR_SUBPARTS (rhs1_type))
+ {
+ error ("incorrect number of vector CONSTRUCTOR elements");
+ debug_generic_stmt (rhs1);
+ return true;
+ }
+ }
+ else if (!useless_type_conversion_p (elt_t, TREE_TYPE (elt_v)))
+ {
+ error ("incorrect type of vector CONSTRUCTOR elements");
+ debug_generic_stmt (rhs1);
+ return true;
+ }
+ if (elt_i != NULL_TREE
+ && (TREE_CODE (elt_t) == VECTOR_TYPE
+ || TREE_CODE (elt_i) != INTEGER_CST
+ || compare_tree_int (elt_i, i) != 0))
+ {
+ error ("vector CONSTRUCTOR with non-NULL element index");
+ debug_generic_stmt (rhs1);
+ return true;
+ }
+ }
+ }
+ return res;
case OBJ_TYPE_REF:
case ASSERT_EXPR:
case WITH_SIZE_EXPR:
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 9e62ebe..832328d 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -1,5 +1,5 @@
/* SCC value numbering for trees
- Copyright (C) 2006, 2007, 2008, 2009, 2010
+ Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012
Free Software Foundation, Inc.
Contributed by Daniel Berlin <dan@dberlin.org>
@@ -1639,8 +1639,12 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_)
if (i < CONSTRUCTOR_NELTS (ctor))
{
constructor_elt *elt = CONSTRUCTOR_ELT (ctor, i);
- if (compare_tree_int (elt->index, i) == 0)
- val = elt->value;
+ if (TREE_CODE (TREE_TYPE (rhs1)) == VECTOR_TYPE)
+ {
+ if (TREE_CODE (TREE_TYPE (elt->value))
+ != VECTOR_TYPE)
+ val = elt->value;
+ }
}
}
if (val)
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index 1c4f276..c2429b2 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -2345,6 +2345,7 @@ vect_get_constant_vectors (tree op, slp_tree slp_node,
enum tree_code code = gimple_expr_code (stmt);
gimple def_stmt;
struct loop *loop;
+ gimple_seq ctor_seq = NULL;
if (STMT_VINFO_DEF_TYPE (stmt_vinfo) == vect_reduction_def
&& reduc_index != -1)
@@ -2503,11 +2504,27 @@ vect_get_constant_vectors (tree op, slp_tree slp_node,
/* Create 'vect_ = {op0,op1,...,opn}'. */
number_of_places_left_in_vector--;
- if (constant_p
- && !types_compatible_p (TREE_TYPE (vector_type), TREE_TYPE (op)))
+ if (!types_compatible_p (TREE_TYPE (vector_type), TREE_TYPE (op)))
{
- op = fold_unary (VIEW_CONVERT_EXPR, TREE_TYPE (vector_type), op);
- gcc_assert (op && CONSTANT_CLASS_P (op));
+ if (constant_p)
+ {
+ op = fold_unary (VIEW_CONVERT_EXPR,
+ TREE_TYPE (vector_type), op);
+ gcc_assert (op && CONSTANT_CLASS_P (op));
+ }
+ else
+ {
+ tree new_temp
+ = make_ssa_name (TREE_TYPE (vector_type), NULL);
+ gimple init_stmt;
+ op = build1 (VIEW_CONVERT_EXPR, TREE_TYPE (vector_type),
+ op);
+ init_stmt
+ = gimple_build_assign_with_ops (VIEW_CONVERT_EXPR,
+ new_temp, op, NULL_TREE);
+ gimple_seq_add_stmt (&ctor_seq, init_stmt);
+ op = new_temp;
+ }
}
elts[number_of_places_left_in_vector] = op;
@@ -2529,6 +2546,15 @@ vect_get_constant_vectors (tree op, slp_tree slp_node,
VEC_quick_push (tree, voprnds,
vect_init_vector (stmt, vec_cst,
vector_type, NULL));
+ if (ctor_seq != NULL)
+ {
+ gimple init_stmt
+ = SSA_NAME_DEF_STMT (VEC_last (tree, voprnds));
+ gimple_stmt_iterator gsi = gsi_for_stmt (init_stmt);
+ gsi_insert_seq_before_without_update (&gsi, ctor_seq,
+ GSI_SAME_STMT);
+ ctor_seq = NULL;
+ }
}
}
}