-
Notifications
You must be signed in to change notification settings - Fork 274
Add saturating addition/subtraction #6647
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
Add saturating addition/subtraction #6647
Conversation
95f7c8d
to
22ae750
Compare
Codecov Report
@@ Coverage Diff @@
## develop #6647 +/- ##
=========================================
Coverage 76.73% 76.74%
=========================================
Files 1579 1579
Lines 182008 182173 +165
=========================================
+ Hits 139671 139803 +132
- Misses 42337 42370 +33
Continue to review full report at Codecov.
|
22ae750
to
98f43f7
Compare
98f43f7
to
c6c6938
Compare
ed29bfa
to
518af1c
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.
Assuming I've followed all the bit operations correctly, I think that looks reasonable to me. As an aside, the phrase "For C code, it takes MMX instructions to have access to this" of course only applies to x86/amd64. ARM of course has it's own instructions and compiler intrinsics for saturated arithmetic.
@@ -229,6 +229,8 @@ bvt boolbvt::convert_bitvector(const exprt &expr) | |||
} | |||
else if(expr.id() == ID_bitreverse) | |||
return convert_bitreverse(to_bitreverse_expr(expr)); | |||
else if(expr.id() == ID_saturating_minus || expr.id() == ID_saturating_plus) | |||
return convert_saturating_add_sub(to_binary_expr(expr)); |
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.
Minor nit pick... there's a mis-match of terminology here - plus vs add, minus vs sub - should we pick one and settle?
50a4004
to
22defef
Compare
Rust natively supports saturating arithmetic. For C code, it takes MMX instructions to have access to this (which will be implemented in the next commit), and even then it is limited to addition and subtraction. The implementation now is equally restricted to these two arithmetic operations. Fixes: diffblue#5841
With the newly added saturating addition/subtraction it is possible to support MMX instructions performing saturating arithmetic over vectors.
22defef
to
10ea245
Compare
Rust natively supports saturating arithmetic. For C code, it takes MMX
instructions to have access to this, and even then it is limited to
addition and subtraction. The implementation now is equally restricted
to these two arithmetic operations.