Skip to content

Commit 6b73222

Browse files
authored
Merge pull request #7571 from tautschnig/bugfixes/no-unconditional-cast
Byte-operator lowering: do not unconditionally insert bv cast
2 parents e024ecb + f67691e commit 6b73222

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/util/lower_byte_operators.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,17 +337,22 @@ static exprt bv_to_expr(
337337
{
338338
PRECONDITION(can_cast_type<bitvector_typet>(bitvector_expr.type()));
339339

340-
if(
341-
can_cast_type<bitvector_typet>(target_type) ||
342-
target_type.id() == ID_c_enum || target_type.id() == ID_c_enum_tag ||
343-
target_type.id() == ID_string)
340+
if(target_type.id() == ID_floatbv)
344341
{
345342
std::size_t width = to_bitvector_type(bitvector_expr.type()).get_width();
346343
exprt bv_expr =
347344
typecast_exprt::conditional_cast(bitvector_expr, bv_typet{width});
348345
return simplify_expr(
349346
typecast_exprt::conditional_cast(bv_expr, target_type), ns);
350347
}
348+
else if(
349+
can_cast_type<bitvector_typet>(target_type) ||
350+
target_type.id() == ID_c_enum || target_type.id() == ID_c_enum_tag ||
351+
target_type.id() == ID_string)
352+
{
353+
return simplify_expr(
354+
typecast_exprt::conditional_cast(bitvector_expr, target_type), ns);
355+
}
351356

352357
if(target_type.id() == ID_struct)
353358
{

0 commit comments

Comments
 (0)