-
Notifications
You must be signed in to change notification settings - Fork 129
Introduce simd_shuffle intrinsic #417
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
Introduce simd_shuffle intrinsic #417
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.
Could this be integrated into the match below instead of its own code block?
i if i.strip_prefix("simd_shuffle") => ...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.
Apparently this is an "if let guard" and is marked as experimental currently: https://github.com/rust-lang/rfcs/blob/master/text/2294-if-let-guard.md
I'm going to leave it as-is for now.
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 not have it at the end of the match with an starts_with guard?
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.
We need to extract the suffix still. This is what's done in the LLVM code as well.
I don't think including it in the match would be any better.
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, you can match the prefix, then extract the suffix before calling the codegen function.
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.
LGTM, with one testing suggestion
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 move simd_shuffle testing into its own file.
compiler/rustc_codegen_llvm/src/gotoc/cbmc/goto_program/expr.rs
Outdated
Show resolved
Hide resolved
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 do you need this?
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 think I don't anymore, will fix...
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 not have it at the end of the match with an starts_with guard?
|
I think this has addressed everything except the nits about the match vs preceding if. I think there isn't any obviously better choice (except "if let guards", which isn't stable yet), and this style is what appears in some of the llvm codegen crate. IMO, let's just go with it. |
| } | ||
|
|
||
| pub fn vector_expr(typ: Type, elems: Vec<Expr>) -> Self { | ||
| if let Type::Vector { size, typ: value_typ } = typ.clone() { |
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 clone needed here
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 use of value_typ later is a partial move out of the value.
|
|
||
| // An unsigned type here causes an invariant violation in CBMC. | ||
| // Issue: https://github.com/diffblue/cbmc/issues/6298 | ||
| let st_rep = Type::ssize_t(); |
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.
It might be clearer to just use Type::ssize_t() wherever this is used.
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 had that thought too, but I felt like keeping it since it created a place for the comment about the CBMC issue.
* introduce simd_shuffle intrinsic * add links to cbmc issues in simd_shuffle comments * add assert for arguments length to simd instrinsic functions * typo fix Co-authored-by: Adrian Palacios <[email protected]> * separate simd_shuffle test from other tests Co-authored-by: Adrian Palacios <[email protected]> Co-authored-by: Daniel Schwartz-Narbonne <[email protected]>
* introduce simd_shuffle intrinsic * add links to cbmc issues in simd_shuffle comments * add assert for arguments length to simd instrinsic functions * typo fix Co-authored-by: Adrian Palacios <[email protected]> * separate simd_shuffle test from other tests Co-authored-by: Adrian Palacios <[email protected]> Co-authored-by: Daniel Schwartz-Narbonne <[email protected]>
* introduce simd_shuffle intrinsic * add links to cbmc issues in simd_shuffle comments * add assert for arguments length to simd instrinsic functions * typo fix Co-authored-by: Adrian Palacios <[email protected]> * separate simd_shuffle test from other tests Co-authored-by: Adrian Palacios <[email protected]> Co-authored-by: Daniel Schwartz-Narbonne <[email protected]>
* introduce simd_shuffle intrinsic * add links to cbmc issues in simd_shuffle comments * add assert for arguments length to simd instrinsic functions * typo fix Co-authored-by: Adrian Palacios <[email protected]> * separate simd_shuffle test from other tests Co-authored-by: Adrian Palacios <[email protected]> Co-authored-by: Daniel Schwartz-Narbonne <[email protected]>
Description of changes:
vector_exprtto our gotoc representation.simd_shuffleinstrinsics.Resolved issues:
Resolves #309
Call-outs:
shuffle_vector_exprtfor us?) and possibly link to them from the code.I'm going to investigate this before merging. It's possible I should be picking the type in some other way, but this is difficult to diagnose because it seems to be internal to CBMC's transformations (e.g. I think we put "array index" in the symbol table, but them CBMC is transforming that into "pointer + index*size" internally, and that's where the "mult" is coming from. A guess, for now. Perplexing because it would seem to imply that the "sizeof" a type has signed type internally?)
Testing:
How is this change tested? Added tests.
Is this a refactor change? No
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.