[Bug fortran/62283] basic-block vectorization fails

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Aug 27 12:43:00 GMT 2014


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62283

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Like

Index: gcc/tree-vect-slp.c
===================================================================
--- gcc/tree-vect-slp.c (revision 214572)
+++ gcc/tree-vect-slp.c (working copy)
@@ -329,6 +329,13 @@ vect_get_and_check_slp_defs (loop_vec_in
             }
         }

+      /* If this is an internal def but the definition is not vectorizable
+         treat it as external def for basic-block SLP.  */
+      if (!loop
+         && dt == vect_internal_def
+         && !STMT_VINFO_VECTORIZABLE (vinfo_for_stmt (def_stmt)))
+       dt = vect_external_def;
+
       if (first)
        {
          oprnd_info->first_dt = dt;

if one can sort out placing of the initializer (currently we place it at
the start of the basic-block which is wrong).  Like with

Index: gcc/tree-vect-slp.c
===================================================================
--- gcc/tree-vect-slp.c (revision 214572)
+++ gcc/tree-vect-slp.c (working copy)
@@ -2447,6 +2454,8 @@ vect_get_constant_vectors (tree op, slp_

   number_of_places_left_in_vector = nunits;
   elts = XALLOCAVEC (tree, nunits);
+  gimple_stmt_iterator where;
+  bool where_p = false;
   for (j = 0; j < number_of_copies; j++)
     {
       for (i = group_size - 1; stmts.iterate (i, &stmt); i--)
@@ -2517,6 +2526,20 @@ vect_get_constant_vectors (tree op, slp_

           /* Create 'vect_ = {op0,op1,...,opn}'.  */
           number_of_places_left_in_vector--;
+         /* For "externals" defined in BB compute an insert location.  */
+         if (TREE_CODE (op) == SSA_NAME
+             && (STMT_VINFO_BB_VINFO (stmt_vinfo)->bb
+                 == gimple_bb (SSA_NAME_DEF_STMT (op))))
+           {
+             gimple stmt = NULL;
+             if (where_p)
+               stmt = get_earlier_stmt (SSA_NAME_DEF_STMT (op),
+                                        gsi_stmt (where));
+             if (!stmt || stmt == gsi_stmt (where))
+               stmt = SSA_NAME_DEF_STMT (op);
+             where = gsi_for_stmt (stmt);
+             where_p = true;
+           }
          if (!types_compatible_p (TREE_TYPE (vector_type), TREE_TYPE (op)))
            {
              if (CONSTANT_CLASS_P (op))
@@ -2558,8 +2581,12 @@ vect_get_constant_vectors (tree op, slp_
                    CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, elts[k]);
                  vec_cst = build_constructor (vector_type, v);
                }
+             if (where_p)
+               gsi_next (&where);
               voprnds.quick_push (vect_init_vector (stmt, vec_cst,
-                                                   vector_type, NULL));
+                                                   vector_type,
+                                                   where_p ? &where : NULL));
+             where_p = false;
              if (ctor_seq != NULL)
                {
                  gimple init_stmt = SSA_NAME_DEF_STMT (voprnds.last ());

a bit too hackish for my taste.  Also handling unvectorizable stmts as external
should instead turned into sth more general like forcing 'external' handling
as soon as the SLP build fails for children (and letting cost handling reject
the awful cases).



More information about the Gcc-bugs mailing list