aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/logic.cc
diff options
context:
space:
mode:
authorPatrick Palka <ppalka@redhat.com>2020-11-09 18:12:47 -0500
committerPatrick Palka <ppalka@redhat.com>2020-11-09 18:12:47 -0500
commit2096ebd393a5a25921c85de1209b38c715924e22 (patch)
tree3e41d28c28f581e254a7d0065e729c452b282039 /gcc/cp/logic.cc
parent71a8040716c1342547a19c25bd0203ac29258ef3 (diff)
downloadgcc-2096ebd393a5a25921c85de1209b38c715924e22.zip
gcc-2096ebd393a5a25921c85de1209b38c715924e22.tar.gz
gcc-2096ebd393a5a25921c85de1209b38c715924e22.tar.bz2
c++: Reuse identical ATOMIC_CONSTRs during normalization
Profiling revealed that sat_hasher::equal accounts for nearly 40% of compile time in some cmcstl2 tests. This patch eliminates this bottleneck by caching the ATOMIC_CONSTRs returned by normalize_atom. This in turn allows us to replace the expensive atomic_constraints_identical_p check in sat_hasher::equal with cheap pointer equality, with no loss in cache hit rate. With this patch, compile time for the cmcstl2 test test/algorithm/set_symmetric_difference4.cpp drops from 19s to 11s with an --enable-checking=release compiler. gcc/cp/ChangeLog: * constraint.cc (atom_cache): Define this deletable hash_table. (normalize_atom): Use it to cache ATOMIC_CONSTRs when not generating diagnostics. (sat_hasher::hash): Use htab_hash_pointer instead of hash_atomic_constraint. (sat_hasher::equal): Test for pointer equality instead of atomic_constraints_identical_p. * cp-tree.h (struct atom_hasher): Moved and renamed from ... * logic.cc (struct constraint_hash): ... here. (clause::m_set): Adjust accordingly.
Diffstat (limited to 'gcc/cp/logic.cc')
-rw-r--r--gcc/cp/logic.cc17
1 files changed, 1 insertions, 16 deletions
diff --git a/gcc/cp/logic.cc b/gcc/cp/logic.cc
index 194b743..6701488 100644
--- a/gcc/cp/logic.cc
+++ b/gcc/cp/logic.cc
@@ -47,21 +47,6 @@ along with GCC; see the file COPYING3. If not see
#include "toplev.h"
#include "type-utils.h"
-/* Hash functions for atomic constrains. */
-
-struct constraint_hash : default_hash_traits<tree>
-{
- static hashval_t hash (tree t)
- {
- return hash_atomic_constraint (t);
- }
-
- static bool equal (tree t1, tree t2)
- {
- return atomic_constraints_identical_p (t1, t2);
- }
-};
-
/* A conjunctive or disjunctive clause.
Each clause maintains an iterator that refers to the current
@@ -219,7 +204,7 @@ struct clause
}
std::list<tree> m_terms; /* The list of terms. */
- hash_set<tree, false, constraint_hash> m_set; /* The set of atomic constraints. */
+ hash_set<tree, false, atom_hasher> m_set; /* The set of atomic constraints. */
iterator m_current; /* The current term. */
};