@@ -619,6 +619,21 @@ Term BitwuzlaBuilder::constructActual(ref<Expr> e, int *width_out) {
619
619
Term src = castToFloat (construct (ce->src , &srcWidth));
620
620
*width_out = ce->getWidth ();
621
621
FPCastWidthAssert (width_out, " Invalid FPToUI width" );
622
+ auto fp_widths = getFloatSortFromBitWidth (srcWidth);
623
+ Term maxBound = ctx->mk_term (
624
+ Kind::FP_LEQ,
625
+ {src, ctx->mk_term (Kind::FP_TO_FP_FROM_UBV,
626
+ {getRoundingModeSort (ce->roundingMode ),
627
+ ctx->mk_bv_ones (ctx->mk_bv_sort (*width_out))},
628
+ {fp_widths.first , fp_widths.second })});
629
+ sideConstraints.push_back (maxBound);
630
+ Term minBound = ctx->mk_term (
631
+ Kind::FP_GEQ,
632
+ {src, ctx->mk_term (Kind::FP_TO_FP_FROM_UBV,
633
+ {getRoundingModeSort (ce->roundingMode ),
634
+ ctx->mk_bv_zero (ctx->mk_bv_sort (*width_out))},
635
+ {fp_widths.first , fp_widths.second })});
636
+ sideConstraints.push_back (minBound);
622
637
return ctx->mk_term (Kind::FP_TO_UBV,
623
638
{getRoundingModeSort (ce->roundingMode ), src},
624
639
{ce->getWidth ()});
@@ -630,6 +645,21 @@ Term BitwuzlaBuilder::constructActual(ref<Expr> e, int *width_out) {
630
645
Term src = castToFloat (construct (ce->src , &srcWidth));
631
646
*width_out = ce->getWidth ();
632
647
FPCastWidthAssert (width_out, " Invalid FPToSI width" );
648
+ auto fp_widths = getFloatSortFromBitWidth (srcWidth);
649
+ Term maxBound = ctx->mk_term (
650
+ Kind::FP_LEQ,
651
+ {src, ctx->mk_term (Kind::FP_TO_FP_FROM_SBV,
652
+ {getRoundingModeSort (ce->roundingMode ),
653
+ ctx->mk_bv_max_signed (ctx->mk_bv_sort (*width_out))},
654
+ {fp_widths.first , fp_widths.second })});
655
+ sideConstraints.push_back (maxBound);
656
+ Term minBound = ctx->mk_term (
657
+ Kind::FP_GEQ,
658
+ {src, ctx->mk_term (Kind::FP_TO_FP_FROM_SBV,
659
+ {getRoundingModeSort (ce->roundingMode ),
660
+ ctx->mk_bv_min_signed (ctx->mk_bv_sort (*width_out))},
661
+ {fp_widths.first , fp_widths.second })});
662
+ sideConstraints.push_back (minBound);
633
663
return ctx->mk_term (Kind::FP_TO_SBV,
634
664
{getRoundingModeSort (ce->roundingMode ), src},
635
665
{ce->getWidth ()});
0 commit comments