Skip to content

Commit

Permalink
reduce hash table lookups in expr_abstract in half
Browse files Browse the repository at this point in the history
  • Loading branch information
nunoplopes committed Dec 16, 2024
1 parent a6e59ea commit 6f24123
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
15 changes: 8 additions & 7 deletions src/ast/expr_abstract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ void expr_abstractor::operator()(unsigned base, unsigned num_bound, expr* const*

while(!m_stack.empty()) {
curr = m_stack.back();
if (m_map.contains(curr)) {
auto &val = m_map.insert_if_not_there(curr, nullptr);
if (val) {
m_stack.pop_back();
continue;
}
switch(curr->get_kind()) {
case AST_VAR: {
m_map.insert(curr, curr);
val = curr;
m_stack.pop_back();
break;
}
Expand All @@ -56,7 +57,7 @@ void expr_abstractor::operator()(unsigned base, unsigned num_bound, expr* const*
bool all_visited = true;
bool changed = false;
m_args.reset();
for (unsigned i = 0; i < a->get_num_args(); ++i) {
for (unsigned i = 0, e = a->get_num_args(); i < e; ++i) {
if (!m_map.find(a->get_arg(i), b)) {
m_stack.push_back(a->get_arg(i));
all_visited = false;
Expand All @@ -73,7 +74,7 @@ void expr_abstractor::operator()(unsigned base, unsigned num_bound, expr* const*
} else {
b = curr;
}
m_map.insert(curr, b);
val = b;
m_stack.pop_back();
}
break;
Expand All @@ -84,14 +85,14 @@ void expr_abstractor::operator()(unsigned base, unsigned num_bound, expr* const*
expr_ref result1(m);
unsigned new_base = base + q->get_num_decls();

for (unsigned i = 0; i < q->get_num_patterns(); ++i) {
for (unsigned i = 0, e = q->get_num_patterns(); i < e; ++i) {
result1 = expr_abstract(m, new_base, num_bound, bound, q->get_pattern(i));
patterns.push_back(result1.get());
}
result1 = expr_abstract(m, new_base, num_bound, bound, q->get_expr());
b = m.update_quantifier(q, patterns.size(), patterns.data(), result1.get());
m_pinned.push_back(b);
m_map.insert(curr, b);
val = b;
m_stack.pop_back();
break;
}
Expand All @@ -115,7 +116,7 @@ void expr_abstract(ast_manager& m, unsigned base, unsigned num_bound, expr* cons
tout << result << "\n";);
}

expr_ref mk_quantifier(quantifier_kind k, ast_manager& m, unsigned num_bound, app* const* bound, expr* n) {
static expr_ref mk_quantifier(quantifier_kind k, ast_manager& m, unsigned num_bound, app* const* bound, expr* n) {
expr_ref result(m);
expr_abstract(m, 0, num_bound, (expr* const*)bound, n, result);
if (num_bound > 0) {
Expand Down
3 changes: 0 additions & 3 deletions src/ast/expr_abstract.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,3 @@ expr_ref mk_forall(ast_manager& m, unsigned num_bound, app* const* bound, expr*
expr_ref mk_exists(ast_manager& m, unsigned num_bound, app* const* bound, expr* n);
inline expr_ref mk_forall(ast_manager& m, app* b, expr* n) { return mk_forall(m, 1, &b, n); }
inline expr_ref mk_forall(ast_manager& m, expr* b, expr* n) { return mk_forall(m, to_app(b), n); }



0 comments on commit 6f24123

Please sign in to comment.