-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
zero extension expression #8442
Conversation
kroening
commented
Sep 5, 2024
- Each commit message has a non-empty body, explaining why the change was made.
- Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
- n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
- Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
- My commit message includes data points confirming performance improvements (if claimed).
- My PR is restricted to a single feature or bugfix.
- n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.
70aec8f
to
fc73983
Compare
716dfc8
to
e77bbe3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be nice to see support in the simplifier for any case that does zero_extend of a constant.
e77bbe3
to
20acf16
Compare
20acf16
to
2b09504
Compare
I believe this is actually a necessary feature for unit tests to pass. |
I think the support for zero_extend should be added to the simplifier before merging. Moving from expressions which are supported by the simplifier to a new one which is not may have a performance cost. |
Now with simplifier support. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #8442 +/- ##
==========================================
Coverage ? 78.88%
==========================================
Files ? 1727
Lines ? 198398
Branches ? 18545
==========================================
Hits ? 156504
Misses ? 41894
Partials ? 0 ☔ View full report in Codecov by Sentry. |
src/util/bitvector_expr.cpp
Outdated
} | ||
else // new_width <= old_width | ||
{ | ||
return extractbits_exprt{op(), integer_typet{}.zero_expr(), type()}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the index argument a sizet?
This introduces the zero_extend expression, which, given a bit-vector operand and a type, either a) pads the given operand with zeros from the left if the given type is wider than the type of the operand, or b) truncates the operand to the width of the given type if the given type is smaller than the operand, or c) reinterprets the operand as having the given type if the width of the type and the width of the operand match. This may differ from conversion if the types have different bit representations. This is easier to read and less prone to error than the current pattern, in which the operand is 1) converted to an unsigned type of the same width, and then 2) casted to an unsigned type of the wider width, and 3) finally casted to the target type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.