public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/108696] New: querying relations is slow
@ 2023-02-07 13:00 rguenth at gcc dot gnu.org
  2023-02-08 17:16 ` [Bug tree-optimization/108696] " amacleod at redhat dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-02-07 13:00 UTC (permalink / raw)
  To: gcc-bugs

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.

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

end of thread, other threads:[~2023-02-10 14:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-07 13:00 [Bug tree-optimization/108696] New: querying relations is slow rguenth at gcc dot gnu.org
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

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).