Simplify all-zero or all-one constants in bitand/bitor#8944
Simplify all-zero or all-one constants in bitand/bitor#8944kroening merged 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.48% +0.01%
===========================================
Files 1704 1704
Lines 188702 188749 +47
Branches 73 73
===========================================
+ Hits 151854 151911 +57
+ Misses 36848 36838 -10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
We've got |
f8073ad to
64f338e
Compare
Done and included an additional test for the possibly-failing case. |
src/util/simplify_expr_int.cpp
Outdated
| : from_integer(0, new_expr.type()); | ||
| for(const auto &op : new_expr.operands()) | ||
| { | ||
| if(op.is_constant() && op == zero) |
There was a problem hiding this comment.
You don't need the op.is_constant()
There was a problem hiding this comment.
Fixed (in both places).
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>
64f338e to
6e0af33
Compare
all-zeros in bitand yields zero, all-ones in bitor yield all-ones.