Skip to content

Commit 3da0d96

Browse files
authored
Merge pull request #6634 from tautschnig/feature/simplify-overflow_mult
Simplify overflow-mult when one operand is 1
2 parents 1f3801c + c2cbaad commit 3da0d96

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/util/simplify_expr.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2174,14 +2174,23 @@ simplify_exprt::simplify_complex(const unary_exprt &expr)
21742174
simplify_exprt::resultt<>
21752175
simplify_exprt::simplify_overflow_binary(const binary_overflow_exprt &expr)
21762176
{
2177-
// zero is a neutral element for all operations supported here
2177+
// When one operand is zero, an overflow can only occur for a subtraction from
2178+
// zero.
21782179
if(
21792180
expr.op1().is_zero() ||
21802181
(expr.op0().is_zero() && expr.id() != ID_overflow_minus))
21812182
{
21822183
return false_exprt{};
21832184
}
21842185

2186+
// One is neutral element for multiplication
2187+
if(
2188+
expr.id() == ID_overflow_mult &&
2189+
(expr.op0().is_one() || expr.op1().is_one()))
2190+
{
2191+
return false_exprt{};
2192+
}
2193+
21852194
// we only handle the case of same operand types
21862195
if(expr.op0().type() != expr.op1().type())
21872196
return unchanged(expr);

0 commit comments

Comments
 (0)