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

Fix incorrect reduction operations in avx512f #1603

Merged
merged 1 commit into from
Jul 2, 2024
Merged
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
41 changes: 10 additions & 31 deletions crates/core_arch/src/x86/avx512f.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31571,7 +31571,7 @@ pub unsafe fn _mm512_mask_reduce_max_epi32(k: __mmask16, a: __m512i) -> i32 {
simd_reduce_max(simd_select_bitmask(
k,
a.as_i32x16(),
_mm512_undefined_epi32().as_i32x16(),
i32x16::splat(i32::MIN),
))
}

Expand All @@ -31592,11 +31592,7 @@ pub unsafe fn _mm512_reduce_max_epi64(a: __m512i) -> i64 {
#[target_feature(enable = "avx512f")]
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
pub unsafe fn _mm512_mask_reduce_max_epi64(k: __mmask8, a: __m512i) -> i64 {
simd_reduce_max(simd_select_bitmask(
k,
a.as_i64x8(),
_mm512_set1_epi64(0).as_i64x8(),
))
simd_reduce_max(simd_select_bitmask(k, a.as_i64x8(), i64x8::splat(i64::MIN)))
}

/// Reduce the packed unsigned 32-bit integers in a by maximum. Returns the maximum of all elements in a.
Expand All @@ -31619,7 +31615,7 @@ pub unsafe fn _mm512_mask_reduce_max_epu32(k: __mmask16, a: __m512i) -> u32 {
simd_reduce_max(simd_select_bitmask(
k,
a.as_u32x16(),
_mm512_undefined_epi32().as_u32x16(),
_mm512_setzero_si512().as_u32x16(),
))
}

Expand All @@ -31643,7 +31639,7 @@ pub unsafe fn _mm512_mask_reduce_max_epu64(k: __mmask8, a: __m512i) -> u64 {
simd_reduce_max(simd_select_bitmask(
k,
a.as_u64x8(),
_mm512_set1_epi64(0).as_u64x8(),
_mm512_setzero_si512().as_u64x8(),
))
}

Expand Down Expand Up @@ -31718,7 +31714,7 @@ pub unsafe fn _mm512_mask_reduce_min_epi32(k: __mmask16, a: __m512i) -> i32 {
simd_reduce_min(simd_select_bitmask(
k,
a.as_i32x16(),
_mm512_undefined_epi32().as_i32x16(),
i32x16::splat(i32::MAX),
TDecking marked this conversation as resolved.
Show resolved Hide resolved
))
}

Expand All @@ -31739,11 +31735,7 @@ pub unsafe fn _mm512_reduce_min_epi64(a: __m512i) -> i64 {
#[target_feature(enable = "avx512f")]
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
pub unsafe fn _mm512_mask_reduce_min_epi64(k: __mmask8, a: __m512i) -> i64 {
simd_reduce_min(simd_select_bitmask(
k,
a.as_i64x8(),
_mm512_set1_epi64(0).as_i64x8(),
))
simd_reduce_min(simd_select_bitmask(k, a.as_i64x8(), i64x8::splat(i64::MAX)))
}

/// Reduce the packed unsigned 32-bit integers in a by minimum. Returns the minimum of all elements in a.
Expand All @@ -31766,7 +31758,7 @@ pub unsafe fn _mm512_mask_reduce_min_epu32(k: __mmask16, a: __m512i) -> u32 {
simd_reduce_min(simd_select_bitmask(
k,
a.as_u32x16(),
_mm512_undefined_epi32().as_u32x16(),
u32x16::splat(u32::MAX),
))
}

Expand All @@ -31787,11 +31779,7 @@ pub unsafe fn _mm512_reduce_min_epu64(a: __m512i) -> u64 {
#[target_feature(enable = "avx512f")]
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
pub unsafe fn _mm512_mask_reduce_min_epu64(k: __mmask8, a: __m512i) -> u64 {
simd_reduce_min(simd_select_bitmask(
k,
a.as_u64x8(),
_mm512_set1_epi64(0).as_u64x8(),
))
simd_reduce_min(simd_select_bitmask(k, a.as_u64x8(), u64x8::splat(u64::MAX)))
}

/// Reduce the packed single-precision (32-bit) floating-point elements in a by minimum. Returns the minimum of all elements in a.
Expand Down Expand Up @@ -31862,11 +31850,7 @@ pub unsafe fn _mm512_reduce_and_epi32(a: __m512i) -> i32 {
#[target_feature(enable = "avx512f")]
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
pub unsafe fn _mm512_mask_reduce_and_epi32(k: __mmask16, a: __m512i) -> i32 {
simd_reduce_and(simd_select_bitmask(
k,
a.as_i32x16(),
_mm512_set1_epi32(0xFF).as_i32x16(),
))
simd_reduce_and(simd_select_bitmask(k, a.as_i32x16(), i32x16::splat(-1)))
}

/// Reduce the packed 64-bit integers in a by bitwise AND. Returns the bitwise AND of all elements in a.
Expand All @@ -31886,12 +31870,7 @@ pub unsafe fn _mm512_reduce_and_epi64(a: __m512i) -> i64 {
#[target_feature(enable = "avx512f")]
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
pub unsafe fn _mm512_mask_reduce_and_epi64(k: __mmask8, a: __m512i) -> i64 {
simd_reduce_and(simd_select_bitmask(
k,
a.as_i64x8(),
_mm512_set1_epi64(1 << 0 | 1 << 1 | 1 << 2 | 1 << 3 | 1 << 4 | 1 << 5 | 1 << 6 | 1 << 7)
.as_i64x8(),
))
simd_reduce_and(simd_select_bitmask(k, a.as_i64x8(), i64x8::splat(-1)))
}

/// Reduce the packed 32-bit integers in a by bitwise OR. Returns the bitwise OR of all elements in a.
Expand Down