-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Implement checked Shl/Shr on SIMD types #26198
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @huonw (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
The generated check is somewhat heavy: a checked shift on a Is there a better way to check if a vector contains a nonzero element? Or is it not even worth worrying about? The check is only generated when |
I'm pretty sure there is a better way, but I'm very happy to just merge this as is having opened an issue and adding a |
Figured it out. I didn't know about LLVM's |
TypeKind::Integer => ICmp(bcx, llvm::IntNE, value, C_null(llty), binop_debug_loc), | ||
TypeKind::Vector => { | ||
let width = llty.vector_length() as u64 * llty.element_type().int_width(); | ||
let int_value = BitCast(bcx, value, Type::ix(bcx.ccx(), width)); |
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.
Neat trick; could you add a comment describing what's happening? ("check non-zeroness by treating the SIMD vector as one large integer and comparing that".)
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.
(Added comment in latest commit)
Looks great! Could you squash the commits down to one? |
All set. |
@bors r+ Thanks! |
📌 Commit 837c569 has been approved by |
⌛ Testing commit 837c569 with merge 38d1618... |
💔 Test failed - auto-mac-64-opt |
The Running check-stage1 locally right now. |
@bors r+ |
📌 Commit 875f50a has been approved by |
⌛ Testing commit 875f50a with merge 84be3ef... |
💔 Test failed - auto-win-gnu-64-nopt-t |
@bors: retry On Sat, Jun 20, 2015 at 9:34 AM, David Stygstra notifications@github.com
|
When overflow checking on `<<` and `>>` was added for integers, the `<<` and `>>` operations broke for SIMD types (`u32x4`, `i16x8`, etc.). This PR implements checked shifts on SIMD types. Fixes #24258.
Thanks! |
When overflow checking on
<<
and>>
was added for integers, the<<
and>>
operations broke for SIMD types (u32x4
,i16x8
, etc.). This PR implements checked shifts on SIMD types.Fixes #24258.