Winch: i8x16.shuffle for x64 with AVX#9959
Merged
Merged
Conversation
Member
|
I can take this review as well. |
Subscribe to Label ActionDetailsThis issue or pull request has been labeled: "winch"Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
Comment on lines
+1263
to
+1290
| if self.flags.has_avx() { | ||
| // Use `vpshufb` with `lanes` to set the lanes in `lhs` and `rhs` | ||
| // separately to either the selected index or 0. | ||
| // Then use `vpor` to combine `lhs` and `rhs` into `dst`. | ||
| // Setting the most significant bit in the mask's lane to 1 will | ||
| // result in corresponding lane in the destination register being | ||
| // set to 0. 0x80 sets the most significant bit to 1. | ||
| let mut mask_lhs: [u8; 16] = [0x80; 16]; | ||
| let mut mask_rhs: [u8; 16] = [0x80; 16]; | ||
| for i in 0..lanes.len() { | ||
| if lanes[i] < 16 { | ||
| mask_lhs[i] = lanes[i]; | ||
| } else { | ||
| mask_rhs[i] = lanes[i] - 16; | ||
| } | ||
| } | ||
| let mask_lhs = self.asm.add_constant(&mask_lhs); | ||
| let mask_rhs = self.asm.add_constant(&mask_rhs); | ||
|
|
||
| self.asm.xmm_vpshufb_rrm(dst, lhs, &mask_lhs); | ||
| let scratch = writable!(regs::scratch_xmm()); | ||
| self.asm.xmm_vpshufb_rrm(scratch, rhs, &mask_rhs); | ||
| self.asm.vpor(dst, dst.to_reg(), scratch.to_reg()); | ||
| } else { | ||
| bail!(CodeGenError::UnimplementedForNoAvx) | ||
| } | ||
| Ok(()) | ||
| } |
Member
There was a problem hiding this comment.
One small suggestion perhaps to improve readability, given that the then branch is somewhat lengthy, could we invert the check so that we return early in case there's no avx support?
if !self.flags().has_avx() {
bail!(...);
}
// ....
Ok(())
saulecabrera
approved these changes
Jan 15, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #8093. Implements
i8x16.shuffleon x64 with AVX extensions.