public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Speedup PTA solving for call constraint sets
@ 2023-03-10 13:38 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2023-03-10 13:38 UTC (permalink / raw)
  To: gcc-patches

With calls we now often get contraints like

  callarg = *callarg + UNKNOWN

or similar cases.  The important thing to note is that this
complex constraint changes the node solution itself, so when
solving the node is marked as changed immediately again.  When
that happens it's profitable to iterate that self-cycle immediately
so we maximize cache reuse and build up the successor graph quickly
to get better topological ordering and reduce the number of
iterations of the solving.

For a testcase derived from ceph this reduces the time spent in
PTA solving from 453s to 92s which is quite significant.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.  For
the testcase I verified we create identical points-to solutions
before and after the change.  There are regression bugs complaining
about high PTA time (often only as part of overall slow compile),
I did not verify if this improves any of those but consider the
change a regression fix.

	* tree-ssa-structalias.cc (solve_graph): Immediately
	iterate self-cycles.
---
 gcc/tree-ssa-structalias.cc | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/gcc/tree-ssa-structalias.cc b/gcc/tree-ssa-structalias.cc
index fd7450b9477..fa3a2e4e1f9 100644
--- a/gcc/tree-ssa-structalias.cc
+++ b/gcc/tree-ssa-structalias.cc
@@ -2775,8 +2775,15 @@ solve_graph (constraint_graph_t graph)
 	    continue;
 
 	  /* If the node has changed, we need to process the
-	     complex constraints and outgoing edges again.  */
-	  if (bitmap_clear_bit (changed, i))
+	     complex constraints and outgoing edges again.  For complex
+	     constraints that modify i itself, like the common group of
+	       callarg = callarg + UNKNOWN;
+	       callarg = *callarg + UNKNOWN;
+	       *callarg = callescape;
+	     make sure to iterate immediately because that maximizes
+	     cache reuse and expands the graph quickest, leading to
+	     better visitation order in the next iteration.  */
+	  while (bitmap_clear_bit (changed, i))
 	    {
 	      unsigned int j;
 	      constraint_t c;
@@ -2794,7 +2801,7 @@ solve_graph (constraint_graph_t graph)
 		     ???  But we shouldn't ended up with "changed" set ...  */
 		  if (vi->oldsolution
 		      && bitmap_bit_p (vi->oldsolution, anything_id))
-		    continue;
+		    break;
 		  bitmap_copy (pts, get_varinfo (find (anything_id))->solution);
 		}
 	      else if (vi->oldsolution)
@@ -2803,7 +2810,7 @@ solve_graph (constraint_graph_t graph)
 		bitmap_copy (pts, vi->solution);
 
 	      if (bitmap_empty_p (pts))
-		continue;
+		break;
 
 	      if (vi->oldsolution)
 		bitmap_ior_into (vi->oldsolution, pts);
-- 
2.35.3

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-03-10 13:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-10 13:38 [PATCH] Speedup PTA solving for call constraint sets 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).