Skip to content

Commit ab543f1

Browse files
gwennalexcrichton
authored andcommitted
Fix some assert_instr (rust-lang#254)
* Fix some assert_instr Missing assert_instr: - _mm_cvtsi32_si128 - _mm_cvtsi128_si32 - _mm_loadl_epi64 - _mm_storel_epi64 - _mm_move_epi64 - _mm_cvtsd_f64 - _mm_setzero_pd - _mm_load1_pd - _mm_load_pd1 - _mm_loaddup_pd Wrong intrusction used: - _mm_hsub_pi16 * Try to fix CI build by disabling some asserts * Exclude some assert_instr on (x86_64, linux)
1 parent ea2cb3e commit ab543f1

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

coresimd/src/x86/i586/sse2.rs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -697,15 +697,15 @@ pub unsafe fn _mm_cvtps_epi32(a: f32x4) -> i32x4 {
697697
/// `0`.
698698
#[inline(always)]
699699
#[target_feature = "+sse2"]
700-
// no particular instruction to test
700+
#[cfg_attr(all(test, target_arch = "x86_64"), assert_instr(movd))]
701701
pub unsafe fn _mm_cvtsi32_si128(a: i32) -> i32x4 {
702702
i32x4::new(a, 0, 0, 0)
703703
}
704704

705705
/// Return the lowest element of `a`.
706706
#[inline(always)]
707707
#[target_feature = "+sse2"]
708-
// no particular instruction to test
708+
#[cfg_attr(all(test, not(windows)), assert_instr(movd))] // FIXME mov on windows
709709
pub unsafe fn _mm_cvtsi128_si32(a: i32x4) -> i32 {
710710
a.extract(0)
711711
}
@@ -826,7 +826,11 @@ pub unsafe fn _mm_setzero_si128() -> __m128i {
826826
/// Load 64-bit integer from memory into first element of returned vector.
827827
#[inline(always)]
828828
#[target_feature = "+sse2"]
829-
// no particular instruction to test
829+
// FIXME movsd on windows
830+
#[cfg_attr(all(test, not(windows),
831+
not(all(target_os = "linux", target_arch = "x86_64")),
832+
target_arch = "x86_64"),
833+
assert_instr(movq))]
830834
pub unsafe fn _mm_loadl_epi64(mem_addr: *const i64x2) -> i64x2 {
831835
i64x2::new((*mem_addr).extract(0), 0)
832836
}
@@ -901,7 +905,11 @@ pub unsafe fn _mm_storeu_si128(mem_addr: *mut __m128i, a: __m128i) {
901905
/// `mem_addr` does not need to be aligned on any particular boundary.
902906
#[inline(always)]
903907
#[target_feature = "+sse2"]
904-
// no particular instruction to test
908+
// FIXME mov on windows, movlps on i686
909+
#[cfg_attr(all(test, not(windows),
910+
not(all(target_os = "linux", target_arch = "x86_64")),
911+
target_arch = "x86_64"),
912+
assert_instr(movq))]
905913
pub unsafe fn _mm_storel_epi64(mem_addr: *mut __m128i, a: __m128i) {
906914
ptr::copy_nonoverlapping(
907915
&a as *const _ as *const u8,
@@ -934,7 +942,9 @@ pub unsafe fn _mm_stream_si32(mem_addr: *mut i32, a: i32) {
934942
/// element is zero.
935943
#[inline(always)]
936944
#[target_feature = "+sse2"]
937-
// no particular instruction to test
945+
// FIXME movd on windows, movd on i686
946+
#[cfg_attr(all(test, not(windows), target_arch = "x86_64"),
947+
assert_instr(movq))]
938948
pub unsafe fn _mm_move_epi64(a: i64x2) -> i64x2 {
939949
simd_shuffle2(a, i64x2::splat(0), [0, 2])
940950
}
@@ -1752,7 +1762,7 @@ pub unsafe fn _mm_cvtsd_ss(a: f32x4, b: f64x2) -> f32x4 {
17521762
/// Return the lower double-precision (64-bit) floating-point element of "a".
17531763
#[inline(always)]
17541764
#[target_feature = "+sse2"]
1755-
// no particular instruction to test
1765+
#[cfg_attr(all(test, windows), assert_instr(movsd))] // FIXME movq/movlps/mov on other platform
17561766
pub unsafe fn _mm_cvtsd_f64(a: f64x2) -> f64 {
17571767
a.extract(0)
17581768
}
@@ -1839,6 +1849,7 @@ pub unsafe fn _mm_setr_pd(a: f64, b: f64) -> f64x2 {
18391849
/// zeros.
18401850
#[inline(always)]
18411851
#[target_feature = "+sse2"]
1852+
#[cfg_attr(test, assert_instr(xorps))] // FIXME xorpd expected
18421853
pub unsafe fn _mm_setzero_pd() -> f64x2 {
18431854
f64x2::splat(0_f64)
18441855
}
@@ -1991,6 +2002,7 @@ pub unsafe fn _mm_storel_pd(mem_addr: *mut f64, a: f64x2) {
19912002
/// into both elements of returned vector.
19922003
#[inline(always)]
19932004
#[target_feature = "+sse2"]
2005+
//#[cfg_attr(test, assert_instr(movapd))] FIXME movapd expected
19942006
pub unsafe fn _mm_load1_pd(mem_addr: *const f64) -> f64x2 {
19952007
let d = *mem_addr;
19962008
f64x2::new(d, d)
@@ -2000,6 +2012,7 @@ pub unsafe fn _mm_load1_pd(mem_addr: *const f64) -> f64x2 {
20002012
/// into both elements of returned vector.
20012013
#[inline(always)]
20022014
#[target_feature = "+sse2"]
2015+
//#[cfg_attr(test, assert_instr(movapd))] FIXME movapd expected
20032016
pub unsafe fn _mm_load_pd1(mem_addr: *const f64) -> f64x2 {
20042017
let d = *mem_addr;
20052018
f64x2::new(d, d)

coresimd/src/x86/i586/sse3.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ pub unsafe fn _mm_movedup_pd(a: f64x2) -> f64x2 {
8383
/// into both elements of return vector.
8484
#[inline(always)]
8585
#[target_feature = "+sse3"]
86+
#[cfg_attr(test, assert_instr(movddup))]
8687
pub unsafe fn _mm_loaddup_pd(mem_addr: *const f64) -> f64x2 {
8788
use x86::i586::sse2::_mm_load1_pd;
8889
_mm_load1_pd(mem_addr)

coresimd/src/x86/i686/ssse3.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ pub unsafe fn _mm_hadds_pi16(a: i16x4, b: i16x4) -> i16x4 {
8888
/// packed 64-bit vectors of [4 x i16].
8989
#[inline(always)]
9090
#[target_feature = "+ssse3"]
91-
#[cfg_attr(test, assert_instr(phsubsw))]
91+
#[cfg_attr(test, assert_instr(phsubw))]
9292
pub unsafe fn _mm_hsub_pi16(a: i16x4, b: i16x4) -> i16x4 {
93-
mem::transmute(phsubsw(mem::transmute(a), mem::transmute(b)))
93+
mem::transmute(phsubw(mem::transmute(a), mem::transmute(b)))
9494
}
9595

9696
/// Horizontally subtracts the adjacent pairs of values contained in 2

0 commit comments

Comments
 (0)