Skip to content

Commit 9c47380

Browse files
committed
Try fix for windows
1 parent cf86d8a commit 9c47380

File tree

2 files changed

+33
-13
lines changed

2 files changed

+33
-13
lines changed

src/x86/macros.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -338,4 +338,12 @@ macro_rules! constify_imm2 {
338338
}
339339
}
340340

341-
341+
macro_rules! constify_imm1 {
342+
($imm8:expr, $expand:ident) => {
343+
#[allow(overflowing_literals)]
344+
match $imm8 & 0b1 {
345+
0 => $expand!(0),
346+
_ => $expand!(1),
347+
}
348+
}
349+
}

src/x86/sse41.rs

+24-12
Original file line numberDiff line numberDiff line change
@@ -64,34 +64,46 @@ pub unsafe fn _mm_blend_ps(a: f32x4, b: f32x4, imm4: u8) -> f32x4 {
6464
/// Extract a single-precision (32-bit) floating-point element from `a`, selected with `imm8`
6565
#[inline(always)]
6666
#[target_feature = "+sse4.1"]
67-
#[cfg_attr(test, assert_instr(extractps, imm8=0))]
68-
pub unsafe fn _mm_extract_ps(a: f32x4, imm8: u8) -> i32 {
69-
mem::transmute(a.extract(imm8 as u32 & 0b11))
67+
#[cfg_attr(test, assert_instr(extractps, imm2=0))]
68+
pub unsafe fn _mm_extract_ps(a: f32x4, imm2: u8) -> i32 {
69+
macro_rules! call {
70+
($imm2:expr) => { mem::transmute(a.extract($imm2)) }
71+
}
72+
constify_imm2!(imm2, call)
7073
}
7174

7275
/// Extract an 8-bit integer from `a` selected with `imm8`
7376
#[inline(always)]
7477
#[target_feature = "+sse4.1"]
75-
#[cfg_attr(test, assert_instr(pextrb, imm8=0))]
76-
pub unsafe fn _mm_extract_epi8(a: i8x16, imm8: u8) -> i8 {
77-
a.extract((imm8 & 0b1111) as u32)
78+
#[cfg_attr(test, assert_instr(pextrb, imm4=0))]
79+
pub unsafe fn _mm_extract_epi8(a: i8x16, imm4: u8) -> i8 {
80+
macro_rules! call {
81+
($imm4:expr) => { a.extract($imm4) }
82+
}
83+
constify_imm4!(imm4, call)
7884
}
7985

8086
/// Extract an 32-bit integer from `a` selected with `imm8`
8187
#[inline(always)]
8288
#[target_feature = "+sse4.1"]
83-
#[cfg_attr(test, assert_instr(pextrd, imm8=1))]
84-
pub unsafe fn _mm_extract_epi32(a: i32x4, imm8: u8) -> i32 {
85-
a.extract((imm8 & 0b11) as u32)
89+
#[cfg_attr(test, assert_instr(pextrd, imm2=1))]
90+
pub unsafe fn _mm_extract_epi32(a: i32x4, imm2: u8) -> i32 {
91+
macro_rules! call {
92+
($imm2:expr) => { a.extract($imm2) }
93+
}
94+
constify_imm2!(imm2, call)
8695
}
8796

8897
/// Extract an 64-bit integer from `a` selected with `imm8`
8998
#[cfg(target_arch = "x86_64")]
9099
#[inline(always)]
91100
#[target_feature = "+sse4.1"]
92-
#[cfg_attr(test, assert_instr(pextrq, imm8=1))]
93-
pub unsafe fn _mm_extract_epi64(a: i64x2, imm8: u8) -> i64 {
94-
a.extract((imm8 & 0b1) as u32)
101+
#[cfg_attr(test, assert_instr(pextrq, imm1=1))]
102+
pub unsafe fn _mm_extract_epi64(a: i64x2, imm1: u8) -> i64 {
103+
macro_rules! call {
104+
($imm1:expr) => { a.extract($imm1) }
105+
}
106+
constify_imm1!(imm1, call)
95107
}
96108

97109
/// Select a single value in `a` to store at some position in `b`,

0 commit comments

Comments
 (0)