Skip to content

Commit 9d66549

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 9909593 commit 9d66549

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
@@ -1181,6 +1181,16 @@ literalt bv_utilst::equal(const bvt &op0, const bvt &op1)
11811181
return equal_const(op0, op1);
11821182
#endif
11831183

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

0 commit comments

Comments
 (0)