Skip to content
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

Re-land mm_extract_epi fix #898

Merged
merged 1 commit into from
Sep 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions crates/core_arch/src/x86/avx2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3743,9 +3743,14 @@ pub unsafe fn _mm256_xor_si256(a: __m256i, b: __m256i) -> __m256i {
// This intrinsic has no corresponding instruction.
#[rustc_args_required_const(1)]
#[stable(feature = "simd_x86", since = "1.27.0")]
pub unsafe fn _mm256_extract_epi8(a: __m256i, imm8: i32) -> i8 {
let imm8 = (imm8 & 31) as u32;
simd_extract(a.as_i8x32(), imm8 as u32)
pub unsafe fn _mm256_extract_epi8(a: __m256i, imm8: i32) -> i32 {
let a = a.as_u8x32();
macro_rules! call {
($imm5:expr) => {
simd_extract::<_, u8>(a, $imm5) as i32
};
}
constify_imm5!(imm8, call)
}

/// Extracts a 16-bit integer from `a`, selected with `imm8`. Returns a 32-bit
Expand All @@ -3759,9 +3764,14 @@ pub unsafe fn _mm256_extract_epi8(a: __m256i, imm8: i32) -> i8 {
// This intrinsic has no corresponding instruction.
#[rustc_args_required_const(1)]
#[stable(feature = "simd_x86", since = "1.27.0")]
pub unsafe fn _mm256_extract_epi16(a: __m256i, imm8: i32) -> i16 {
let imm8 = (imm8 & 15) as u32;
simd_extract(a.as_i16x16(), imm8)
pub unsafe fn _mm256_extract_epi16(a: __m256i, imm8: i32) -> i32 {
let a = a.as_u16x16();
macro_rules! call {
($imm4:expr) => {
simd_extract::<_, u16>(a, $imm4) as i32
};
}
constify_imm4!((imm8 & 15), call)
}

/// Extracts a 32-bit integer from `a`, selected with `imm8`.
Expand Down Expand Up @@ -6120,7 +6130,7 @@ mod tests {
);
let r1 = _mm256_extract_epi8(a, 0);
let r2 = _mm256_extract_epi8(a, 35);
assert_eq!(r1, -1);
assert_eq!(r1, 0xFF);
assert_eq!(r2, 3);
}

Expand All @@ -6133,7 +6143,7 @@ mod tests {
);
let r1 = _mm256_extract_epi16(a, 0);
let r2 = _mm256_extract_epi16(a, 19);
assert_eq!(r1, -1);
assert_eq!(r1, 0xFFFF);
assert_eq!(r2, 3);
}

Expand Down
2 changes: 0 additions & 2 deletions crates/stdarch-verify/tests/x86-intel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,6 @@ fn verify_all_signatures() {
// take a signed-integer. This breaks `_MM_SHUFFLE` for
// `_mm_shuffle_ps`:
"_mm_shuffle_ps" => continue,
// FIXME(#867)
"_mm256_extract_epi8" | "_mm256_extract_epi16" => continue,
_ => {}
}

Expand Down