public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-6584] Speedup PTA solving for call constraint sets
Date: Fri, 10 Mar 2023 14:08:29 +0000 (GMT)	[thread overview]
Message-ID: <20230310140829.A0A8A3858033@sourceware.org> (raw)

https://gcc.gnu.org/g:413ec1d12c50f8e2e6adb4de30482780bdfdeeb4

commit r13-6584-g413ec1d12c50f8e2e6adb4de30482780bdfdeeb4
Author: Richard Biener <rguenther@suse.de>
Date:   Fri Mar 10 14:15:14 2023 +0100

    Speedup PTA solving for call constraint sets
    
    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.
    
            * tree-ssa-structalias.cc (solve_graph): Immediately
            iterate self-cycles.

Diff:
---
 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 07e0fd6827a..c3c5bce42df 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);

                 reply	other threads:[~2023-03-10 14:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230310140829.A0A8A3858033@sourceware.org \
    --to=rguenth@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).