Skip to content

Commit bbf1d22

Browse files
committed
Reduce variable equivalences unnecessarily generated by set_literals
There is no need to call set_literals for `A == A`, and if we end up in set_literals via another code path we can still avoid generating the trivially-true equality of `l == l`.
1 parent ced9262 commit bbf1d22

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/solvers/flattening/boolbv.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -483,10 +483,12 @@ bool boolbvt::boolbv_set_equality_to_true(const equal_exprt &expr)
483483

484484
const bvt &bv1=convert_bv(expr.rhs());
485485

486-
const irep_idt &identifier=
487-
to_symbol_expr(expr.lhs()).get_identifier();
486+
if(expr.rhs() != expr.lhs())
487+
{
488+
const irep_idt &identifier = to_symbol_expr(expr.lhs()).get_identifier();
488489

489-
map.set_literals(identifier, type, bv1);
490+
map.set_literals(identifier, type, bv1);
491+
}
490492

491493
if(freeze_all)
492494
set_frozen(bv1);

src/solvers/flattening/boolbv_map.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ void boolbv_mapt::set_literals(
110110
INVARIANT(
111111
bit < map_entry.literal_map.size(), "bit index shall be within bounds");
112112

113-
prop.set_equal(map_entry.literal_map[bit], literal);
113+
if(map_entry.literal_map[bit] != literal)
114+
{
115+
// this branch should be avoided wherever possible
116+
prop.set_equal(map_entry.literal_map[bit], literal);
117+
}
114118
}
115119
}
116120
}

0 commit comments

Comments
 (0)