Simplify (T1)(T2)x over integer bitvector types where T1 and x have the same type#8943
Simplify (T1)(T2)x over integer bitvector types where T1 and x have the same type#8943tautschnig wants to merge 1 commit intodiffblue:developfrom
Conversation
84804b6 to
bf450b6
Compare
There was a problem hiding this comment.
Pull request overview
Adds a new bitvector-specific simplification rule to eliminate redundant “double typecasts” when the outer cast type matches the original operand type (and both cast types have the same bit-width), along with a unit test to exercise the new behavior.
Changes:
- Simplify
(T1)(T2)xtoxforsignedbv/unsignedbv/bvtypes whentype(x)==T1andwidth(T1)==width(T2). - Add a unit test covering the common
(unsigned)(signed)x -> xcase with equal widths.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/util/simplify_expr.cpp |
Implements the new double-typecast elimination in simplify_exprt::simplify_typecast. |
unit/util/simplify_expr.cpp |
Adds a regression/unit test validating the new simplification behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #8943 +/- ##
===========================================
- Coverage 80.47% 80.47% -0.01%
===========================================
Files 1704 1704
Lines 188702 188721 +19
Branches 73 73
===========================================
+ Hits 151854 151866 +12
- Misses 36848 36855 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
I would sharpen the comment/description. "Bitvector type" can be read to include things like floating-point or fixed-point numbers, for which this rule doesn't work. The implementation seems ok, given that it specifically checks for binary and two's complement. |
…he same type When T2 has the same width (and also is an integer bitvector type) then the typecasts do not change the result -- we can use `x` directly.
bf450b6 to
7501fca
Compare
Fixed comments, test name, commit message, and PR title. |
When T2 has the same width (and also is a bitvector type) then the typecasts do not change the result -- we can use
xdirectly.