Skip to content

Commit 8be266c

Browse files
micro tuning for #4192
1 parent f313ab9 commit 8be266c

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

src/smt/smt_context.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,10 @@ namespace smt {
735735

736736
bool ts_visit_children(expr * n, bool gate_ctx, svector<int> & tcolors, svector<int> & fcolors, svector<expr_bool_pair> & todo);
737737

738+
svector<expr_bool_pair> ts_todo;
739+
svector<int> tcolors;
740+
svector<int> fcolors;
741+
738742
void top_sort_expr(expr * n, svector<expr_bool_pair> & sorted_exprs);
739743

740744
void assert_default(expr * n, proof * pr);

src/smt/smt_internalizer.cpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,7 @@ namespace smt {
126126
if (!def_int) {
127127
ptr_buffer<expr> descendants;
128128
get_foreign_descendants(to_app(n), fid, descendants);
129-
ptr_buffer<expr>::iterator it = descendants.begin();
130-
ptr_buffer<expr>::iterator end = descendants.end();
131-
for (; it != end; ++it) {
132-
expr * arg = *it;
129+
for (expr * arg : descendants) {
133130
ts_visit_child(arg, false, tcolors, fcolors, todo, visited);
134131
}
135132
return visited;
@@ -154,27 +151,27 @@ namespace smt {
154151
}
155152

156153
void context::top_sort_expr(expr * n, svector<expr_bool_pair> & sorted_exprs) {
157-
svector<expr_bool_pair> todo;
158-
svector<int> tcolors;
159-
svector<int> fcolors;
160-
todo.push_back(expr_bool_pair(n, true));
161-
while (!todo.empty()) {
162-
expr_bool_pair & p = todo.back();
154+
ts_todo.reset();
155+
tcolors.reset();
156+
fcolors.reset();
157+
ts_todo.push_back(expr_bool_pair(n, true));
158+
while (!ts_todo.empty()) {
159+
expr_bool_pair & p = ts_todo.back();
163160
expr * curr = p.first;
164161
bool gate_ctx = p.second;
165162
switch (get_color(tcolors, fcolors, curr, gate_ctx)) {
166163
case White:
167164
set_color(tcolors, fcolors, curr, gate_ctx, Grey);
168-
ts_visit_children(curr, gate_ctx, tcolors, fcolors, todo);
165+
ts_visit_children(curr, gate_ctx, tcolors, fcolors, ts_todo);
169166
break;
170167
case Grey:
171-
SASSERT(ts_visit_children(curr, gate_ctx, tcolors, fcolors, todo));
168+
SASSERT(ts_visit_children(curr, gate_ctx, tcolors, fcolors, ts_todo));
172169
set_color(tcolors, fcolors, curr, gate_ctx, Black);
173170
if (n != curr && !m.is_not(curr))
174171
sorted_exprs.push_back(expr_bool_pair(curr, gate_ctx));
175172
break;
176173
case Black:
177-
todo.pop_back();
174+
ts_todo.pop_back();
178175
break;
179176
default:
180177
UNREACHABLE();
@@ -185,7 +182,7 @@ namespace smt {
185182
#define DEEP_EXPR_THRESHOLD 1024
186183

187184
void context::internalize_deep(expr* n) {
188-
if (::get_depth(n) > DEEP_EXPR_THRESHOLD) {
185+
if (!e_internalized(n) && ::get_depth(n) > DEEP_EXPR_THRESHOLD) {
189186
// if the expression is deep, then execute topological sort to avoid
190187
// stack overflow.
191188
// a caveat is that theory internalizers do rely on recursive descent so

src/smt/theory_fpa.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -388,16 +388,15 @@ namespace smt {
388388
context & ctx = get_context();
389389

390390
expr_ref res(m), t(m);
391+
expr_ref_vector fmls(m);
391392
proof_ref t_pr(m);
392-
res = m.mk_true();
393393

394-
expr_ref_vector::iterator it = m_converter.m_extra_assertions.begin();
395-
expr_ref_vector::iterator end = m_converter.m_extra_assertions.end();
396-
for (; it != end; it++) {
397-
ctx.get_rewriter()(*it, t, t_pr);
398-
res = m.mk_and(res, t);
394+
for (expr* arg : m_converter.m_extra_assertions) {
395+
ctx.get_rewriter()(arg, t, t_pr);
396+
fmls.push_back(t);
399397
}
400398
m_converter.m_extra_assertions.reset();
399+
res = m.mk_and(fmls);
401400

402401
m_th_rw(res);
403402

0 commit comments

Comments
 (0)