Skip to content

Commit 5473f7a

Browse files
committed
Remove redundant simplification rule
The simplification of if-expressions over constants within an (in)equality is already covered elsewhere, as confirmed both by the test added in the preceding commit (which still succeeds) and test coverage.
1 parent 4bf03bb commit 5473f7a

File tree

1 file changed

+0
-69
lines changed

1 file changed

+0
-69
lines changed

src/util/simplify_expr_int.cpp

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,36 +1460,6 @@ static bool eliminate_common_addends(exprt &op0, exprt &op1)
14601460
return true;
14611461
}
14621462

1463-
/// Collect integer-typed constants in \p values when \p expr either itself is a
1464-
/// constant or an if-expression; for an if-expression recursively collect those
1465-
/// values in the true- and false case, respectively.
1466-
/// \param expr: expression to collect constants from
1467-
/// \param [out] values: set of integer constants
1468-
/// \return false, iff all sub-expressions were either integer constants or if
1469-
/// expressions with true/false cases being constants or if expressions.
1470-
static bool collect_constants(const exprt &expr, std::set<mp_integer> &values)
1471-
{
1472-
if(expr.is_constant())
1473-
{
1474-
const auto int_value_opt = numeric_cast<mp_integer>(to_constant_expr(expr));
1475-
if(!int_value_opt.has_value())
1476-
return true;
1477-
1478-
values.insert(*int_value_opt);
1479-
1480-
return false;
1481-
}
1482-
else if(expr.id() == ID_if)
1483-
{
1484-
const auto &if_expr = to_if_expr(expr);
1485-
1486-
return collect_constants(if_expr.true_case(), values) ||
1487-
collect_constants(if_expr.false_case(), values);
1488-
}
1489-
1490-
return true;
1491-
}
1492-
14931463
simplify_exprt::resultt<> simplify_exprt::simplify_inequality_no_constant(
14941464
const binary_relation_exprt &expr)
14951465
{
@@ -1543,45 +1513,6 @@ simplify_exprt::resultt<> simplify_exprt::simplify_inequality_no_constant(
15431513
if(expr.op0() == expr.op1())
15441514
return true_exprt();
15451515

1546-
// try constants
1547-
1548-
std::set<mp_integer> values0, values1;
1549-
bool ok = !collect_constants(expr.op0(), values0);
1550-
if(ok)
1551-
ok = !collect_constants(expr.op1(), values1);
1552-
1553-
if(ok)
1554-
{
1555-
// We can simplify equality if both sides have exactly one constant value.
1556-
// This rule most likely never kicks in as we will already have simplified
1557-
// this case elsewhere (equalities with at least one side being constant are
1558-
// handled by other functions, and if expressions with multiple branches
1559-
// having the same value are simplified to remove the if expression).
1560-
if(expr.id() == ID_equal)
1561-
{
1562-
if(values0.size() == 1 && values1.size() == 1)
1563-
{
1564-
return make_boolean_expr(*values0.begin() == *values1.begin());
1565-
}
1566-
}
1567-
else
1568-
{
1569-
// ID_ge, as ensured by the above INVARIANT: the smallest value in values0
1570-
// must be >= the largest value in values1
1571-
if(*values0.begin() >= *values1.rbegin())
1572-
{
1573-
return make_boolean_expr(true);
1574-
}
1575-
// If all entries in values0 are smaller than the smallest entry in
1576-
// values1 then the result must be false.
1577-
else if(*values0.rbegin() < *values1.begin())
1578-
{
1579-
return make_boolean_expr(false);
1580-
}
1581-
// Else we don't know for sure.
1582-
}
1583-
}
1584-
15851516
// See if we can eliminate common addends on both sides.
15861517
// On bit-vectors, this is only sound on '='.
15871518
if(expr.id()==ID_equal)

0 commit comments

Comments
 (0)