Skip to content

Commit 308ddc5

Browse files
AdamNiedereralexcrichton
authored andcommitted
Fix mm256_round_epi* return types (#173)
From the Intel intrinsics manual (emphasis mine): > Compute the absolute value of packed 16-bit integers in a, and store the > *unsigned* results in dst.
1 parent 071f8f9 commit 308ddc5

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/x86/avx2.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,23 @@ use stdsimd_test::assert_instr;
3333
#[inline(always)]
3434
#[target_feature = "+avx2"]
3535
#[cfg_attr(test, assert_instr(vpabsd))]
36-
pub unsafe fn _mm256_abs_epi32(a: i32x8) -> i32x8 {
36+
pub unsafe fn _mm256_abs_epi32(a: i32x8) -> u32x8 {
3737
pabsd(a)
3838
}
3939

4040
/// Computes the absolute values of packed 16-bit integers in `a`.
4141
#[inline(always)]
4242
#[target_feature = "+avx2"]
4343
#[cfg_attr(test, assert_instr(vpabsw))]
44-
pub unsafe fn _mm256_abs_epi16(a: i16x16) -> i16x16 {
44+
pub unsafe fn _mm256_abs_epi16(a: i16x16) -> u16x16 {
4545
pabsw(a)
4646
}
4747

4848
/// Computes the absolute values of packed 8-bit integers in `a`.
4949
#[inline(always)]
5050
#[target_feature = "+avx2"]
5151
#[cfg_attr(test, assert_instr(vpabsb))]
52-
pub unsafe fn _mm256_abs_epi8(a: i8x32) -> i8x32 {
52+
pub unsafe fn _mm256_abs_epi8(a: i8x32) -> u8x32 {
5353
pabsb(a)
5454
}
5555

@@ -2000,11 +2000,11 @@ pub unsafe fn _mm256_xor_si256(a: __m256i, b: __m256i) -> __m256i {
20002000
#[allow(improper_ctypes)]
20012001
extern "C" {
20022002
#[link_name = "llvm.x86.avx2.pabs.b"]
2003-
fn pabsb(a: i8x32) -> i8x32;
2003+
fn pabsb(a: i8x32) -> u8x32;
20042004
#[link_name = "llvm.x86.avx2.pabs.w"]
2005-
fn pabsw(a: i16x16) -> i16x16;
2005+
fn pabsw(a: i16x16) -> u16x16;
20062006
#[link_name = "llvm.x86.avx2.pabs.d"]
2007-
fn pabsd(a: i32x8) -> i32x8;
2007+
fn pabsd(a: i32x8) -> u32x8;
20082008
#[link_name = "llvm.x86.avx2.padds.b"]
20092009
fn paddsb(a: i8x32, b: i8x32) -> i8x32;
20102010
#[link_name = "llvm.x86.avx2.padds.w"]
@@ -2186,13 +2186,13 @@ mod tests {
21862186
#[cfg_attr(rustfmt, rustfmt_skip)]
21872187
let a = i32x8::new(
21882188
0, 1, -1, std::i32::MAX,
2189-
std::i32::MIN + 1, 100, -100, -32,
2189+
std::i32::MIN, 100, -100, -32,
21902190
);
21912191
let r = avx2::_mm256_abs_epi32(a);
21922192
#[cfg_attr(rustfmt, rustfmt_skip)]
2193-
let e = i32x8::new(
2194-
0, 1, 1, std::i32::MAX,
2195-
(std::i32::MIN + 1).abs(), 100, 100, 32,
2193+
let e = u32x8::new(
2194+
0, 1, 1, std::i32::MAX as u32,
2195+
std::i32::MAX as u32 + 1, 100, 100, 32,
21962196
);
21972197
assert_eq!(r, e);
21982198
}
@@ -2202,13 +2202,13 @@ mod tests {
22022202
#[cfg_attr(rustfmt, rustfmt_skip)]
22032203
let a = i16x16::new(
22042204
0, 1, -1, 2, -2, 3, -3, 4,
2205-
-4, 5, -5, std::i16::MAX, std::i16::MIN + 1, 100, -100, -32,
2205+
-4, 5, -5, std::i16::MAX, std::i16::MIN, 100, -100, -32,
22062206
);
22072207
let r = avx2::_mm256_abs_epi16(a);
22082208
#[cfg_attr(rustfmt, rustfmt_skip)]
2209-
let e = i16x16::new(
2209+
let e = u16x16::new(
22102210
0, 1, 1, 2, 2, 3, 3, 4,
2211-
4, 5, 5, std::i16::MAX, (std::i16::MIN + 1).abs(), 100, 100, 32,
2211+
4, 5, 5, std::i16::MAX as u16, std::i16::MAX as u16 + 1, 100, 100, 32,
22122212
);
22132213
assert_eq!(r, e);
22142214
}
@@ -2218,17 +2218,17 @@ mod tests {
22182218
#[cfg_attr(rustfmt, rustfmt_skip)]
22192219
let a = i8x32::new(
22202220
0, 1, -1, 2, -2, 3, -3, 4,
2221-
-4, 5, -5, std::i8::MAX, std::i8::MIN + 1, 100, -100, -32,
2221+
-4, 5, -5, std::i8::MAX, std::i8::MIN, 100, -100, -32,
22222222
0, 1, -1, 2, -2, 3, -3, 4,
2223-
-4, 5, -5, std::i8::MAX, std::i8::MIN + 1, 100, -100, -32,
2223+
-4, 5, -5, std::i8::MAX, std::i8::MIN, 100, -100, -32,
22242224
);
22252225
let r = avx2::_mm256_abs_epi8(a);
22262226
#[cfg_attr(rustfmt, rustfmt_skip)]
2227-
let e = i8x32::new(
2227+
let e = u8x32::new(
22282228
0, 1, 1, 2, 2, 3, 3, 4,
2229-
4, 5, 5, std::i8::MAX, (std::i8::MIN + 1).abs(), 100, 100, 32,
2229+
4, 5, 5, std::i8::MAX as u8, std::i8::MAX as u8 + 1, 100, 100, 32,
22302230
0, 1, 1, 2, 2, 3, 3, 4,
2231-
4, 5, 5, std::i8::MAX, (std::i8::MIN + 1).abs(), 100, 100, 32,
2231+
4, 5, 5, std::i8::MAX as u8, std::i8::MAX as u8 + 1, 100, 100, 32,
22322232
);
22332233
assert_eq!(r, e);
22342234
}

0 commit comments

Comments
 (0)