-
Notifications
You must be signed in to change notification settings - Fork 352
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 LLVM x86 AVX2 intrinsics #3492
Conversation
964ade8
to
80316e1
Compare
My hope was that we'd implement them in libstd as fallback bodies instead (#3397), but I guess now that we have a shim impl and tests, doing that would be simpler as we have some help against messing up the fallback bodies |
… on `rustc_target::abi::Size`
80316e1
to
af9fc5d
Compare
@bors r+ |
☀️ Test successful - checks-actions |
let dest = this.project_index(&dest, i)?; | ||
|
||
// Converting to a host "i128" works since the input is always signed. | ||
let res = op.to_int(dest.layout.size)?.unsigned_abs(); |
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.
This may be worth an assertion.
Alternatively, a moire clear implementation might avoid using host integers entirely and just use binop_with_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.
I'm not sure what to check with an assertion. How would you implement this with binop_with_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.
The assertion would check that the element type is signed.
How would you implement this with binop_with_overflow?
Sorry, I meant wrapping_binary_op
.
Basically run the equivalent of if op < 0 { -op } else { op }
. It's one BinOp::lt
and one... okay you need wrapping_unary_op
as well, UnOp::Neg
. You can use ImmTy::from_int
to create a 0 of the right type.
Ok(()) | ||
} | ||
|
||
fn pack_generic<'tcx>( |
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.
A doc comment would be good.
let (mask, mask_len) = this.operand_to_simd(mask)?; | ||
let (dest, dest_len) = this.mplace_to_simd(dest)?; | ||
|
||
// There are cases like dest: i32x4, offsets: i64x2 |
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.
What happens if the offsets are longer than the dest?
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.
Extra elements are ignored.
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.
And that's how the intrinsic is intended to work? Wow.
Would be good to have a comment explaining that.
No description provided.