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.
a7523db to
326cd10
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #9073 +/- ##
========================================
Coverage 80.68% 80.69%
========================================
Files 1714 1714
Lines 189593 189638 +45
Branches 73 73
========================================
+ Hits 152979 153024 +45
Misses 36614 36614 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
When converting an array store/select, the index was unconditionally typecast to the array's index type, which is wrong once that index type is a mathematical integer or a struct (e.g. a map key): the cast is unnecessary (the sorts already match) and, for struct keys, ill-formed. Coerce the index to the array's declared index type only when that type is a fixed-width bitvector and differs from the index expression's type; otherwise emit the index unchanged. The decision is keyed on the *destination* (array) index type so that an integer- or differently-sized-bitvector-sourced index is still coerced when the array's index type is a bitvector -- in particular when array_typet::index_type() falls back to c_index_type() for an array without an ID_C_index_type annotation, which would otherwise feed an integer-sorted index into a bitvector-sorted store/select (ill-sorted SMT). A DATA_INVARIANT makes the remaining assumption explicit: a bitvector index requires the array's index type to be a bitvector too. The selection logic (previously duplicated verbatim in convert_with and convert_index) is factored into a single cast_array_index() helper. Enum and enum-tag index types are treated as bitvector-like; convert_typecast resolves an enum-tag destination via ns.follow_tag, so the emission stays valid. A unit test (unit/solvers/smt2/smt2_conv.cpp) pins the serialization for all three cases -- mathematical-integer index, matching-width bitvector index, and differing-width bitvector index -- for both select and store. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
326cd10 to
00d968c
Compare
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.