Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/solvers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ SRC = $(BOOLEFORCE_SRC) \
flattening/boolbv_onehot.cpp \
flattening/boolbv_overflow.cpp \
flattening/boolbv_power.cpp \
flattening/boolbv_popcount.cpp \
flattening/boolbv_quantifier.cpp \
flattening/boolbv_reduction.cpp \
flattening/boolbv_replication.cpp \
Expand Down
4 changes: 2 additions & 2 deletions src/solvers/flattening/boolbv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ bvt boolbvt::convert_bitvector(const exprt &expr)
else if(expr.id()==ID_power)
return convert_power(to_binary_expr(expr));
else if(expr.id() == ID_popcount)
return convert_bv(simplify_expr(to_popcount_expr(expr).lower(), ns));
return convert_popcount(to_popcount_expr(expr));
else if(expr.id() == ID_count_leading_zeros)
{
return convert_bv(
Expand Down Expand Up @@ -407,7 +407,7 @@ literalt boolbvt::convert_rest(const exprt &expr)
CHECK_RETURN(!bv.empty());
const irep_idt type_id = op.type().id();
if(type_id == ID_signedbv || type_id == ID_fixedbv || type_id == ID_floatbv)
return bv[bv.size()-1];
return bv_utils.sign_bit(bv);
if(type_id == ID_unsignedbv)
return const_literal(false);
}
Expand Down
2 changes: 2 additions & 0 deletions src/solvers/flattening/boolbv.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class floatbv_round_to_integral_exprt;
class floatbv_typecast_exprt;
class ieee_float_op_exprt;
class overflow_result_exprt;
class popcount_exprt;
class replication_exprt;
class unary_overflow_exprt;
class union_typet;
Expand Down Expand Up @@ -203,6 +204,7 @@ class boolbvt:public arrayst
virtual bvt convert_bitreverse(const bitreverse_exprt &expr);
virtual bvt convert_saturating_add_sub(const binary_exprt &expr);
virtual bvt convert_overflow_result(const overflow_result_exprt &expr);
virtual bvt convert_popcount(const popcount_exprt &expr);

bvt convert_update_bits(bvt src, const exprt &index, const bvt &new_value);

Expand Down
20 changes: 20 additions & 0 deletions src/solvers/flattening/boolbv_popcount.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*******************************************************************\

Module:

Author: Michael Tautschnig

\*******************************************************************/

#include <util/bitvector_expr.h>

#include "boolbv.h"

bvt boolbvt::convert_popcount(const popcount_exprt &expr)
{
const std::size_t width = boolbv_width(expr.type());

bvt op = convert_bv(expr.op());

return bv_utils.zero_extension(bv_utils.popcount(op), width);
}
Loading
Loading