Skip to content

Commit

Permalink
Fix masking unconstrained multiplication and add test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Jonáš committed Jun 8, 2018
1 parent f427435 commit 4bd744f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/UnconstrainedVariableSimplifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ z3::expr UnconstrainedVariableSimplifier::simplifyOnce(expr e, std::vector<Bound
}
else if (mulReplacementMode == MASK)
{
returnAst = (1 << zeroes) & e.arg(0);
returnAst = (-1 << zeroes) & e.arg(0);
}
return to_expr(*context, returnAst);
}
Expand All @@ -384,7 +384,7 @@ z3::expr UnconstrainedVariableSimplifier::simplifyOnce(expr e, std::vector<Bound
}
else if (mulReplacementMode == MASK)
{
returnAst = (1 << zeroes) & e.arg(1);
returnAst = (-1 << zeroes) & e.arg(1);
}
return to_expr(*context, returnAst);
}
Expand Down
8 changes: 8 additions & 0 deletions tests/data/unconstrainedMulConst.smt2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(set-info :smt-lib-version 2.6)
(set-logic BV)
(set-info :status sat)

(declare-const x (_ BitVec 32))

(assert (bvugt (bvmul #x00000002 x) #x00000004))
(check-sat)
1 change: 1 addition & 0 deletions tests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ TEST_CASE( "Without approximations", "[noapprox]" )
REQUIRE( SolveWithoutApprox("../tests/data/magnetic_field-node118398.smt2") == UNSAT );
REQUIRE( SolveWithoutApprox("../tests/data/unconstrainedMulVar.smt2") == UNSAT );
REQUIRE( SolveWithoutApprox("../tests/data/check_bvsle_bvmul_8bit.smt2") == UNSAT );
REQUIRE( SolveWithoutApprox("../tests/data/unconstrainedMulConst.smt2") == SAT );
}

TEST_CASE( "With variable approximations", "[variableapprox]" )
Expand Down

0 comments on commit 4bd744f

Please sign in to comment.