After no longer requiring copies for existing vector defs we
have to deal with them.  vectorizable_live_operation computes
an insert location based on them, so insert on region entry
if required.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

        * tree-vect-loop.cc (vectorizable_live_operation): Insert
        on entry when the vector def is a default def or a constant.
---
 gcc/tree-vect-loop.cc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 8cda9da7f1a..31de29c036b 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -10366,7 +10366,6 @@ vectorizable_live_operation (vec_info *vinfo, 
stmt_vec_info stmt_info,
 
   /* Get the correct slp vectorized stmt.  */
   tree vec_lhs = SLP_TREE_VEC_DEFS (slp_node)[vec_entry];
-  gimple *vec_stmt = SSA_NAME_DEF_STMT (vec_lhs);
 
   /* In case we need to early break vectorize also get the first stmt.  */
   tree vec_lhs0 = SLP_TREE_VEC_DEFS (slp_node)[0];
@@ -10454,7 +10453,10 @@ vectorizable_live_operation (vec_info *vinfo, 
stmt_vec_info stmt_info,
       if (TREE_CODE (new_tree) == SSA_NAME
          && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (lhs))
        SSA_NAME_OCCURS_IN_ABNORMAL_PHI (new_tree) = 1;
-      if (is_a <gphi *> (vec_stmt))
+      gimple *vec_stmt = SSA_NAME_DEF_STMT (vec_lhs);
+      if (TREE_CODE (vec_lhs) != SSA_NAME || SSA_NAME_IS_DEFAULT_DEF (vec_lhs))
+       vinfo->insert_seq_on_entry (stmt_info, stmts);
+      else if (is_a <gphi *> (vec_stmt))
        {
          gimple_stmt_iterator si = gsi_after_labels (gimple_bb (vec_stmt));
          gsi_insert_seq_before (&si, stmts, GSI_SAME_STMT);
@@ -10505,6 +10507,8 @@ vectorizable_live_operation (vec_info *vinfo, 
stmt_vec_info stmt_info,
                edge e;
                if (TREE_CODE (new_tree) == SSA_NAME
                    && !SSA_NAME_IS_DEFAULT_DEF (new_tree)
+                   && TREE_CODE (vec_lhs) == SSA_NAME
+                   && !SSA_NAME_IS_DEFAULT_DEF (vec_lhs)
                    && (gimple_bb (use_stmt)->loop_father
                        != gimple_bb (vec_stmt)->loop_father)
                    /* But a replacement in a LC PHI is OK.  This happens
-- 
2.51.0

Reply via email to