]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/54713 (error: non-trivial conversion at assignment in gcc...
authorJakub Jelinek <jakub@redhat.com>
Tue, 2 Oct 2012 13:43:09 +0000 (15:43 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 2 Oct 2012 13:43:09 +0000 (15:43 +0200)
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.

From-SVN: r191983

gcc/ChangeLog
gcc/expr.c
gcc/tree-cfg.c
gcc/tree-ssa-sccvn.c
gcc/tree-vect-slp.c

index a40549f356fee2e7fd0a9e873d4052fde4c3181e..c4bd0a4fa4e72ffb59ca9a66877e9539893f5135 100644 (file)
@@ -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.
index c180e8d5edcbc3c66e38875406698b955867db3b..1adea93c31699fa6c129dd81b9c4f6fcbf6e448d 100644 (file)
@@ -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);
index 774e74f2a545d8ceaed32e26aa29ec71e5b52a8d..b14a3b929f518f00cf109a199f0737c169f6630b 100644 (file)
@@ -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:
index 9e62ebe2e18a21e184a3e26fb1f529570d507b8d..832328d328a26d782d89be0668147f23d32da7a4 100644 (file)
@@ -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)
index 1c4f2762fd8d6346fb1e52d4e907edbf2f64c123..c2429b28693a9586a008fd3fb98edddb5d7f9bc0 100644 (file)
@@ -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;
+               }
             }
         }
     }