public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew MacLeod <amacleod@redhat.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [COMMITTED] tree-optimization/106280 - Check if transitives need to be registered.
Date: Mon, 18 Jul 2022 16:02:32 -0400	[thread overview]
Message-ID: <58aa1a95-c496-5fa3-42de-477d32efae31@redhat.com> (raw)

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

Regardless of whether this is enough of an improvement for the PR, it 
should be done.

Whenever a relation is registered with the oracle, it walks the 
dominator tree trying to apply any transitives it can find.

FIrst, it should check whether the operands are already in any relation. 
If neither operand is in a relation, we can conclude there cannot be any 
transitives. this is a simple bitmask check.

The second thing this patch does is adjust the set_relation routine to 
return NULL if the relation being applied already exists.  ie, we don't 
need to set the relation or do any additionalwork if the relation is 
already true. This will also prevent additional calls to the register 
transitives.

This provides some marginal improvements across the board, and 
noticeable improvements in the testcase.

Bootstrapped on    x86_64-pc-linux-gnu with no regressions. Pushed.

Andrew

[-- Attachment #2: 280.patch --]
[-- Type: text/x-patch, Size: 2093 bytes --]

commit 5e47c9333df6df1aa9da861f07e68f985d7d28fb
Author: Andrew MacLeod <amacleod@redhat.com>
Date:   Thu Jul 14 12:35:55 2022 -0400

    Check if transitives need to be registered.
    
    Whenever a relation is added, register_transitive is always called.
    If neither operand was in a relation before, or this is not a new
    relation, then there is no need to register transitives.
    
            PR tree-optimization/106280
            * value-relation.cc (dom_oracle::register_relation): Register
            transitives only when it is possible for there to be one.
            (dom_oracle::set_one_relation): Return NULL if this is an
            existing relation.

diff --git a/gcc/value-relation.cc b/gcc/value-relation.cc
index 13ce44199f7..bd344253af3 100644
--- a/gcc/value-relation.cc
+++ b/gcc/value-relation.cc
@@ -967,8 +967,12 @@ dom_oracle::register_relation (basic_block bb, relation_kind k, tree op1,
     equiv_oracle::register_relation (bb, k, op1, op2);
   else
     {
+      // if neither op1 nor op2 are in a relation before this is registered,
+      // there will be no transitive.
+      bool check = bitmap_bit_p (m_relation_set, SSA_NAME_VERSION (op1))
+		   || bitmap_bit_p (m_relation_set, SSA_NAME_VERSION (op2));
       relation_chain *ptr = set_one_relation (bb, k, op1, op2);
-      if (ptr)
+      if (ptr && check)
 	register_transitives (bb, *ptr);
     }
 }
@@ -1010,13 +1014,16 @@ dom_oracle::set_one_relation (basic_block bb, relation_kind k, tree op1,
       // Check into whether we can simply replace the relation rather than
       // intersecting it.  THis may help with some optimistic iterative
       // updating algorithms.
-      ptr->intersect (vr);
+      bool new_rel = ptr->intersect (vr);
       if (dump_file && (dump_flags & TDF_DETAILS))
 	{
 	  fprintf (dump_file, " to produce ");
 	  ptr->dump (dump_file);
-	  fprintf (dump_file, "\n");
+	  fprintf (dump_file, " %s.\n", new_rel ? "Updated" : "No Change");
 	}
+      // If there was no change, return no record..
+      if (!new_rel)
+	return NULL;
     }
   else
     {

                 reply	other threads:[~2022-07-18 20:02 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=58aa1a95-c496-5fa3-42de-477d32efae31@redhat.com \
    --to=amacleod@redhat.com \
    --cc=gcc-patches@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).