Add div_overflow_exprt for bit-vector division overflow#9087
Open
kroening wants to merge 2 commits into
Open
Conversation
Introduce `div_overflow_exprt` (ID `overflow-/`) as a subclass of `binary_overflow_exprt`, analogous to the existing `plus_overflow_exprt`, `minus_overflow_exprt`, `mult_overflow_exprt`, and `shl_overflow_exprt`. Signed integer division overflows exactly when dividing INT_MIN by -1. Unsigned division never overflows. The expression is wired into all downstream backends: propositional flattening, non-incremental SMT2, incremental SMT2, the simplifier, and `lower()`. The existing ad-hoc construction in `goto_check_ct::integer_overflow_check` is replaced with the new expression. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Extend simplify_overflow_binary to reduce div_overflow_exprt early when either operand rules out the INT_MIN/-1 case: if the dividend is a constant != INT_MIN, or the divisor is a constant != -1, or the type is unsigned, the expression simplifies to false. Without this, the old inline and_exprt (which the simplifier could immediately fold) was replaced by an opaque div_overflow_exprt node that survived into the assertion list, causing Division3 to report a spurious overflow check. - Fix line length and clang-format issues in the SMT2 incremental backend conversion for div_overflow_exprt. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #9087 +/- ##
===========================================
- Coverage 80.69% 80.69% -0.01%
===========================================
Files 1714 1714
Lines 189597 189659 +62
Branches 73 73
===========================================
+ Hits 152987 153036 +49
- Misses 36610 36623 +13 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
div_overflow_exprt(IR idoverflow-/) as a new subclass ofbinary_overflow_exprt, following the same pattern asplus_overflow_exprt,minus_overflow_exprt,mult_overflow_exprt, andshl_overflow_exprtINT_MINby-1; unsigned division never overflows — both cases are encoded inlower()and in each backendand_exprt(int_min_eq, minus_one_eq)construction ingoto_check_ct::integer_overflow_checkwith the new expressionChanges
src/util/irep_ids.def— new idoverflow-/src/util/bitvector_expr.h/.cpp—div_overflow_exprtclass withlower();valid_id()andto_binary_overflow_expr()updatedsrc/util/simplify_expr.cpp— constant-folding fordiv_overflow_exprtsrc/solvers/flattening/boolbv_overflow.cpp— propositional backendsrc/solvers/smt2/smt2_conv.cpp— non-incremental SMT2 backendsrc/solvers/smt2_incremental/convert_expr_to_smt.cpp— incremental SMT2 backendsrc/ansi-c/goto-conversion/goto_check_c.cpp— usediv_overflow_exprtTest plan
🤖 Generated with Claude Code