tree-vectorizer.h (struct _slp_oprnd_info): Add second_pattern member.
authorRichard Biener <rguenther@suse.de>
Fri, 22 May 2015 13:52:58 +0000 (13:52 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 22 May 2015 13:52:58 +0000 (13:52 +0000)
2015-05-22  Richard Biener  <rguenther@suse.de>

* tree-vectorizer.h (struct _slp_oprnd_info): Add second_pattern
member.
* tree-vect-loop.c (vect_analyze_loop_operations): Look at
patterns when determining whether SLP is pure.
(vect_is_slp_reduction): Remove check for pattern stmts.
(vect_is_simple_reduction_1): Remove dead code.
* tree-vect-slp.c (vect_create_oprnd_info): Initialize second_pattern.
(vect_get_and_check_slp_defs): Pass in the stmt number.
Allow the first def in a reduction to be not a pattern stmt when
the rest of the stmts def are patterns.
(vect_build_slp_tree_1): Allow tcc_expression codes like
SAD_EXPR and DOT_PROD_EXPR.
(vect_build_slp_tree): Adjust.
(vect_analyze_slp): Refactor and move BB vect error message ...
(vect_slp_analyze_bb_1): ... here.

From-SVN: r223574

gcc/ChangeLog
gcc/tree-vect-loop.c
gcc/tree-vect-slp.c
gcc/tree-vectorizer.h

index 58abb46c997c5cd0258b7aadab227b1ba0c7ad6e..212b8e57527a9784110a9ac2a5fb4bffbb56bf71 100644 (file)
@@ -1,3 +1,21 @@
+2015-05-22  Richard Biener  <rguenther@suse.de>
+
+       * tree-vectorizer.h (struct _slp_oprnd_info): Add second_pattern
+       member.
+       * tree-vect-loop.c (vect_analyze_loop_operations): Look at
+       patterns when determining whether SLP is pure.
+       (vect_is_slp_reduction): Remove check for pattern stmts.
+       (vect_is_simple_reduction_1): Remove dead code.
+       * tree-vect-slp.c (vect_create_oprnd_info): Initialize second_pattern.
+       (vect_get_and_check_slp_defs): Pass in the stmt number.
+       Allow the first def in a reduction to be not a pattern stmt when
+       the rest of the stmts def are patterns.
+       (vect_build_slp_tree_1): Allow tcc_expression codes like
+       SAD_EXPR and DOT_PROD_EXPR.
+       (vect_build_slp_tree): Adjust.
+       (vect_analyze_slp): Refactor and move BB vect error message ...
+       (vect_slp_analyze_bb_1): ... here.
+
 2015-05-22  Aldy Hernandez  <aldyh@redhat.com>
 
        * tree-switch-conversion.c (build_one_array): Set DECL_IGNORED_P
index 123958b31ca352a39b8cc2a63c1510421fbb3cc3..2c983b889d170091bd566b8d1d1ba8cfd58e78b1 100644 (file)
@@ -1399,7 +1399,12 @@ vect_analyze_loop_operations (loop_vec_info loop_vinfo, bool slp)
            {
              gimple stmt = gsi_stmt (si);
              stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
-             gcc_assert (stmt_info);
+             if (STMT_VINFO_IN_PATTERN_P (stmt_info)
+                 && STMT_VINFO_RELATED_STMT (stmt_info))
+               {
+                 stmt = STMT_VINFO_RELATED_STMT (stmt_info);
+                 stmt_info = vinfo_for_stmt (stmt);
+               }
              if ((STMT_VINFO_RELEVANT_P (stmt_info)
                   || VECTORIZABLE_CYCLE_DEF (STMT_VINFO_DEF_TYPE (stmt_info)))
                  && !PURE_SLP_STMT (stmt_info))
@@ -2031,12 +2036,8 @@ vect_is_slp_reduction (loop_vec_info loop_info, gimple phi, gimple first_stmt)
 
           if (flow_bb_inside_loop_p (loop, gimple_bb (use_stmt)))
             {
-              if (vinfo_for_stmt (use_stmt)
-                  && !STMT_VINFO_IN_PATTERN_P (vinfo_for_stmt (use_stmt)))
-                {
-                  loop_use_stmt = use_stmt;
-                  nloop_uses++;
-                }
+             loop_use_stmt = use_stmt;
+             nloop_uses++;
             }
            else
              n_out_of_loop_uses++;
@@ -2265,9 +2266,7 @@ vect_is_simple_reduction_1 (loop_vec_info loop_info, gimple phi,
           return NULL;
         }
 
-      if (vinfo_for_stmt (use_stmt)
-         && !is_pattern_stmt_p (vinfo_for_stmt (use_stmt)))
-        nloop_uses++;
+      nloop_uses++;
       if (nloop_uses > 1)
         {
           if (dump_enabled_p ())
@@ -2325,9 +2324,7 @@ vect_is_simple_reduction_1 (loop_vec_info loop_info, gimple phi,
       gimple use_stmt = USE_STMT (use_p);
       if (is_gimple_debug (use_stmt))
        continue;
-      if (flow_bb_inside_loop_p (loop, gimple_bb (use_stmt))
-         && vinfo_for_stmt (use_stmt)
-         && !is_pattern_stmt_p (vinfo_for_stmt (use_stmt)))
+      if (flow_bb_inside_loop_p (loop, gimple_bb (use_stmt)))
        nloop_uses++;
       if (nloop_uses > 1)
        {
index 21489b3ed3af8cd3460507f0dd1454c4e4dab2d3..1c519903153c2ede8ba95b0faf255861af5a5da2 100644 (file)
@@ -183,6 +183,7 @@ vect_create_oprnd_info (int nops, int group_size)
       oprnd_info->first_dt = vect_uninitialized_def;
       oprnd_info->first_op_type = NULL_TREE;
       oprnd_info->first_pattern = false;
+      oprnd_info->second_pattern = false;
       oprnds_info.quick_push (oprnd_info);
     }
 
@@ -242,7 +243,7 @@ vect_get_place_in_interleaving_chain (gimple stmt, gimple first_stmt)
 
 static int 
 vect_get_and_check_slp_defs (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo,
-                             gimple stmt, bool first,
+                             gimple stmt, unsigned stmt_num,
                              vec<slp_oprnd_info> *oprnds_info)
 {
   tree oprnd;
@@ -256,6 +257,8 @@ vect_get_and_check_slp_defs (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo,
   int first_op_idx = 1;
   bool commutative = false;
   bool first_op_cond = false;
+  bool first = stmt_num == 0;
+  bool second = stmt_num == 1;
 
   if (loop_vinfo)
     loop = LOOP_VINFO_LOOP (loop_vinfo);
@@ -326,7 +329,11 @@ again:
          && !STMT_VINFO_LIVE_P (vinfo_for_stmt (def_stmt)))
         {
           pattern = true;
-          if (!first && !oprnd_info->first_pattern)
+          if (!first && !oprnd_info->first_pattern
+             /* Allow different pattern state for the defs of the
+                first stmt in reduction chains.  */
+             && (oprnd_info->first_dt != vect_reduction_def
+                 || (!second && !oprnd_info->second_pattern)))
            {
              if (i == 0
                  && !swapped
@@ -377,6 +384,9 @@ again:
             }
         }
 
+      if (second)
+       oprnd_info->second_pattern = pattern;
+
       if (first)
        {
          oprnd_info->first_dt = dt;
@@ -892,7 +902,7 @@ vect_build_slp_tree_1 (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo,
          /* Not memory operation.  */
          if (TREE_CODE_CLASS (rhs_code) != tcc_binary
              && TREE_CODE_CLASS (rhs_code) != tcc_unary
-             && rhs_code != COND_EXPR
+             && TREE_CODE_CLASS (rhs_code) != tcc_expression
              && rhs_code != CALL_EXPR)
            {
              if (dump_enabled_p ())
@@ -1033,7 +1043,7 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo,
   FOR_EACH_VEC_ELT (SLP_TREE_SCALAR_STMTS (*node), i, stmt)
     {
       switch (vect_get_and_check_slp_defs (loop_vinfo, bb_vinfo,
-                                          stmt, (i == 0), &oprnds_info))
+                                          stmt, i, &oprnds_info))
        {
        case 0:
          break;
@@ -1910,17 +1920,7 @@ vect_analyze_slp (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo,
                                   max_tree_size))
       ok = true;
 
-  if (bb_vinfo && !ok)
-    {
-      if (dump_enabled_p ())
-        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-                        "Failed to SLP the basic block.\n");
-
-      return false;
-    }
-
-  if (loop_vinfo
-      && LOOP_VINFO_REDUCTION_CHAINS (loop_vinfo).length () > 0)
+  if (reduc_chains.length () > 0)
     {
       /* Find SLP sequences starting from reduction chains.  */
       FOR_EACH_VEC_ELT (reduc_chains, i, first_element)
@@ -1936,7 +1936,7 @@ vect_analyze_slp (loop_vec_info loop_vinfo, bb_vec_info bb_vinfo,
     }
 
   /* Find SLP sequences starting from groups of reductions.  */
-  if (loop_vinfo && LOOP_VINFO_REDUCTIONS (loop_vinfo).length () > 1
+  if (reductions.length () > 1
       && vect_analyze_slp_instance (loop_vinfo, bb_vinfo, reductions[0],
                                    max_tree_size))
     ok = true;
@@ -2443,9 +2443,13 @@ vect_slp_analyze_bb_1 (basic_block bb)
   if (!vect_analyze_slp (NULL, bb_vinfo, n_stmts))
     {
       if (dump_enabled_p ())
-        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, 
-                        "not vectorized: failed to find SLP opportunities "
-                        "in basic block.\n");
+       {
+         dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                          "Failed to SLP the basic block.\n");
+         dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, 
+                          "not vectorized: failed to find SLP opportunities "
+                          "in basic block.\n");
+       }
 
       destroy_bb_vec_info (bb_vinfo);
       return NULL;
index 17e590e67defcd6ea9a04e3035678033d80655c0..adde2fb0d1d0dba14ef0d16c5393c4950b968a2b 100644 (file)
@@ -163,6 +163,7 @@ typedef struct _slp_oprnd_info
   enum vect_def_type first_dt;
   tree first_op_type;
   bool first_pattern;
+  bool second_pattern;
 } *slp_oprnd_info;