SMT2: only typecast array index for fixed-width bitvector index types#9073
Open
tautschnig wants to merge 1 commit into
Open
SMT2: only typecast array index for fixed-width bitvector index types#9073tautschnig wants to merge 1 commit into
tautschnig wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adjust SMT2 array store/select index handling to avoid unnecessary typecasts, only casting when both index types are fixed-width bitvectors.
Changes:
- Conditionally typecast array
storeindices only when both sides are fixed-width bitvector-like types. - Conditionally typecast array
select(index) expressions using the same rule, emitting integer/struct indices directly.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+4786
to
+4796
| const typet idx_type = array_type.index_type(); | ||
| const auto is_bv = [](const typet &t) { | ||
| return t.id() == ID_unsignedbv || t.id() == ID_signedbv || | ||
| t.id() == ID_c_bool || t.id() == ID_c_enum || | ||
| t.id() == ID_c_enum_tag; | ||
| }; | ||
| const exprt index = | ||
| (idx_type != expr.index().type() && is_bv(idx_type) && | ||
| is_bv(expr.index().type())) | ||
| ? static_cast<exprt>(typecast_exprt(expr.index(), idx_type)) | ||
| : expr.index(); |
Comment on lines
+4555
to
+4565
| const typet idx_type = array_type.index_type(); | ||
| const auto is_bv = [](const typet &t) { | ||
| return t.id() == ID_unsignedbv || t.id() == ID_signedbv || | ||
| t.id() == ID_c_bool || t.id() == ID_c_enum || | ||
| t.id() == ID_c_enum_tag; | ||
| }; | ||
| const exprt where = | ||
| (idx_type != expr.where().type() && is_bv(idx_type) && | ||
| is_bv(expr.where().type())) | ||
| ? static_cast<exprt>(typecast_exprt(expr.where(), idx_type)) | ||
| : expr.where(); |
Comment on lines
+4783
to
+4786
| // Typecast the index to the array's index type, but only when both | ||
| // types are fixed-width bitvectors. For mathematical integers or | ||
| // struct-typed indices (e.g., map keys), emit directly. | ||
| const typet idx_type = array_type.index_type(); |
Comment on lines
+4792
to
+4796
| const exprt index = | ||
| (idx_type != expr.index().type() && is_bv(idx_type) && | ||
| is_bv(expr.index().type())) | ||
| ? static_cast<exprt>(typecast_exprt(expr.index(), idx_type)) | ||
| : expr.index(); |
When converting array store/select, typecast the index to the array's index type only when both are fixed-width bitvectors; for mathematical-integer or struct-typed (map key) indices, emit the index directly. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
a7523db to
326cd10
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #9073 +/- ##
===========================================
- Coverage 80.68% 80.68% -0.01%
===========================================
Files 1714 1714
Lines 189501 189521 +20
Branches 73 73
===========================================
+ Hits 152902 152917 +15
- Misses 36599 36604 +5 ☔ 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.
When converting array store/select, typecast the index to the array's index type only when both are fixed-width bitvectors; for mathematical-integer or struct-typed (map key) indices, emit the index directly.