mirror of
https://github.com/Z3Prover/z3
synced 2025-06-21 21:33:39 +00:00
avoid perf abyss for macros
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
574246ff7a
commit
0ba518b0c0
5 changed files with 22 additions and 21 deletions
|
@ -209,6 +209,7 @@ namespace recfun {
|
|||
void def::compute_cases(util& u,
|
||||
replace& subst,
|
||||
is_immediate_pred & is_i,
|
||||
bool is_macro,
|
||||
unsigned n_vars, var *const * vars, expr* rhs)
|
||||
{
|
||||
VERIFY(m_cases.empty() && "cases cannot already be computed");
|
||||
|
@ -227,7 +228,7 @@ namespace recfun {
|
|||
expr_ref_vector conditions(m);
|
||||
|
||||
// is the function a macro (unconditional body)?
|
||||
if (n_vars == 0 || !contains_ite(u, rhs)) {
|
||||
if (is_macro || n_vars == 0 || !contains_ite(u, rhs)) {
|
||||
// constant function or trivial control flow, only one (dummy) case
|
||||
add_case(name, 0, conditions, rhs);
|
||||
return;
|
||||
|
@ -336,9 +337,9 @@ namespace recfun {
|
|||
}
|
||||
|
||||
|
||||
void util::set_definition(replace& subst, promise_def & d, unsigned n_vars, var * const * vars, expr * rhs) {
|
||||
void util::set_definition(replace& subst, promise_def & d, bool is_macro, unsigned n_vars, var * const * vars, expr * rhs) {
|
||||
expr_ref rhs1 = get_plugin().redirect_ite(subst, n_vars, vars, rhs);
|
||||
d.set_definition(subst, n_vars, vars, rhs1);
|
||||
d.set_definition(subst, is_macro, n_vars, vars, rhs1);
|
||||
}
|
||||
|
||||
app_ref util::mk_num_rounds_pred(unsigned d) {
|
||||
|
@ -369,11 +370,11 @@ namespace recfun {
|
|||
};
|
||||
|
||||
// set definition
|
||||
void promise_def::set_definition(replace& r, unsigned n_vars, var * const * vars, expr * rhs) {
|
||||
void promise_def::set_definition(replace& r, bool is_macro, unsigned n_vars, var * const * vars, expr * rhs) {
|
||||
SASSERT(n_vars == d->get_arity());
|
||||
|
||||
is_imm_pred is_i(*u);
|
||||
d->compute_cases(*u, r, is_i, n_vars, vars, rhs);
|
||||
d->compute_cases(*u, r, is_i, is_macro, n_vars, vars, rhs);
|
||||
}
|
||||
|
||||
namespace decl {
|
||||
|
@ -426,8 +427,8 @@ namespace recfun {
|
|||
}
|
||||
}
|
||||
|
||||
void plugin::set_definition(replace& r, promise_def & d, unsigned n_vars, var * const * vars, expr * rhs) {
|
||||
u().set_definition(r, d, n_vars, vars, rhs);
|
||||
void plugin::set_definition(replace& r, promise_def & d, bool is_macro, unsigned n_vars, var * const * vars, expr * rhs) {
|
||||
u().set_definition(r, d, is_macro, n_vars, vars, rhs);
|
||||
for (case_def & c : d.get_def()->get_cases()) {
|
||||
m_case_defs.insert(c.get_decl(), &c);
|
||||
}
|
||||
|
@ -437,12 +438,12 @@ namespace recfun {
|
|||
return !m_case_defs.empty();
|
||||
}
|
||||
|
||||
def* plugin::mk_def(replace& subst,
|
||||
def* plugin::mk_def(replace& subst, bool is_macro,
|
||||
symbol const& name, unsigned n, sort ** params, sort * range,
|
||||
unsigned n_vars, var ** vars, expr * rhs) {
|
||||
promise_def d = mk_def(name, n, params, range);
|
||||
SASSERT(! m_defs.contains(d.get_def()->get_decl()));
|
||||
set_definition(subst, d, n_vars, vars, rhs);
|
||||
set_definition(subst, d, is_macro, n_vars, vars, rhs);
|
||||
return d.get_def();
|
||||
}
|
||||
|
||||
|
@ -520,7 +521,7 @@ namespace recfun {
|
|||
auto pd = mk_def(fresh_name, n, domain.data(), max_expr->get_sort());
|
||||
func_decl* f = pd.get_def()->get_decl();
|
||||
expr_ref new_body(m().mk_app(f, n, args.data()), m());
|
||||
set_definition(subst, pd, n, vars, max_expr);
|
||||
set_definition(subst, pd, false, n, vars, max_expr);
|
||||
subst.reset();
|
||||
subst.insert(max_expr, new_body);
|
||||
result = subst(result);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue