Skip to content

Commit 067d36a

Browse files
committed
chore(floats): Add description fo FPToI workaround
1 parent df5b3b7 commit 067d36a

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

lib/Solver/BitwuzlaBuilder.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,15 @@ Term BitwuzlaBuilder::constructActual(ref<Expr> e, int *width_out) {
639639
{ce->getWidth()});
640640
}
641641

642+
643+
// https://smt-lib.org/theories-FloatingPoint.shtml
644+
//
645+
// All fp.to_* functions are unspecified for NaN and infinity input values.
646+
// In addition, fp.to_ubv and fp.to_sbv are unspecified for finite number inputs
647+
// that are out of range (which includes all negative numbers for fp.to_ubv).
648+
//
649+
// This workaround restricts fp.to_ubv and fp.to_sbv arguments to be in range.
650+
642651
case Expr::FPToSI: {
643652
int srcWidth;
644653
FPToSIExpr *ce = cast<FPToSIExpr>(e);
@@ -660,6 +669,7 @@ Term BitwuzlaBuilder::constructActual(ref<Expr> e, int *width_out) {
660669
ctx->mk_bv_min_signed(ctx->mk_bv_sort(*width_out))},
661670
{fp_widths.first, fp_widths.second})});
662671
sideConstraints.push_back(minBound);
672+
663673
return ctx->mk_term(Kind::FP_TO_SBV,
664674
{getRoundingModeSort(ce->roundingMode), src},
665675
{ce->getWidth()});

0 commit comments

Comments
 (0)