Skip to content

Commit dc0a2b5

Browse files
Daniel SmithAmanieu
authored andcommitted
Add signed variants
1 parent df2e755 commit dc0a2b5

File tree

3 files changed

+119
-0
lines changed

3 files changed

+119
-0
lines changed

crates/core_arch/src/x86/avx512f.rs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,69 @@ pub unsafe fn _mm512_mask_cmpeq_epu64_mask(m: __mmask8, a: __m512i, b: __m512i)
157157
_mm512_cmpeq_epu64_mask(a, b) & m
158158
}
159159

160+
/// Compare packed unsigned 64-bit integers in a and b for less-than, and store the results in a mask vector.
161+
///
162+
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#expand=727,1063,4909,1062,1062&text=_mm512_cmplt_epi64)
163+
#[inline]
164+
#[target_feature(enable = "avx512f")]
165+
#[cfg_attr(test, assert_instr(vpcmp))]
166+
pub unsafe fn _mm512_cmplt_epi64_mask(a: __m512i, b: __m512i) -> __mmask8 {
167+
simd_bitmask::<__m512i, _>(simd_lt(a.as_i64x8(), b.as_i64x8()))
168+
}
169+
170+
///Compare packed unsigned 64-bit integers in a and b for less-than, and store the results in a mask vector k
171+
/// using zeromask m (elements are zeroed out when the corresponding mask bit is not set).
172+
///
173+
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#expand=727,1063,4909,1062,1062,1063&text=_mm512_mask_cmplt_epi64)
174+
#[inline]
175+
#[target_feature(enable = "avx512f")]
176+
#[cfg_attr(test, assert_instr(vpcmp))]
177+
pub unsafe fn _mm512_mask_cmplt_epi64_mask(m: __mmask8, a: __m512i, b: __m512i) -> __mmask8 {
178+
_mm512_cmplt_epi64_mask(a, b) & m
179+
}
180+
181+
/// Compare packed unsigned 64-bit integers in a and b for less-than, and store the results in a mask vector.
182+
///
183+
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#expand=727,1063,4909,1062,1062&text=_mm512_cmpgt_epi64)
184+
#[inline]
185+
#[target_feature(enable = "avx512f")]
186+
#[cfg_attr(test, assert_instr(vpcmp))]
187+
pub unsafe fn _mm512_cmpgt_epi64_mask(a: __m512i, b: __m512i) -> __mmask8 {
188+
simd_bitmask::<__m512i, _>(simd_gt(a.as_i64x8(), b.as_i64x8()))
189+
}
190+
191+
///Compare packed unsigned 64-bit integers in a and b for less-than, and store the results in a mask vector k
192+
/// using zeromask m (elements are zeroed out when the corresponding mask bit is not set).
193+
///
194+
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#expand=727,1063,4909,1062,1062,1063&text=_mm512_mask_cmpgt_epi64)
195+
#[inline]
196+
#[target_feature(enable = "avx512f")]
197+
#[cfg_attr(test, assert_instr(vpcmp))]
198+
pub unsafe fn _mm512_mask_cmpgt_epi64_mask(m: __mmask8, a: __m512i, b: __m512i) -> __mmask8 {
199+
_mm512_cmpgt_epi64_mask(a, b) & m
200+
}
201+
202+
/// Compare packed unsigned 64-bit integers in a and b for less-than, and store the results in a mask vector.
203+
///
204+
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#expand=727,1063,4909,1062,1062&text=_mm512_cmpeq_epi64)
205+
#[inline]
206+
#[target_feature(enable = "avx512f")]
207+
#[cfg_attr(test, assert_instr(vpcmp))]
208+
pub unsafe fn _mm512_cmpeq_epi64_mask(a: __m512i, b: __m512i) -> __mmask8 {
209+
simd_bitmask::<__m512i, _>(simd_eq(a.as_i64x8(), b.as_i64x8()))
210+
}
211+
212+
///Compare packed unsigned 64-bit integers in a and b for less-than, and store the results in a mask vector k
213+
/// using zeromask m (elements are zeroed out when the corresponding mask bit is not set).
214+
///
215+
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#expand=727,1063,4909,1062,1062,1063&text=_mm512_mask_cmpeq_epi64)
216+
#[inline]
217+
#[target_feature(enable = "avx512f")]
218+
#[cfg_attr(test, assert_instr(vpcmp))]
219+
pub unsafe fn _mm512_mask_cmpeq_epi64_mask(m: __mmask8, a: __m512i, b: __m512i) -> __mmask8 {
220+
_mm512_cmpeq_epi64_mask(a, b) & m
221+
}
222+
160223
#[cfg(test)]
161224
mod tests {
162225
use std;

crates/core_arch/src/x86/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,11 @@ pub(crate) trait m512iExt: Sized {
518518
fn as_u64x8(self) -> crate::core_arch::simd::u64x8 {
519519
unsafe { transmute(self.as_m512i()) }
520520
}
521+
522+
#[inline]
523+
fn as_i64x8(self) -> crate::core_arch::simd::i64x8 {
524+
unsafe { transmute(self.as_m512i()) }
525+
}
521526
}
522527

523528
impl m512iExt for __m512i {

crates/core_arch/src/x86_64/avx512f.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,57 @@ mod tests {
100100
assert_eq!(r, 0b01001010);
101101
}
102102

103+
#[simd_test(enable = "avx512f")]
104+
unsafe fn test_mm512_cmplt_epi64_mask() {
105+
let a = _mm512_set_epi64(0, 1, -1, 13, i64::MAX, i64::MIN, 100, -100);
106+
let b = _mm512_set1_epi64(-1);
107+
let m = _mm512_cmplt_epi64_mask(a, b);
108+
assert_eq!(m, 0b00000101);
109+
}
110+
111+
#[simd_test(enable = "avx512f")]
112+
unsafe fn test_mm512_mask_cmplt_epi64_mask() {
113+
let a = _mm512_set_epi64(0, 1, -1, 13, i64::MAX, i64::MIN, 100, -100);
114+
let b = _mm512_set1_epi64(-1);
115+
let mask = 0b01100110;
116+
let r = _mm512_mask_cmplt_epi64_mask(mask, a, b);
117+
assert_eq!(r, 0b00000100);
118+
}
119+
120+
#[simd_test(enable = "avx512f")]
121+
unsafe fn test_mm512_cmpgt_epi64_mask() {
122+
let a = _mm512_set_epi64(0, 1, -1, 13, i64::MAX, i64::MIN, 100, -100);
123+
let b = _mm512_set1_epi64(-1);
124+
let m = _mm512_cmpgt_epi64_mask(b, a);
125+
assert_eq!(m, 0b00000101);
126+
}
127+
128+
#[simd_test(enable = "avx512f")]
129+
unsafe fn test_mm512_mask_cmpgt_epi64_mask() {
130+
let a = _mm512_set_epi64(0, 1, -1, 13, i64::MAX, i64::MIN, 100, -100);
131+
let b = _mm512_set1_epi64(-1);
132+
let mask = 0b01100110;
133+
let r = _mm512_mask_cmpgt_epi64_mask(mask, b, a);
134+
assert_eq!(r, 0b00000100);
135+
}
136+
137+
#[simd_test(enable = "avx512f")]
138+
unsafe fn test_mm512_cmpeq_epi64_mask() {
139+
let a = _mm512_set_epi64(0, 1, -1, 13, i64::MAX, i64::MIN, 100, -100);
140+
let b = _mm512_set_epi64(0, 1, 13, 42, i64::MAX, i64::MIN, 100, -100);
141+
let m = _mm512_cmpeq_epi64_mask(b, a);
142+
assert_eq!(m, 0b11001111);
143+
}
144+
145+
#[simd_test(enable = "avx512f")]
146+
unsafe fn test_mm512_mask_cmpeq_epi64_mask() {
147+
let a = _mm512_set_epi64(0, 1, -1, 13, i64::MAX, i64::MIN, 100, -100);
148+
let b = _mm512_set_epi64(0, 1, 13, 42, i64::MAX, i64::MIN, 100, -100);
149+
let mask = 0b01111010;
150+
let r = _mm512_mask_cmpeq_epi64_mask(mask, b, a);
151+
assert_eq!(r, 0b01001010);
152+
}
153+
103154
#[simd_test(enable = "avx512f")]
104155
unsafe fn test_mm512_set_epi64() {
105156
let r = _mm512_setr_epi64(0, 1, 2, 3, 4, 5, 6, 7);

0 commit comments

Comments
 (0)