public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/108696] New: querying relations is slow
Date: Tue, 07 Feb 2023 13:00:51 +0000	[thread overview]
Message-ID: <bug-108696-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108696

            Bug ID: 108696
           Summary: querying relations is slow
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

With the compiler.i testcase from PR26854 I notice we do quite a lot of bitmap
intersections via dom_oracle::query_relation for the case (which hits 99% of
the time) when a SSA name doesn't have any relation but equiv_set () returns a
newly allocated bitmap with just the self-equivalence recorded.

The self-equivalence case isn't used to prune the work done by query_relation
it seems.  Maybe find_relation_dom does that via

  // IF either name does not occur in a relation anywhere, there isnt one.
  if (!bitmap_bit_p (m_relation_set, v1) || !bitmap_bit_p (m_relation_set, v2))
    return VREL_VARYING;

but we still get all the way to the query_relation overload which eventually
does the intersection with m_relation_set which is a lot more expensive than
this.

A naiive

diff --git a/gcc/value-relation.cc b/gcc/value-relation.cc
index f5b1e67e420..f58d5050bdb 100644
--- a/gcc/value-relation.cc
+++ b/gcc/value-relation.cc
@@ -1373,6 +1373,10 @@ dom_oracle::query_relation (basic_block bb, tree ssa1,
tree ssa2)
   unsigned v2 = SSA_NAME_VERSION (ssa2);
   if (v1 == v2)
     return VREL_EQ;
+ 
+  // IF either name does not occur in a relation anywhere, there isnt one.
+  if (!bitmap_bit_p (m_relation_set, v1) || !bitmap_bit_p (m_relation_set,
v2))
+    return VREL_VARYING;

   // Check for equivalence first.  They must be in each equivalency set.
   const_bitmap equiv1 = equiv_set (ssa1, bb);

cuts

 dominator optimization             :  17.35 ( 15%) 

down to

 dominator optimization             :  16.17 ( 14%)

note almost all of the DOM time is spent in ranger for this testcase.

             reply	other threads:[~2023-02-07 13:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-07 13:00 rguenth at gcc dot gnu.org [this message]
2023-02-08 17:16 ` [Bug tree-optimization/108696] " amacleod at redhat dot com
2023-02-08 17:50 ` amacleod at redhat dot com
2023-02-08 18:01 ` rguenther at suse dot de
2023-02-10  8:38 ` rguenth at gcc dot gnu.org
2023-02-10 14:53 ` amacleod at redhat dot com

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=bug-108696-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).