Skip to content

Commit 9b1a388

Browse files
committed
Factor out working out signedness in convert_binary_overflow
1 parent c0797f9 commit 9b1a388

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

src/solvers/flattening/boolbv_overflow.cpp

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ literalt boolbvt::convert_binary_overflow(const binary_overflow_exprt &expr)
2020
? optionalt<std::size_t>{bv0.size()}
2121
: nullopt);
2222

23+
const bv_utilst::representationt rep =
24+
expr.lhs().type().id() == ID_signedbv
25+
? bv_utilst::representationt::SIGNED
26+
: bv_utilst::representationt::UNSIGNED;
27+
2328
const auto plus_or_minus_conversion =
2429
[&](
2530
const binary_overflow_exprt &overflow_expr,
@@ -30,11 +35,6 @@ literalt boolbvt::convert_binary_overflow(const binary_overflow_exprt &expr)
3035
if(bv0.size() != bv1.size())
3136
return SUB::convert_rest(expr);
3237

33-
bv_utilst::representationt rep =
34-
overflow_expr.lhs().type().id() == ID_signedbv
35-
? bv_utilst::representationt::SIGNED
36-
: bv_utilst::representationt::UNSIGNED;
37-
3838
return bv_util_overflow(&bv_utils, bv0, bv1, rep);
3939
};
4040
if(
@@ -54,11 +54,6 @@ literalt boolbvt::convert_binary_overflow(const binary_overflow_exprt &expr)
5454
mult_overflow->lhs().type().id() != ID_signedbv)
5555
return SUB::convert_rest(expr);
5656

57-
bv_utilst::representationt rep =
58-
mult_overflow->lhs().type().id() == ID_signedbv
59-
? bv_utilst::representationt::SIGNED
60-
: bv_utilst::representationt::UNSIGNED;
61-
6257
DATA_INVARIANT(
6358
mult_overflow->lhs().type() == mult_overflow->rhs().type(),
6459
"operands of overflow_mult expression shall have same type");
@@ -105,11 +100,6 @@ literalt boolbvt::convert_binary_overflow(const binary_overflow_exprt &expr)
105100
std::size_t old_size = bv0.size();
106101
std::size_t new_size = old_size * 2;
107102

108-
bv_utilst::representationt rep =
109-
shl_overflow->lhs().type().id() == ID_signedbv
110-
? bv_utilst::representationt::SIGNED
111-
: bv_utilst::representationt::UNSIGNED;
112-
113103
bvt bv_ext=bv_utils.extension(bv0, new_size, rep);
114104

115105
bvt result=bv_utils.shift(bv_ext, bv_utilst::shiftt::SHIFT_LEFT, bv1);

0 commit comments

Comments
 (0)