This changes the loop over all stmts to a loop over all costed stmts.

Bootstrapped / tested on x86_64-unknown-linux-gnu, applied.

2020-06-03  Richard Biener  <rguent...@suse.de>

        * tree-vect-slp.c (vect_bb_vectorization_profitable_p): Loop over
        the cost vector to unset the visited flag on stmts.
---
 gcc/tree-vect-slp.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index 836defce990..f1d61944ae0 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -3078,6 +3078,11 @@ vect_bb_vectorization_profitable_p (bb_vec_info bb_vinfo)
                               SLP_INSTANCE_TREE (instance),
                               &life, &scalar_costs, visited);
     }
+  /* Unset visited flag.  */
+  stmt_info_for_cost *si;
+  FOR_EACH_VEC_ELT (scalar_costs, i, si)
+    gimple_set_visited  (si->stmt_info->stmt, false);
+
   void *target_cost_data = init_cost (NULL);
   add_stmt_costs (bb_vinfo, target_cost_data, &scalar_costs);
   scalar_costs.release ();
@@ -3085,11 +3090,6 @@ vect_bb_vectorization_profitable_p (bb_vec_info bb_vinfo)
   finish_cost (target_cost_data, &dummy, &scalar_cost, &dummy);
   destroy_cost_data (target_cost_data);
 
-  /* Unset visited flag.  */
-  for (gimple_stmt_iterator gsi = bb_vinfo->region_begin;
-       gsi_stmt (gsi) != gsi_stmt (bb_vinfo->region_end); gsi_next (&gsi))
-    gimple_set_visited  (gsi_stmt (gsi), false);
-
   /* Complete the target-specific cost calculation.  */
   finish_cost (BB_VINFO_TARGET_COST_DATA (bb_vinfo), &vec_prologue_cost,
               &vec_inside_cost, &vec_epilogue_cost);
-- 
2.25.1

Reply via email to