-
Notifications
You must be signed in to change notification settings - Fork 11
BitfieldSimplifier: arbitrary precision bit masks #11
base: master
Are you sure you want to change the base?
Conversation
lib/Expr/BitfieldSimplifier.cpp
Outdated
|
||
case Expr::And: | ||
rbits.knownOneBits = bits[0].knownOneBits & bits[1].knownOneBits; | ||
rbits.knownZeroBits = bits[0].knownZeroBits | bits[1].knownZeroBits; | ||
|
||
bits[0].ignoredBits = ignoredBits | bits[1].knownZeroBits; | ||
bits[1].ignoredBits = ignoredBits | (bits[0].knownZeroBits & ~bits[1].knownZeroBits); | ||
bits[1].ignoredBits = ignoredBits | bits[0].knownZeroBits; |
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.
Why is the remaining part of the expression missing?
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 a bit on the left side is 0, doesn't it mean that we can ignore the corresponding bit on the right side? And is also commutative so wouldn't it make sense to have the same expression for ignored bits on the left and on the right?
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.
Could be, I'll have a better look later. In the meantime, could you move optimizations/bugfixes in a separate commit? The first commit would just have the mechanical conversion to APInt. This would make it much simpler to review.
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.
In the original zeroMask is only needed because the masks are 64 bits wide even when the expressions are narrower than 64 bits. APInts can be any number of bits wide so that would not be needed anymore. Should I keep 64-bit masks and zeroMask in the mechanical conversion or not?
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.
Yes, please keep 64-bits.
I admit that this BitFieldSimplifier is a bit fuzzy in my mind. There are some expressions that look different from before, it would make sense to add comments to the code to explain the changes. Also a couple of test cases would help. They should be simple to add, following this model: https://github.com/S2E/klee/blob/master/unittests/Expr/ExprTest.cpp |
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 limited to 64-bit masks. Signed-off-by: Matteo Rizzo <matteo.rizzo@epfl.ch>
Use llvm::APInt to support expressions of arbitrary width. Signed-off-by: Matteo Rizzo <matteo.rizzo@epfl.ch>
c9e2ed2
to
d60fbe1
Compare
Use llvm::APInt instead of uint64_t for bit masks.
Needed for the modified (non-forking) helper for signed multiplication
which uses 128-bit integers.
Signed-off-by: Matteo Rizzo matteo.rizzo@epfl.ch