public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH]middle-end: add two debug counters for early-break vectorization debugging
@ 2024-02-08 13:47 Tamar Christina
  2024-02-08 14:15 ` Richard Biener
  0 siblings, 1 reply; 4+ messages in thread
From: Tamar Christina @ 2024-02-08 13:47 UTC (permalink / raw)
  To: gcc-patches; +Cc: nd, rguenther, jlaw

[-- Attachment #1: Type: text/plain, Size: 2500 bytes --]

Hi All,

This adds two new debug counter to aid in debugging early break code.

- vect_force_last_exit: when reached will always force the final loop exit.
- vect_skip_exit: when reached will skip selecting the current candidate exit
		  as the loop exit.

The first counter essentially allows you to turn off the PEELED case and the
second counter to pick a different exit, which may mean you pick no exit at
all.

Bootstrapped Regtested on aarch64-none-linux-gnu and no issues.

Ok for master?

Thanks,
Tamar

gcc/ChangeLog:

	* dbgcnt.def (vect_force_last_exit, vect_skip_exit): New.
	* tree-vect-loop.cc (vec_init_loop_exit_info): Use them.

--- inline copy of patch -- 
diff --git a/gcc/dbgcnt.def b/gcc/dbgcnt.def
index ed9f062eac2c28c52df76b39d4312dd9fde1c800..8f7bebf93fceabdf6ae86c2df591eae4848b8a5c 100644
--- a/gcc/dbgcnt.def
+++ b/gcc/dbgcnt.def
@@ -213,5 +213,7 @@ DEBUG_COUNTER (stv_conversion)
 DEBUG_COUNTER (tail_call)
 DEBUG_COUNTER (tree_sra)
 DEBUG_COUNTER (treepre_insert)
+DEBUG_COUNTER (vect_force_last_exit)
 DEBUG_COUNTER (vect_loop)
+DEBUG_COUNTER (vect_skip_exit)
 DEBUG_COUNTER (vect_slp)
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index eed2268e9bae7e7ad36d13da03e0b54eab26ef6f..854e9d78bc71721e6559a6bc5dff78c813603a78 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -58,6 +58,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-eh.h"
 #include "case-cfn-macros.h"
 #include "langhooks.h"
+#include "dbgcnt.h"
 
 /* Loop Vectorization Pass.
 
@@ -977,6 +978,20 @@ vec_init_loop_exit_info (class loop *loop)
   if (exits.length () == 1)
     return exits[0];
 
+  /* Check to see if we've been asked to force the last exit.  */
+  if (!dbg_cnt (vect_force_last_exit))
+    {
+      basic_block bb = ip_normal_pos (loop);
+      if (!bb)
+	return NULL;
+
+      edge exit = EDGE_SUCC (bb, 0);
+      if (exit->dest == loop->latch)
+	return EDGE_SUCC (bb, 1);
+
+      return exit;
+    }
+
   /* If we have multiple exits we only support counting IV at the moment.
      Analyze all exits and return the last one we can analyze.  */
   class tree_niter_desc niter_desc;
@@ -998,6 +1013,7 @@ vec_init_loop_exit_info (class loop *loop)
 		   && exit->src == single_pred (loop->latch)
 		   && (integer_nonzerop (may_be_zero)
 		       || COMPARISON_CLASS_P (may_be_zero))))
+	      && dbg_cnt (vect_skip_exit)
 	      && (!candidate
 		  || dominated_by_p (CDI_DOMINATORS, exit->src,
 				     candidate->src)))




-- 

[-- Attachment #2: rb18254.patch --]
[-- Type: text/plain, Size: 1820 bytes --]

diff --git a/gcc/dbgcnt.def b/gcc/dbgcnt.def
index ed9f062eac2c28c52df76b39d4312dd9fde1c800..8f7bebf93fceabdf6ae86c2df591eae4848b8a5c 100644
--- a/gcc/dbgcnt.def
+++ b/gcc/dbgcnt.def
@@ -213,5 +213,7 @@ DEBUG_COUNTER (stv_conversion)
 DEBUG_COUNTER (tail_call)
 DEBUG_COUNTER (tree_sra)
 DEBUG_COUNTER (treepre_insert)
+DEBUG_COUNTER (vect_force_last_exit)
 DEBUG_COUNTER (vect_loop)
+DEBUG_COUNTER (vect_skip_exit)
 DEBUG_COUNTER (vect_slp)
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index eed2268e9bae7e7ad36d13da03e0b54eab26ef6f..854e9d78bc71721e6559a6bc5dff78c813603a78 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -58,6 +58,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-eh.h"
 #include "case-cfn-macros.h"
 #include "langhooks.h"
+#include "dbgcnt.h"
 
 /* Loop Vectorization Pass.
 
@@ -977,6 +978,20 @@ vec_init_loop_exit_info (class loop *loop)
   if (exits.length () == 1)
     return exits[0];
 
+  /* Check to see if we've been asked to force the last exit.  */
+  if (!dbg_cnt (vect_force_last_exit))
+    {
+      basic_block bb = ip_normal_pos (loop);
+      if (!bb)
+	return NULL;
+
+      edge exit = EDGE_SUCC (bb, 0);
+      if (exit->dest == loop->latch)
+	return EDGE_SUCC (bb, 1);
+
+      return exit;
+    }
+
   /* If we have multiple exits we only support counting IV at the moment.
      Analyze all exits and return the last one we can analyze.  */
   class tree_niter_desc niter_desc;
@@ -998,6 +1013,7 @@ vec_init_loop_exit_info (class loop *loop)
 		   && exit->src == single_pred (loop->latch)
 		   && (integer_nonzerop (may_be_zero)
 		       || COMPARISON_CLASS_P (may_be_zero))))
+	      && dbg_cnt (vect_skip_exit)
 	      && (!candidate
 		  || dominated_by_p (CDI_DOMINATORS, exit->src,
 				     candidate->src)))




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-02-08 14:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-08 13:47 [PATCH]middle-end: add two debug counters for early-break vectorization debugging Tamar Christina
2024-02-08 14:15 ` Richard Biener
2024-02-08 14:41   ` Tamar Christina
2024-02-08 14:49     ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).