File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
src/solvers/smt2_incremental Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -878,6 +878,29 @@ static smt_termt convert_expr_to_smt(const plus_overflow_exprt &plus_overflow)
878
878
879
879
static smt_termt convert_expr_to_smt (const minus_overflow_exprt &minus_overflow)
880
880
{
881
+ const smt_termt left = convert_expr_to_smt (minus_overflow.lhs ());
882
+ const smt_termt right = convert_expr_to_smt (minus_overflow.rhs ());
883
+ if (operands_are_of_type<unsignedbv_typet>(minus_overflow))
884
+ {
885
+ return smt_bit_vector_theoryt::unsigned_less_than (left, right);
886
+ }
887
+ if (operands_are_of_type<signedbv_typet>(minus_overflow))
888
+ {
889
+ // Overflow has occurred if the operands have the opposing signs and
890
+ // subtracting them gives a result having the same signedness as the
891
+ // right-hand operand. For example the following would be overflow for cases
892
+ // for 8 bit wide bit vectors -
893
+ // -128 - 1 == 127
894
+ // 127 - (-1) == -128
895
+ const smt_termt msb_left = most_significant_bit_is_set (left);
896
+ const smt_termt msb_right = most_significant_bit_is_set (right);
897
+ return smt_core_theoryt::make_and (
898
+ smt_core_theoryt::distinct (msb_left, msb_right),
899
+ smt_core_theoryt::equal (
900
+ msb_right,
901
+ most_significant_bit_is_set (
902
+ smt_bit_vector_theoryt::subtract (left, right))));
903
+ }
881
904
UNIMPLEMENTED_FEATURE (
882
905
" Generation of SMT formula for minus overflow expression: " +
883
906
minus_overflow.pretty ());
You can’t perform that action at this time.
0 commit comments