Skip to content

Commit 0de3a0e

Browse files
committed
Consistently use convert_bv instead of convert
This will place all expressions in boolbvt's cache instead of sometimes using prop_convt's cache.
1 parent 3a577d7 commit 0de3a0e

8 files changed

+51
-23
lines changed

src/solvers/flattening/boolbv_byte_extract.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr)
161161
else
162162
equal_bv[j]=const_literal(true);
163163

164-
prop.l_set_to_true(prop.limplies(
165-
convert(equal_exprt(expr.offset(), from_integer(i, constant_type))),
166-
prop.land(equal_bv)));
164+
const bvt &eq_bv = convert_bv(equal_exprt(expr.offset(), from_integer(i, constant_type)));
165+
CHECK_RETURN(eq_bv.size() == 1);
166+
prop.l_set_to_true(prop.limplies(eq_bv[0], prop.land(equal_bv)));
167167
}
168168
}
169169
else
@@ -173,8 +173,9 @@ bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr)
173173

174174
for(std::size_t i=0; i<bytes; i++)
175175
{
176-
literalt e =
177-
convert(equal_exprt(expr.offset(), from_integer(i, constant_type)));
176+
const bvt &eq_bv = convert_bv(equal_exprt(expr.offset(), from_integer(i, constant_type)));
177+
CHECK_RETURN(eq_bv.size() == 1);
178+
literalt e = eq_bv[0];
178179

179180
std::size_t offset=i*byte_width;
180181

src/solvers/flattening/boolbv_byte_update.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ bvt boolbvt::convert_byte_update(const byte_update_exprt &expr)
8787
// index condition
8888
equal_exprt equality(
8989
offset_expr, from_integer(offset / byte_width, offset_expr.type()));
90-
literalt equal=convert(equality);
90+
const bvt &eq_bv = convert_bv(equality);
91+
CHECK_RETURN(eq_bv.size() == 1);
92+
literalt equal = eq_bv[0];
9193

9294
bv_endianness_mapt map_op(op.type(), little_endian, ns, boolbv_width);
9395
bv_endianness_mapt map_value(value.type(), little_endian, ns, boolbv_width);

src/solvers/flattening/boolbv_cond.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ bvt boolbvt::convert_cond(const cond_exprt &expr)
4141
{
4242
if(condition)
4343
{
44-
cond_literal=convert(*it);
44+
const bvt &cond_bv = convert_bv(*it);
45+
CHECK_RETURN(cond_bv.size() == 1);
46+
cond_literal = cond_bv[0];
4547
cond_literal=prop.land(!previous_cond, cond_literal);
4648

4749
previous_cond=prop.lor(previous_cond, cond_literal);
@@ -70,7 +72,9 @@ bvt boolbvt::convert_cond(const cond_exprt &expr)
7072
const exprt &cond=expr.operands()[i-2];
7173
const exprt &value=expr.operands()[i-1];
7274

73-
literalt cond_literal=convert(cond);
75+
const bvt &cond_bv = convert_bv(cond);
76+
CHECK_RETURN(cond_bv.size() == 1);
77+
literalt cond_literal = cond_bv[0];
7478

7579
const bvt &op = convert_bv(value, bv.size());
7680

src/solvers/flattening/boolbv_extractbit.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ literalt boolbvt::convert_extractbit(const extractbit_exprt &expr)
6666
{
6767
equality.rhs()=from_integer(i, index_type);
6868
literalt equal = prop.lequal(literal, src_bv[i]);
69-
prop.l_set_to_true(prop.limplies(convert(equality), equal));
69+
const bvt &eq_bv = convert_bv(equality);
70+
CHECK_RETURN(eq_bv.size() == 1);
71+
prop.l_set_to_true(prop.limplies(eq_bv[0], equal));
7072
}
7173

7274
return literal;
@@ -78,7 +80,9 @@ literalt boolbvt::convert_extractbit(const extractbit_exprt &expr)
7880
for(std::size_t i = 0; i < src_bv.size(); i++)
7981
{
8082
equality.rhs()=from_integer(i, index_type);
81-
literal = prop.lselect(convert(equality), src_bv[i], literal);
83+
const bvt &eq_bv = convert_bv(equality);
84+
CHECK_RETURN(eq_bv.size() == 1);
85+
literal = prop.lselect(eq_bv[0], src_bv[i], literal);
8286
}
8387

8488
return literal;

src/solvers/flattening/boolbv_if.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ bvt boolbvt::convert_if(const if_exprt &expr)
1616
if(width==0)
1717
return bvt(); // An empty bit-vector if.
1818

19-
literalt cond=convert(expr.cond());
19+
const bvt &cond_bv = convert_bv(expr.cond());
20+
CHECK_RETURN(cond_bv.size() == 1);
21+
literalt cond = cond_bv[0];
2022

2123
const bvt &true_case_bv = convert_bv(expr.true_case(), width);
2224
const bvt &false_case_bv = convert_bv(expr.false_case(), width);

src/solvers/flattening/boolbv_index.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ bvt boolbvt::convert_index(const index_exprt &expr)
116116

117117
// Simplify may remove the lower bound if the type
118118
// is correct.
119-
prop.l_set_to_true(convert(simplify_expr(implication, ns)));
119+
simplify(implication, ns);
120+
const bvt &bv2 = convert_bv(implication);
121+
CHECK_RETURN(bv2.size() == 1);
122+
prop.l_set_to_true(bv2[0]);
120123

121124
return bv;
122125
}
@@ -159,9 +162,12 @@ bvt boolbvt::convert_index(const index_exprt &expr)
159162
"past the array's end");
160163

161164
// Cache comparisons and equalities
162-
prop.l_set_to_true(convert(implies_exprt(
165+
const bvt &bv2 =
166+
convert_bv(implies_exprt(
163167
equal_exprt(index, from_integer(i, index.type())),
164-
equal_exprt(result, *it++))));
168+
equal_exprt(result, *it++)));
169+
CHECK_RETURN(bv2.size() == 1);
170+
prop.l_set_to_true(bv2[0]);
165171
}
166172

