Skip to content

Commit 7c83918

Browse files
committed
bv_utilst::equal: stop early when the result will be false
There is no need to create any further bit-level equalities when the result will be false anyway. On aws-c-common/aws_hash_iter_next, this reduces the number of Boolean variables from 2291304 to 584628, and the time spent in CaDiCaL from 191 seconds to 22 seconds.
1 parent 66384d6 commit 7c83918

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/solvers/flattening/bv_utils.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,16 @@ literalt bv_utilst::equal(const bvt &op0, const bvt &op1)
11851185
return equal_const(op0, op1);
11861186
#endif
11871187

1188+
// If the eventual result would be "false" anyway, avoid constructing
1189+
// equalities that would end up not affecting the satisfiability of the
1190+
// formula (effectively doing preprocessing steps that the SAT solver would
1191+
// otherwise have to undertake).
1192+
for(std::size_t i = 0; i < op0.size(); i++)
1193+
{
1194+
if(op0[i] != op1[i] && op0[i].var_no() == op1[i].var_no())
1195+
return const_literal(false);
1196+
}
1197+
11881198
bvt equal_bv;
11891199
equal_bv.resize(op0.size());
11901200

0 commit comments

Comments
 (0)