Simplify all-zero or all-one constants in bitand/bitor#8944
Simplify all-zero or all-one constants in bitand/bitor#8944tautschnig wants to merge 1 commit intodiffblue:developfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds simplification rules for bitwise operations involving all-zero/all-one constants, plus new regression tests around expression simplification.
Changes:
- Simplify
bitandto zero when any operand is an all-zero bitvector constant. - Simplify
bitorto all-ones when any operand is an all-ones constant. - Add unit tests for bitand/all-zero and a few other simplify rules.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
src/util/simplify_expr_int.cpp |
Implements early-return simplifications for bitand with all-zeros and bitor with all-ones. |
unit/util/simplify_expr.cpp |
Adds new simplification regression tests, including all-zero in bitand. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c425d32 to
f8073ad
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #8944 +/- ##
========================================
Coverage 80.47% 80.47%
========================================
Files 1704 1704
Lines 188694 188741 +47
Branches 73 73
========================================
+ Hits 151843 151887 +44
- Misses 36851 36854 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
We've got |
all-zeros in bitand yields zero, all-ones in bitor yield all-ones. Use from_integer() for type-agnostic constant construction so the rules apply to all bitvector types (bv, unsignedbv, signedbv), not just bv_typet. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
f8073ad to
64f338e
Compare
Done and included an additional test for the possibly-failing case. |
all-zeros in bitand yields zero, all-ones in bitor yield all-ones.