Skip to content

Commit a868976

Browse files
committed
Add invariant that multiplication uses operands of the same size
Our implementations swap operands, and determine the size of the result from the size of the operand(s). Make sure we produce consistent-width results.
1 parent 646418f commit a868976

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/solvers/flattening/bv_utils.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,11 @@ bvt bv_utilst::multiplier(
10701070
const bvt &op1,
10711071
representationt rep)
10721072
{
1073+
// We determine the result size from the operand size, and the implementation
1074+
// liberally swaps the operands, so we need to arrive at the same size
1075+
// whatever the order of the operands.
1076+
PRECONDITION(op0.size() == op1.size());
1077+
10731078
switch(rep)
10741079
{
10751080
case representationt::SIGNED: return signed_multiplier(op0, op1);

0 commit comments

Comments
 (0)