From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 164BD3858D33; Tue, 7 Feb 2023 13:00:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 164BD3858D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675774852; bh=lrsGTcl88NyAfInBOpNNVcIuM7iy9JKk1tDipGCbMTc=; h=From:To:Subject:Date:From; b=W9tWG99dE8p25o1cyzUFKiX2mosnKKWB4/Ly8m+XIx05VBEFgdGUEmd4tQQvoBRcL Nij6/V28mMUsYvDZ4NMxUQEe/pO2htdopKtdP3O5xjcIiy1tZqtyQuPAsem3Vnp5no szYhaB2apZfgacFtNfObp55XUcHh6wTGf9OGobTQ= From: "rguenth at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108696 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 bit= map 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 () return= s a newly allocated bitmap with just the self-equivalence recorded. The self-equivalence case isn't used to prune the work done by query_relati= on 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 ssa= 1, tree ssa2) unsigned v2 =3D SSA_NAME_VERSION (ssa2); if (v1 =3D=3D v2) return VREL_EQ; +=20 + // 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 =3D equiv_set (ssa1, bb); cuts dominator optimization : 17.35 ( 15%)=20 down to dominator optimization : 16.17 ( 14%) note almost all of the DOM time is spent in ranger for this testcase.=