Skip to content

Commit 600c3fa

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 9d8f3f2 commit 600c3fa

8 files changed

+51
-19
lines changed

src/solvers/flattening/boolbv_byte_extract.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,9 @@ bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr)
144144
else
145145
equal_bv[j]=const_literal(true);
146146

147-
prop.l_set_to_true(
148-
prop.limplies(convert(equality), prop.land(equal_bv)));
147+
const bvt &eq_bv = convert_bv(equality);
148+
CHECK_RETURN(eq_bv.size() == 1);
149+
prop.l_set_to_true(prop.limplies(eq_bv[0], prop.land(equal_bv)));
149150
}
150151
}
151152
else
@@ -159,7 +160,9 @@ bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr)
159160
{
160161
equality.rhs()=from_integer(i, constant_type);
161162

162-
literalt e=convert(equality);
163+
const bvt &eq_bv = convert_bv(equality);
164+
CHECK_RETURN(eq_bv.size() == 1);
165+
literalt e = eq_bv[0];
163166

164167
std::size_t offset=i*byte_width;
165168

src/solvers/flattening/boolbv_byte_update.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ bvt boolbvt::convert_byte_update(const byte_update_exprt &expr)
9191
equal_exprt equality;
9292
equality.lhs()=offset_expr;
9393
equality.rhs()=from_integer(offset/byte_width, offset_expr.type());
94-
literalt equal=convert(equality);
94+
95+
const bvt &eq_bv = convert_bv(equality);
96+
CHECK_RETURN(eq_bv.size() == 1);
97+
literalt equal = eq_bv[0];
9598

9699
endianness_mapt map_op(op.type(), little_endian, ns);
97100
endianness_mapt map_value(value.type(), little_endian, ns);

src/solvers/flattening/boolbv_cond.cpp

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

4850
previous_cond=prop.lor(previous_cond, cond_literal);
@@ -74,7 +76,9 @@ bvt boolbvt::convert_cond(const exprt &expr)
7476
const exprt &cond=expr.operands()[i-2];
7577
const exprt &value=expr.operands()[i-1];
7678

77-
literalt cond_literal=convert(cond);
79+
const bvt &cond_bv = convert_bv(cond);
80+
CHECK_RETURN(cond_bv.size() == 1);
81+
literalt cond_literal = cond_bv[0];
7882

7983
const bvt &op=convert_bv(value);
8084

src/solvers/flattening/boolbv_extractbit.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ literalt boolbvt::convert_extractbit(const extractbit_exprt &expr)
7171
{
7272
equality.rhs()=from_integer(i, index_type);
7373
literalt equal=prop.lequal(l, bv0[i]);
74-
prop.l_set_to_true(prop.limplies(convert(equality), equal));
74+
const bvt &eq_bv = convert_bv(equality);
75+
CHECK_RETURN(eq_bv.size() == 1);
76+
prop.l_set_to_true(prop.limplies(eq_bv[0], equal));
7577
}
7678

7779
return l;
@@ -83,7 +85,9 @@ literalt boolbvt::convert_extractbit(const extractbit_exprt &expr)
8385
for(std::size_t i=0; i<bv0.size(); i++)
8486
{
8587
equality.rhs()=from_integer(i, index_type);
86-
l=prop.lselect(convert(equality), bv0[i], l);
88+
const bvt &eq_bv = convert_bv(equality);
89+
CHECK_RETURN(eq_bv.size() == 1);
90+
l=prop.lselect(eq_bv[0], bv0[i], l);
8791
}
8892

8993
return l;

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 &op1_bv=convert_bv(expr.true_case());
2224
const bvt &op2_bv=convert_bv(expr.false_case());

src/solvers/flattening/boolbv_index.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,10 @@ bvt boolbvt::convert_index(const index_exprt &expr)
132132

133133
// Simplify may remove the lower bound if the type
134134
// is correct.
135-
prop.l_set_to_true(convert(simplify_expr(implication, ns)));
135+
simplify(implication, ns);
136+
const bvt &bv2 = convert_bv(implication);
137+
CHECK_RETURN(bv2.size() == 1);
138+
prop.l_set_to_true(bv2[0]);
136139

137140
return bv;
138141
}
@@ -186,8 +189,10 @@ bvt boolbvt::convert_index(const index_exprt &expr)
186189
value_equality.rhs()=*it++;
187190

188191
// Cache comparisons and equalities
189-
prop.l_set_to_true(convert(implies_exprt(index_equality,
190-
value_equality)));
192+
const bvt &bv2 =
193+
convert_bv(implies_exprt(index_equality, value_equality));
194+
CHECK_RETURN(bv2.size() == 1);
195+
prop.l_set_to_true(bv2[0]);
191196
}
192197

193198
return bv;
@@ -244,8 +249,9 @@ bvt boolbvt::convert_index(const index_exprt &expr)
244249
equal_bv[j]=prop.lequal(bv[j],
245250
array_bv[integer2size_t(offset+j)]);
246251

247-
prop.l_set_to_true(
248-
prop.limplies(convert(index_equality), prop.land(equal_bv)));
252+
const bvt &index_eq = convert_bv(index_equality);
253+
CHECK_RETURN(index_eq.size() == 1);
254+
prop.l_set_to_true(prop.limplies(index_eq[0], prop.land(equal_bv)));
249255
}
250256
}
251257
else
@@ -267,7 +273,9 @@ bvt boolbvt::convert_index(const index_exprt &expr)
267273
{
268274
equality.op1()=from_integer(i, constant_type);
269275

270-
literalt e=convert(equality);
276+
const bvt &eq_bv = convert_bv(equality);
277+
CHECK_RETURN(eq_bv.size() == 1);
278+
literalt e = eq_bv[0];
271279

272280
mp_integer offset=i*width;
273281

src/solvers/flattening/boolbv_with.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ void boolbvt::convert_with_array(
160160
{
161161
exprt counter=from_integer(i, counter_type);
162162

163-
literalt eq_lit=convert(equal_exprt(op1, counter));
163+
const bvt &eq_bv = convert_bv(equal_exprt(op1, counter));
164+
CHECK_RETURN(eq_bv.size() == 1);
165+
literalt eq_lit = eq_bv[0];
164166

165167
std::size_t offset=integer2unsigned(i*op2_bv.size());
166168

@@ -177,7 +179,9 @@ void boolbvt::convert_with_bv(
177179
const bvt &prev_bv,
178180
bvt &next_bv)
179181
{
180-
literalt l=convert(op2);
182+
const bvt &bv = convert_bv(op2);
183+
CHECK_RETURN(bv.size() == 1);
184+
literalt l = bv[0];
181185

182186
mp_integer op1_value;
183187
if(!to_integer(op1, op1_value))
@@ -196,7 +200,9 @@ void boolbvt::convert_with_bv(
196200
{
197201
exprt counter=from_integer(i, counter_type);
198202

199-
literalt eq_lit=convert(equal_exprt(op1, counter));
203+
const bvt &eq_bv = convert_bv(equal_exprt(op1, counter));
204+
CHECK_RETURN(eq_bv.size() == 1);
205+
literalt eq_lit = eq_bv[0];
200206

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

src/solvers/flattening/bv_pointers.cpp

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

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

203205
bvt bv1, bv2;
204206

0 commit comments

Comments
 (0)