167173
return bv;
@@ -208,9 +214,9 @@ bvt boolbvt::convert_index(const index_exprt &expr)
208214
equal_bv[j] = prop.lequal(
209215
bv[j], array_bv[numeric_cast_v<std::size_t>(offset + j)]);
210216

211-
prop.l_set_to_true(prop.limplies(
212-
convert(equal_exprt(index, from_integer(i, index.type()))),
213-
prop.land(equal_bv)));
217+
const bvt &index_eq = convert_bv(equal_exprt(index, from_integer(i, index_type())));
218+
CHECK_RETURN(index_eq.size() == 1);
219+
prop.l_set_to_true(prop.limplies(index_eq[0], prop.land(equal_bv)));
214220
}
215221
}
216222
else
@@ -229,8 +235,9 @@ bvt boolbvt::convert_index(const index_exprt &expr)
229235

230236
for(mp_integer i=0; i<array_size; i=i+1)
231237
{
232-
literalt e =
233-
convert(equal_exprt(index, from_integer(i, constant_type)));
238+
const bvt &eq_bv = convert_bv(equal_exprt(index, from_integer(i, constant_type)));
239+
CHECK_RETURN(eq_bv.size() == 1);
240+
literalt e = eq_bv[0];
234241

235242
mp_integer offset=i*width;
236243

src/solvers/flattening/boolbv_with.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ void boolbvt::convert_with_array(
167167
{
168168
exprt counter=from_integer(i, counter_type);
169169

170-
literalt eq_lit=convert(equal_exprt(op1, counter));
170+
const bvt &eq_bv = convert_bv(equal_exprt(op1, counter));
171+
CHECK_RETURN(eq_bv.size() == 1);
172+
literalt eq_lit = eq_bv[0];
171173

172174
const std::size_t offset = numeric_cast_v<std::size_t>(i * op2_bv.size());
173175

@@ -183,7 +185,9 @@ void boolbvt::convert_with_bv(
183185
const bvt &prev_bv,
184186
bvt &next_bv)
185187
{
186-
literalt l=convert(op2);
188+
const bvt &bv = convert_bv(op2);
189+
CHECK_RETURN(bv.size() == 1);
190+
literalt l = bv[0];
187191

188192
if(const auto op1_value = numeric_cast<mp_integer>(op1))
189193
{
@@ -201,7 +205,9 @@ void boolbvt::convert_with_bv(
201205
{
202206
exprt counter=from_integer(i, counter_type);
203207

204-
literalt eq_lit=convert(equal_exprt(op1, counter));
208+
const bvt &eq_bv = convert_bv(equal_exprt(op1, counter));
209+
CHECK_RETURN(eq_bv.size() == 1);
210+
literalt eq_lit = eq_bv[0];
205211

206212
next_bv[i]=prop.lselect(eq_lit, l, prev_bv[i]);
207213
}

src/solvers/flattening/bv_pointers.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ bool bv_pointerst::convert_address_of_rec(
197197
{
198198
const if_exprt &ifex=to_if_expr(expr);
199199

200-
literalt cond=convert(ifex.cond());
200+
const bvt &cond_bv = convert_bv(ifex.cond());
201+
CHECK_RETURN(cond_bv.size() == 1);
202+
literalt cond = cond_bv[0];
201203

202204
bvt bv1, bv2;
203205

0 commit comments

Comments
 (0)