-
Notifications
You must be signed in to change notification settings - Fork 274
Simplify overflow-* expressions #5872
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
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.
Useful for #5841
__CPROVER_assert(!__CPROVER_overflow_shl(1, 2), ""); | ||
__CPROVER_assert(!__CPROVER_overflow_unary_minus(1), ""); | ||
__CPROVER_assert(__CPROVER_overflow_unary_minus(1U), ""); | ||
} |
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 we should also have:
__CPROVER_assert(__CPROVER_overflow_minus(0U, 2U), "");
To check the case below where a 0 value can still have overflow?
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 so, it should probably be in a separate test case as the trick @tautschnig is using for testing that it is simplification that handles these will not work for false things.
while (__CPROVER_overflow_minus(0U, 2U) {}
could do something interesting though...
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.
Trying to cover this in the test spec: ^Generated 7 VCC\(s\), 0 remaining after simplification$
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 say that this is both frail and also obscure.
How about using __builtin_constant_p
?
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.
Fair. I'm now using _Static_assert
instead.
10e8bcf
to
05d35e1
Compare
@@ -0,0 +1,7 @@ | |||
CORE gcc-only |
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.
The #ifdef _MSC_VER
suggests that the test might work with goto-cl?
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.
Ah, thank you, that was a left-over from when I thought about the __builtin_constant_p
approach. Fixed.
We can simplify these over constants and for some trivial cases when mathematical types are used.
05d35e1
to
e6943df
Compare
Codecov Report
@@ Coverage Diff @@
## develop #5872 +/- ##
=========================================
Coverage 72.90% 72.91%
=========================================
Files 1423 1425 +2
Lines 154159 154272 +113
=========================================
+ Hits 112397 112481 +84
- Misses 41762 41791 +29
Continue to review full report at Codecov.
|
We can simplify these over constants and for some trivial cases when
mathematical types are used.