public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* PATCH] tree-ssa-sink: Add heuristics for code sinking
@ 2023-04-14  8:41 Ajit Agarwal
  2023-04-14  8:59 ` Richard Biener
  0 siblings, 1 reply; 4+ messages in thread
From: Ajit Agarwal @ 2023-04-14  8:41 UTC (permalink / raw)
  To: gcc-patches; +Cc: Segher Boessenkool, Peter Bergner, Jeff Law

Hello All:

This patch add heuristics for code sinking opportunities.
Bootstrapped and regtested for powerpc64-linux-gnu.

Thanks & Regards
Ajit

	tree-ssa-sink: Add heuristics for code sinking.

	Add following code sinking heuristics:

	1. from code block dominates the call.
	2. To Code block have uses inside the function call.
	3. Loop headers.
	4. Sinking from code block after call increases register
	pressure.
	5. Sinking calls.

	2023-04-14  Ajit Kumar Agarwal  <aagarwa1@linux.ibm.com>

gcc/ChangeLog:

	* tree-ssa-sink.cc (statement_sink_location): Add heuristics
	for code sinking.
---
 gcc/tree-ssa-sink.cc | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/gcc/tree-ssa-sink.cc b/gcc/tree-ssa-sink.cc
index 87b1d40c174..8de88b259a3 100644
--- a/gcc/tree-ssa-sink.cc
+++ b/gcc/tree-ssa-sink.cc
@@ -465,6 +465,39 @@ statement_sink_location (gimple *stmt, basic_block frombb,
 	  if (sinkbb == frombb)
 	    return false;
 
+	  auto_vec<basic_block> h;
+	  h = get_all_dominated_blocks (CDI_DOMINATORS,
+					frombb);
+	  bool is_call = false;
+	  while (h.length ())
+	    {
+	      basic_block bb = h.pop ();
+
+	      if (bb == frombb)
+		continue;
+
+	      for (gimple_stmt_iterator gsi = gsi_last_bb (bb); !gsi_end_p (gsi);)
+		{
+		  gimple *stmt = gsi_stmt (gsi);
+
+		  if (is_gimple_call (stmt))
+		    {
+		      is_call = true;
+		      break;
+		    }
+
+		   if (!gsi_end_p (gsi))
+		     gsi_prev (&gsi);
+		}
+	     }
+
+	    if (!is_gimple_call (stmt)
+		&& (gimple_bb (use) != frombb)
+		&& !is_gimple_call (use)
+		&& dominated_by_p (CDI_DOMINATORS, sinkbb, frombb)
+		&& is_call)
+	       return false;
+
 	  if (sinkbb == gimple_bb (use))
 	    *togsi = gsi_for_stmt (use);
 	  else
-- 
2.31.1


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

end of thread, other threads:[~2023-04-14 11:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-14  8:41 PATCH] tree-ssa-sink: Add heuristics for code sinking Ajit Agarwal
2023-04-14  8:59 ` Richard Biener
2023-04-14 10:07   ` Ajit Agarwal
2023-04-14 11:56     ` 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).