-
Notifications
You must be signed in to change notification settings - Fork 273
Bitvectors are now hexadecimal #3107
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
Conversation
536b087
to
a0c531b
Compare
15d8038
to
f2ae4cf
Compare
6b999bc
to
0e37e1f
Compare
Now cleaned up! The B256 option is now in a separate PR. |
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.
This PR failed Diffblue compatibility checks (cbmc commit: 6b999bc).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/88546710
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.
Common spurious failures:
- the cbmc commit has disappeared in the mean time (e.g. in a force-push)
- the author is not in the list of contributors (e.g. first-time contributors).
The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.
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.
Passed Diffblue compatibility checks (cbmc commit: 0e37e1f).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/88550170
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.
Sorry, still an incomplete review, sending the below comments and will do further reviews once those are addressed.
src/util/arith_tools.cpp
Outdated
|
||
char nibble = src[src.size() - 1 - nibble_index]; | ||
|
||
DATA_INVARIANT(isxdigit(nibble), ""); |
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.
Still to be addressed.
src/util/arith_tools.cpp
Outdated
return src[src.size() - 1 - bit_index] == '1'; | ||
|
||
// The representation is hex, most significant nibble first. | ||
const auto nibble_index = bit_index >> 2; |
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.
Maybe leave the optimisation that "divide by 4" is a shift by 2 to the compiler? I don't think doing those optimisations help readability.
const auto nibble_index = bit_index >> 2; | ||
|
||
if(nibble_index >= src.size()) | ||
return false; |
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.
This needs to be changed now that #3196 has been merged to re-instate the PRECONDITION
.
src/util/arith_tools.cpp
Outdated
if(nibble_index >= src.size()) | ||
return false; | ||
|
||
char nibble = src[src.size() - 1 - nibble_index]; |
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.
const
src/util/arith_tools.cpp
Outdated
@@ -299,12 +323,36 @@ bool get_bvrep_bit( | |||
irep_idt | |||
make_bvrep(const std::size_t width, const std::function<bool(std::size_t)> f) | |||
{ | |||
std::string result(width, ' '); | |||
std::string result; | |||
result.reserve(width / 4 + 1); |
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.
- If doing the division-by-power-of-two-is-shift then it should be done everywhere (or, my preference: nowhere)
(width + 3) / 4
will avoid reserving an unnecessary extra space.
src/util/arith_tools.cpp
Outdated
std::string result(width, ' '); | ||
std::string result; | ||
result.reserve(width / 4 + 1); | ||
unsigned nibble = 0; |
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.
char
?
src/util/arith_tools.cpp
Outdated
|
||
return result; | ||
nibble |= ((unsigned)f(i)) << bit_in_nibble; |
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.
What about:
if(f(i))
nibble |= 1u << bit_in_nibble;
Not sure to what extent performance would differ given the additional branch, though.
src/util/arith_tools.cpp
Outdated
|
||
// drop leading zeros | ||
while(!result.empty() && result.back() == '0') | ||
result.resize(result.size() - 1); |
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.
Please use rfind
and a single resize
.
0e37e1f
to
d2263f2
Compare
a91718a
to
b366d8b
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.
Passed Diffblue compatibility checks (cbmc commit: b366d8b).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/88622003
a9826b6
to
103d74c
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.
This PR failed Diffblue compatibility checks (cbmc commit: a9826b6).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/88886344
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.
Common spurious failures:
- the cbmc commit has disappeared in the mean time (e.g. in a force-push)
- the author is not in the list of contributors (e.g. first-time contributors).
The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.
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.
Passed Diffblue compatibility checks (cbmc commit: 103d74c).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/88888437
Simultaneously leading zeros are dropped. This reduces the memory consumption of bit-vectors by 4x or more.
103d74c
to
c7c4110
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.
✔️
Passed Diffblue compatibility checks (cbmc commit: c7c4110).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/90285596
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 think everything I raised has been resolved or removed.
Note that an alternative would be to go to a binary representation, which is not much different compared to this PR. This would save another 2x in memory, but has the disadvantage that ireps are then more difficult to read.
This will require a bump in the goto-binary version number, which I would prefer to do together with a few other changes.