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.