public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/62283] basic-block vectorization fails
Date: Wed, 27 Aug 2014 12:43:00 -0000	[thread overview]
Message-ID: <bug-62283-4-fx3eiCoBKV@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-62283-4@http.gcc.gnu.org/bugzilla/>

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).


  parent reply	other threads:[~2014-08-27 12:43 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-27 11:49 [Bug fortran/62283] New: SSE optimization fails holst at matmech dot com
2014-08-27 11:52 ` [Bug fortran/62283] " holst at matmech dot com
2014-08-27 12:00 ` [Bug fortran/62283] basic-block vectorization fails rguenth at gcc dot gnu.org
2014-08-27 12:43 ` rguenth at gcc dot gnu.org [this message]
2014-08-27 14:26 ` holst at matmech dot com
2014-08-27 14:52 ` holst at matmech dot com
2014-08-28  9:17 ` rguenth at gcc dot gnu.org
2014-08-28  9:42 ` rguenth at gcc dot gnu.org
2014-08-28 13:14 ` rguenth at gcc dot gnu.org
2014-08-28 13:14 ` rguenth at gcc dot gnu.org
2014-09-01 13:33 ` ro at gcc dot gnu.org
2014-09-01 13:35 ` rguenther at suse dot de
2014-09-01 13:37 ` ro at gcc dot gnu.org
2014-09-01 14:11 ` rguenth at gcc dot gnu.org
2014-09-01 14:29 ` ro at CeBiTec dot Uni-Bielefeld.DE
2014-09-01 14:41 ` rguenther at suse dot de
2014-09-02 11:08 ` ro at gcc dot gnu.org
2014-09-02 11:08 ` ro at gcc dot gnu.org
2014-09-02 11:12 ` ro at CeBiTec dot Uni-Bielefeld.DE
2014-09-02 12:11 ` rguenth at gcc dot gnu.org
2014-09-02 12:17 ` rguenth at gcc dot gnu.org
2015-04-28  8:31 ` rguenth at gcc dot gnu.org
2015-04-28  8:32 ` rguenth at gcc dot gnu.org
2015-05-04 14:43 ` ro at gcc dot gnu.org
2015-05-04 14:44 ` ro at gcc dot gnu.org
2015-05-06  6:47 ` rguenth at gcc dot gnu.org
2015-05-06  6:48 ` rguenth at gcc dot gnu.org
2015-05-06  6:48 ` rguenth at gcc dot gnu.org
2015-05-06 11:31 ` ro at gcc dot gnu.org
2015-05-06 12:18 ` rguenther at suse dot de
2015-05-06 12:21 ` rguenth at gcc dot gnu.org
2024-02-28 14:59 ` ro at gcc dot gnu.org
2024-02-28 15:01 ` ro at gcc dot gnu.org
2024-03-15 21:27 ` anlauf at gcc dot gnu.org
2024-03-15 21:41 ` [Bug tree-optimization/62283] " pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-62283-4-fx3eiCoBKV@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).