3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 09:05:31 +00:00

Bug and performance fixes for FP UFs.

This commit is contained in:
Christoph M. Wintersteiger 2016-05-17 16:35:45 +01:00
parent ec565ae7a0
commit df81ab72f5
5 changed files with 122 additions and 42 deletions

View file

@ -100,18 +100,17 @@ br_status fpa_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr * con
SASSERT(num_args == 2); st = BR_FAILED; break;
case OP_FPA_INTERNAL_RM:
SASSERT(num_args == 1); st = mk_rm(args[0], result); break;
SASSERT(num_args == 1); SASSERT(num_args == 1); st = mk_rm(args[0], result); break;
case OP_FPA_INTERNAL_TO_UBV_UNSPECIFIED:
case OP_FPA_INTERNAL_TO_SBV_UNSPECIFIED:
case OP_FPA_INTERNAL_TO_REAL_UNSPECIFIED:
case OP_FPA_INTERNAL_TO_IEEE_BV_UNSPECIFIED:
st = BR_FAILED;
case OP_FPA_INTERNAL_BVWRAP:
case OP_FPA_INTERNAL_BVUNWRAP:
st = BR_FAILED;
break;
case OP_FPA_INTERNAL_BVWRAP: SASSERT(num_args == 1); st = mk_bvwrap(args[0], result); break;
case OP_FPA_INTERNAL_BVUNWRAP: SASSERT(num_args == 1); st = mk_bvunwrap(args[0], result); break;
default:
NOT_IMPLEMENTED_YET();
}
@ -892,3 +891,42 @@ br_status fpa_rewriter::mk_to_real(expr * arg, expr_ref & result) {
return BR_FAILED;
}
br_status fpa_rewriter::mk_bvwrap(expr * arg, expr_ref & result) {
if (is_app_of(arg, m_util.get_family_id(), OP_FPA_FP)) {
bv_util bu(m());
SASSERT(to_app(arg)->get_num_args() == 3);
sort_ref fpsrt(m());
fpsrt = to_app(arg)->get_decl()->get_range();
expr_ref a0(m()), a1(m()), a2(m());
a0 = to_app(arg)->get_arg(0);
a1 = to_app(arg)->get_arg(1);
a2 = to_app(arg)->get_arg(2);
if (bu.is_extract(a0) && bu.is_extract(a1) && bu.is_extract(a2)) {
unsigned w0 = bu.get_extract_high(a0) - bu.get_extract_low(a0) + 1;
unsigned w1 = bu.get_extract_high(a1) - bu.get_extract_low(a1) + 1;
unsigned w2 = bu.get_extract_high(a2) - bu.get_extract_low(a2) + 1;
unsigned cw = w0 + w1 + w2;
if (cw == m_util.get_ebits(fpsrt) + m_util.get_sbits(fpsrt)) {
expr_ref aa0(m()), aa1(m()), aa2(m());
aa0 = to_app(a0)->get_arg(0);
aa1 = to_app(a1)->get_arg(0);
aa2 = to_app(a2)->get_arg(0);
if (aa0 == aa1 && aa1 == aa2 && bu.get_bv_size(aa0) == cw) {
result = aa0;
return BR_DONE;
}
}
}
}
return BR_FAILED;
}
br_status fpa_rewriter::mk_bvunwrap(expr * arg, expr_ref & result) {
if (is_app_of(arg, m_util.get_family_id(), OP_FPA_INTERNAL_BVWRAP))
result = to_app(arg)->get_arg(0);
return BR_FAILED;
}

View file

@ -89,6 +89,9 @@ public:
br_status mk_to_ubv_unspecified(unsigned ebits, unsigned sbits, unsigned with, expr_ref & result);
br_status mk_to_sbv_unspecified(unsigned ebits, unsigned sbits, unsigned with, expr_ref & result);
br_status mk_to_real_unspecified(unsigned ebits, unsigned sbits, expr_ref & result);
br_status mk_bvwrap(expr * arg, expr_ref & result);
br_status mk_bvunwrap(expr * arg, expr_ref & result);
};
#endif