-
Notifications
You must be signed in to change notification settings - Fork 274
Use bitvector types to implement __builtin_{add,sub,mul}_overflow #5544
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
Use bitvector types to implement __builtin_{add,sub,mul}_overflow #5544
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #5544 +/- ##
=========================================
Coverage 75.02% 75.02%
=========================================
Files 1431 1433 +2
Lines 155595 155785 +190
=========================================
+ Hits 116734 116877 +143
- Misses 38861 38908 +47
Continue to review full report at Codecov.
|
4d540eb
to
7451373
Compare
Note that we've got expressions ID_overflow_plus, ID_overflow_minus and ID_overflow_mult -- these make attempts at optimizing the encoding required for these predicates. |
I am well aware of those, and did wonder whether we can just use them instead of making a big fuzz here. My concern was twofold, and I'd appreciate further thoughts on this:
|
7451373
to
4b2f37c
Compare
https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/z3prefix.pdf |
Where would that be supported? |
https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html appears to suggest that the two operands do indeed have the same type. |
I'm not sure I can see this? The signature |
4b2f37c
to
3b4d6e2
Compare
3b4d6e2
to
f8c7908
Compare
f8c7908
to
a22995d
Compare
a22995d
to
03494ea
Compare
The use of mathematical integers is not supported by the SAT back-end. Although GCC's specification describes the operations over mathematical integers, the same precision can be achieved by using bitvector types of sufficient width. The implementation now also introduces a fresh symbol to store the result of the full-precision operation. This ensures that the arguments to __builtin_{add,sub,mul}_overflow are evaluated exactly once.
Refactor and expand the implementation of __builtin_{add,sub,mul}_overflow (i.e., without the _p suffix) to also support the variant that does not store the computed result.
03494ea
to
e789c67
Compare
The use of mathematical integers is not supported by the SAT back-end.
Although GCC's specification describes the operations over mathematical
integers, the same precision can be achieved by using bitvector types of
sufficient width.
The implementation now also introduces a fresh symbol to store the
result of the full-precision operation. This ensures that the arguments
to _builtin{add,sub,mul}_overflow are evaluated exactly once.