Skip to content

Commit 37b4f63

Browse files
authored
Reduce implicit reliance on structure of __m* types (rust-lang#290)
They need to be structured *somehow* to be the right bit width but ideally we wouldn't have the intrinsics rely on the particulars about how they're represented.
1 parent 5d37060 commit 37b4f63

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

coresimd/src/x86/i586/sse2.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,9 @@ pub unsafe fn _mm_stream_si32(mem_addr: *mut i32, a: i32) {
948948
#[cfg_attr(all(test, not(windows), target_arch = "x86_64"),
949949
assert_instr(movq))]
950950
pub unsafe fn _mm_move_epi64(a: __m128i) -> __m128i {
951-
simd_shuffle2(a, _mm_setzero_si128(), [0, 2])
951+
let zero = _mm_setzero_si128();
952+
let r: i64x2 = simd_shuffle2(a.as_i64x2(), zero.as_i64x2(), [0, 2]);
953+
mem::transmute(r)
952954
}
953955

954956
/// Convert packed 16-bit integers from `a` and `b` to packed 8-bit integers
@@ -2088,7 +2090,7 @@ pub unsafe fn _mm_castpd_ps(a: __m128d) -> __m128 {
20882090
#[inline(always)]
20892091
#[target_feature(enable = "sse2")]
20902092
pub unsafe fn _mm_castpd_si128(a: __m128d) -> __m128i {
2091-
simd_cast(a)
2093+
mem::transmute::<i64x2, _>(simd_cast(a))
20922094
}
20932095

20942096
/// Casts a 128-bit floating-point vector of [4 x float] into a 128-bit
@@ -2112,7 +2114,7 @@ pub unsafe fn _mm_castps_si128(a: __m128) -> __m128i {
21122114
#[inline(always)]
21132115
#[target_feature(enable = "sse2")]
21142116
pub unsafe fn _mm_castsi128_pd(a: __m128i) -> __m128d {
2115-
simd_cast(a)
2117+
simd_cast(a.as_i64x2())
21162118
}
21172119

21182120
/// Casts a 128-bit integer vector into a 128-bit floating-point vector

coresimd/src/x86/i686/sse2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub unsafe fn _mm_setr_epi64(e1: __m64, e0: __m64) -> __m128i {
8080
// #[cfg_attr(test, assert_instr(movdq2q))] // FIXME: llvm codegens wrong
8181
// instr?
8282
pub unsafe fn _mm_movepi64_pi64(a: __m128i) -> __m64 {
83-
mem::transmute(simd_extract::<_, i64>(a, 0))
83+
mem::transmute(simd_extract::<_, i64>(a.as_i64x2(), 0))
8484
}
8585

8686
/// Moves the 64-bit operand to a 128-bit integer vector, zeroing the

coresimd/src/x86/i686/sse41.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ use stdsimd_test::assert_instr;
99
#[allow(improper_ctypes)]
1010
extern "C" {
1111
#[link_name = "llvm.x86.sse41.ptestz"]
12-
fn ptestz(a: __m128i, mask: __m128i) -> i32;
12+
fn ptestz(a: i64x2, mask: i64x2) -> i32;
1313
#[link_name = "llvm.x86.sse41.ptestc"]
14-
fn ptestc(a: __m128i, mask: __m128i) -> i32;
14+
fn ptestc(a: i64x2, mask: i64x2) -> i32;
1515
#[link_name = "llvm.x86.sse41.ptestnzc"]
16-
fn ptestnzc(a: __m128i, mask: __m128i) -> i32;
16+
fn ptestnzc(a: i64x2, mask: i64x2) -> i32;
1717
}
1818

1919
/// Tests whether the specified bits in a 128-bit integer vector are all
@@ -33,7 +33,7 @@ extern "C" {
3333
#[target_feature(enable = "sse4.1")]
3434
#[cfg_attr(test, assert_instr(ptest))]
3535
pub unsafe fn _mm_testz_si128(a: __m128i, mask: __m128i) -> i32 {
36-
ptestz(a, mask)
36+
ptestz(a.as_i64x2(), mask.as_i64x2())
3737
}
3838

3939
/// Tests whether the specified bits in a 128-bit integer vector are all
@@ -53,7 +53,7 @@ pub unsafe fn _mm_testz_si128(a: __m128i, mask: __m128i) -> i32 {
5353
#[target_feature(enable = "sse4.1")]
5454
#[cfg_attr(test, assert_instr(ptest))]
5555
pub unsafe fn _mm_testc_si128(a: __m128i, mask: __m128i) -> i32 {
56-
ptestc(a, mask)
56+
ptestc(a.as_i64x2(), mask.as_i64x2())
5757
}
5858

5959
/// Tests whether the specified bits in a 128-bit integer vector are
@@ -73,7 +73,7 @@ pub unsafe fn _mm_testc_si128(a: __m128i, mask: __m128i) -> i32 {
7373
#[target_feature(enable = "sse4.1")]
7474
#[cfg_attr(test, assert_instr(ptest))]
7575
pub unsafe fn _mm_testnzc_si128(a: __m128i, mask: __m128i) -> i32 {
76-
ptestnzc(a, mask)
76+
ptestnzc(a.as_i64x2(), mask.as_i64x2())
7777
}
7878

7979
/// Tests whether the specified bits in a 128-bit integer vector are all

coresimd/src/x86/x86_64/sse2.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub unsafe fn _mm_cvtsi64x_si128(a: i64) -> __m128i {
8282
#[target_feature(enable = "sse2")]
8383
#[cfg_attr(all(test, not(windows)), assert_instr(movq))]
8484
pub unsafe fn _mm_cvtsi128_si64(a: __m128i) -> i64 {
85-
simd_extract(a, 0)
85+
simd_extract(a.as_i64x2(), 0)
8686
}
8787

8888
/// Return the lowest element of `a`.

0 commit comments

Comments
 (0)