simplify visited flag unsetting in SLP scalar cost computation
authorRichard Biener <rguenther@suse.de>
Wed, 3 Jun 2020 11:17:11 +0000 (13:17 +0200)
committerRichard Biener <rguenther@suse.de>
Wed, 3 Jun 2020 11:18:55 +0000 (13:18 +0200)
This changes the loop over all stmts to a loop over all costed stmts.

2020-06-03  Richard Biener  <rguenther@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

index 836defce9901683b000216f98c809451c7c82c5d..f1d61944ae0436372e1025bcd727362537769f79 100644 (file)
@@ -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);