Skip to content

Commit cef6c50

Browse files
committed
Remove vectors: Boolean expressions do not required signed bitvectors
Any bitvector type will do as all we need to produce is a constant with all bits set (see https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html: "Vectors are compared element-wise producing 0 when comparison is false and -1 (constant of the appropriate type where all bits are set) otherwise.").
1 parent b0744ea commit cef6c50

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/goto-programs/remove_vector.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Date: September 2014
1414
#include "remove_vector.h"
1515

1616
#include <util/arith_tools.h>
17+
#include <util/bitvector_types.h>
1718
#include <util/std_expr.h>
1819

1920
#include <ansi-c/c_expr.h>
@@ -188,8 +189,11 @@ static void remove_vector(exprt &expr)
188189
const auto dimension = numeric_cast_v<std::size_t>(vector_type.size());
189190

190191
const typet &subtype = vector_type.element_type();
191-
PRECONDITION(subtype.id() == ID_signedbv);
192-
exprt minus_one = from_integer(-1, subtype);
192+
exprt minus_one = constant_exprt{
193+
make_bvrep(
194+
to_bitvector_type(subtype).get_width(),
195+
[](std::size_t) { return true; }),
196+
subtype};
193197
exprt zero = from_integer(0, subtype);
194198

195199
exprt::operandst operands;

0 commit comments

Comments
 (0)