Skip to content

Commit 29027b6

Browse files
fix: update the implementation of _kshiftri_mask16 and _kshiftli_mask16
to zero out when the amount of shift exceeds 16.
1 parent 0697a43 commit 29027b6

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

crates/core_arch/src/x86/avx512f.rs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29090,7 +29090,7 @@ pub fn _kortestz_mask16_u8(a: __mmask16, b: __mmask16) -> u8 {
2909029090
#[rustc_legacy_const_generics(1)]
2909129091
#[stable(feature = "stdarch_x86_avx512", since = "1.89")]
2909229092
pub fn _kshiftli_mask16<const COUNT: u32>(a: __mmask16) -> __mmask16 {
29093-
a << COUNT
29093+
a.unbounded_shl(COUNT)
2909429094
}
2909529095

2909629096
/// Shift 16-bit mask a right by count bits while shifting in zeros, and store the result in dst.
@@ -29101,7 +29101,7 @@ pub fn _kshiftli_mask16<const COUNT: u32>(a: __mmask16) -> __mmask16 {
2910129101
#[rustc_legacy_const_generics(1)]
2910229102
#[stable(feature = "stdarch_x86_avx512", since = "1.89")]
2910329103
pub fn _kshiftri_mask16<const COUNT: u32>(a: __mmask16) -> __mmask16 {
29104-
a >> COUNT
29104+
a.unbounded_shr(COUNT)
2910529105
}
2910629106

2910729107
/// Load 16-bit mask from memory
@@ -56001,13 +56001,37 @@ mod tests {
5600156001
let r = _kshiftli_mask16::<3>(a);
5600256002
let e: __mmask16 = 0b1011011000011000;
5600356003
assert_eq!(r, e);
56004+
56005+
let r = _kshiftli_mask16::<15>(a);
56006+
let e: __mmask16 = 0b1000000000000000;
56007+
assert_eq!(r, e);
56008+
56009+
let r = _kshiftli_mask16::<16>(a);
56010+
let e: __mmask16 = 0b0000000000000000;
56011+
assert_eq!(r, e);
56012+
56013+
let r = _kshiftli_mask16::<17>(a);
56014+
let e: __mmask16 = 0b0000000000000000;
56015+
assert_eq!(r, e);
5600456016
}
5600556017

5600656018
#[simd_test(enable = "avx512dq")]
5600756019
unsafe fn test_kshiftri_mask16() {
56008-
let a: __mmask16 = 0b0110100100111100;
56020+
let a: __mmask16 = 0b1010100100111100;
5600956021
let r = _kshiftri_mask16::<3>(a);
56010-
let e: __mmask16 = 0b0000110100100111;
56022+
let e: __mmask16 = 0b0001010100100111;
56023+
assert_eq!(r, e);
56024+
56025+
let r = _kshiftri_mask16::<15>(a);
56026+
let e: __mmask16 = 0b0000000000000001;
56027+
assert_eq!(r, e);
56028+
56029+
let r = _kshiftri_mask16::<16>(a);
56030+
let e: __mmask16 = 0b0000000000000000;
56031+
assert_eq!(r, e);
56032+
56033+
let r = _kshiftri_mask16::<17>(a);
56034+
let e: __mmask16 = 0b0000000000000000;
5601156035
assert_eq!(r, e);
5601256036
}
5601356037

0 commit comments

Comments
 (0)