[gcc(refs/users/marxin/heads/slp-ebb-v2)] Skip empty BBs.

Martin Liska marxin@gcc.gnu.org
Mon Oct 5 12:18:13 GMT 2020


https://gcc.gnu.org/g:101c5ff156053eb48ad023b22838a29ad6576a0a

commit 101c5ff156053eb48ad023b22838a29ad6576a0a
Author: Martin Liska <mliska@suse.cz>
Date:   Wed Sep 23 16:23:06 2020 +0200

    Skip empty BBs.

Diff:
---
 gcc/tree-vect-patterns.c |  2 --
 gcc/tree-vect-slp.c      | 18 +++++++++---------
 gcc/tree-vectorizer.h    | 16 +++++-----------
 3 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c
index 09e75437d39..d626c5f7362 100644
--- a/gcc/tree-vect-patterns.c
+++ b/gcc/tree-vect-patterns.c
@@ -5125,8 +5125,6 @@ vect_determine_precisions (vec_info *vinfo)
       bb_vec_info bb_vinfo = as_a <bb_vec_info> (vinfo);
       for (gimple *stmt : bb_vinfo->reverse_region_stmts ())
 	{
-	  if (stmt == NULL)
-	    continue;
 	  stmt_vec_info stmt_info = vinfo->lookup_stmt (stmt);
 	  if (stmt_info && STMT_VINFO_VECTORIZABLE (stmt_info))
 	    vect_determine_stmt_precisions (vinfo, stmt_info);
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index 07459d8c168..2cea4cf89fa 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -2736,8 +2736,6 @@ _bb_vec_info::_bb_vec_info (vec<basic_block> _bbs,
 {
   for (gimple *stmt : this->region_stmts ())
     {
-      if (stmt == NULL)
-	continue;
       gimple_set_uid (stmt, 0);
       if (is_gimple_debug (stmt))
 	continue;
@@ -2752,9 +2750,8 @@ _bb_vec_info::_bb_vec_info (vec<basic_block> _bbs,
 _bb_vec_info::~_bb_vec_info ()
 {
   for (gimple *stmt : this->region_stmts ())
-    if (stmt != NULL)
-      /* Reset region marker.  */
-      gimple_set_uid (stmt, -1);
+    /* Reset region marker.  */
+    gimple_set_uid (stmt, -1);
 }
 
 /* Subroutine of vect_slp_analyze_node_operations.  Handle the root of NODE,
@@ -3457,8 +3454,6 @@ vect_slp_check_for_constructors (bb_vec_info bb_vinfo)
 {
   for (gimple *stmt : bb_vinfo->region_stmts ())
     {
-      if (stmt == NULL)
-	continue;
       gassign *assign = dyn_cast<gassign *> (stmt);
       if (!assign || gimple_assign_rhs_code (assign) != CONSTRUCTOR)
 	continue;
@@ -3816,13 +3811,18 @@ vect_slp_function ()
     {
       basic_block bb = BASIC_BLOCK_FOR_FN (cfun, rpo[i]);
       gphi_iterator phi = gsi_start_phis (bb);
+      gimple_stmt_iterator gsi = gsi_start_nondebug_after_labels_bb (bb);
       if (gsi_end_p (phi))
-	ebb.safe_push (bb);
+	{
+	  if (!gsi_end_p (gsi))
+	    ebb.safe_push (bb);
+	}
       else if (!ebb.is_empty ())
 	{
 	  r |= vect_slp_bbs (ebb);
 	  ebb.truncate (0);
-	  ebb.quick_push (bb);
+	  if (!gsi_end_p (gsi))
+	    ebb.quick_push (bb);
 	}
     }
 
diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
index 0d1cf8cb3f9..9c54bab2916 100644
--- a/gcc/tree-vectorizer.h
+++ b/gcc/tree-vectorizer.h
@@ -840,7 +840,7 @@ public:
     {
       if (!gsi_end_p (gsi))
 	gsi_next (&gsi);
-      while (gsi_end_p (gsi) && bb_index < (int)bbs.length ())
+      if (gsi_end_p (gsi) && bb_index < (int)bbs.length ())
 	gsi = gsi_start_nondebug_after_labels_bb (bbs[bb_index++]);
 
       return *this;
@@ -851,8 +851,7 @@ public:
     bool
     operator== (const const_iterator &other) const
     {
-      return (gsi_stmt (gsi) == gsi_stmt (other.gsi)
-	      && gsi_bb (gsi) == gsi_bb (other.gsi));
+      return gsi_stmt (gsi) == gsi_stmt (other.gsi);
     }
 
     bool
@@ -881,12 +880,8 @@ public:
     {
       if (!gsi_end_p (gsi))
 	gsi_prev (&gsi);
-      while (gsi_end_p (gsi) && bb_index >= 0)
-	{
-	  gsi = gsi_last_bb (bbs[bb_index--]);
-	  if (!gsi_end_p (gsi))
-	    gsi_prev (&gsi);
-	}
+      if (gsi_end_p (gsi) && bb_index >= 0)
+	gsi = gsi_last_bb (bbs[bb_index--]);
 
       return *this;
     }
@@ -896,8 +891,7 @@ public:
     bool
     operator== (const const_reverse_iterator &other) const
     {
-      return (gsi_stmt (gsi) == gsi_stmt (other.gsi)
-	      && gsi_bb (gsi) == gsi_bb (other.gsi));
+      return gsi_stmt (gsi) == gsi_stmt (other.gsi);
     }
 
     bool


More information about the Gcc-cvs mailing list