Skip to content

Commit dea9ce2

Browse files
committed
mark BMI1 intrinsics as safe
Mark all BMI1 intrinsics as safe.
1 parent 6bd844e commit dea9ce2

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

Diff for: crates/core_arch/src/x86/bmi1.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use stdarch_test::assert_instr;
2020
#[target_feature(enable = "bmi1")]
2121
#[cfg_attr(test, assert_instr(bextr))]
2222
#[stable(feature = "simd_x86", since = "1.27.0")]
23-
pub unsafe fn _bextr_u32(a: u32, start: u32, len: u32) -> u32 {
23+
pub fn _bextr_u32(a: u32, start: u32, len: u32) -> u32 {
2424
_bextr2_u32(a, (start & 0xff_u32) | ((len & 0xff_u32) << 8_u32))
2525
}
2626

@@ -35,8 +35,8 @@ pub unsafe fn _bextr_u32(a: u32, start: u32, len: u32) -> u32 {
3535
#[target_feature(enable = "bmi1")]
3636
#[cfg_attr(test, assert_instr(bextr))]
3737
#[stable(feature = "simd_x86", since = "1.27.0")]
38-
pub unsafe fn _bextr2_u32(a: u32, control: u32) -> u32 {
39-
x86_bmi_bextr_32(a, control)
38+
pub fn _bextr2_u32(a: u32, control: u32) -> u32 {
39+
unsafe { x86_bmi_bextr_32(a, control) }
4040
}
4141

4242
/// Bitwise logical `AND` of inverted `a` with `b`.
@@ -46,7 +46,7 @@ pub unsafe fn _bextr2_u32(a: u32, control: u32) -> u32 {
4646
#[target_feature(enable = "bmi1")]
4747
#[cfg_attr(test, assert_instr(andn))]
4848
#[stable(feature = "simd_x86", since = "1.27.0")]
49-
pub unsafe fn _andn_u32(a: u32, b: u32) -> u32 {
49+
pub fn _andn_u32(a: u32, b: u32) -> u32 {
5050
!a & b
5151
}
5252

@@ -57,7 +57,7 @@ pub unsafe fn _andn_u32(a: u32, b: u32) -> u32 {
5757
#[target_feature(enable = "bmi1")]
5858
#[cfg_attr(test, assert_instr(blsi))]
5959
#[stable(feature = "simd_x86", since = "1.27.0")]
60-
pub unsafe fn _blsi_u32(x: u32) -> u32 {
60+
pub fn _blsi_u32(x: u32) -> u32 {
6161
x & x.wrapping_neg()
6262
}
6363

@@ -68,7 +68,7 @@ pub unsafe fn _blsi_u32(x: u32) -> u32 {
6868
#[target_feature(enable = "bmi1")]
6969
#[cfg_attr(test, assert_instr(blsmsk))]
7070
#[stable(feature = "simd_x86", since = "1.27.0")]
71-
pub unsafe fn _blsmsk_u32(x: u32) -> u32 {
71+
pub fn _blsmsk_u32(x: u32) -> u32 {
7272
x ^ (x.wrapping_sub(1_u32))
7373
}
7474

@@ -81,7 +81,7 @@ pub unsafe fn _blsmsk_u32(x: u32) -> u32 {
8181
#[target_feature(enable = "bmi1")]
8282
#[cfg_attr(test, assert_instr(blsr))]
8383
#[stable(feature = "simd_x86", since = "1.27.0")]
84-
pub unsafe fn _blsr_u32(x: u32) -> u32 {
84+
pub fn _blsr_u32(x: u32) -> u32 {
8585
x & (x.wrapping_sub(1))
8686
}
8787

@@ -94,7 +94,7 @@ pub unsafe fn _blsr_u32(x: u32) -> u32 {
9494
#[target_feature(enable = "bmi1")]
9595
#[cfg_attr(test, assert_instr(tzcnt))]
9696
#[stable(feature = "simd_x86_updates", since = "1.82.0")]
97-
pub unsafe fn _tzcnt_u16(x: u16) -> u16 {
97+
pub fn _tzcnt_u16(x: u16) -> u16 {
9898
x.trailing_zeros() as u16
9999
}
100100

@@ -107,7 +107,7 @@ pub unsafe fn _tzcnt_u16(x: u16) -> u16 {
107107
#[target_feature(enable = "bmi1")]
108108
#[cfg_attr(test, assert_instr(tzcnt))]
109109
#[stable(feature = "simd_x86", since = "1.27.0")]
110-
pub unsafe fn _tzcnt_u32(x: u32) -> u32 {
110+
pub fn _tzcnt_u32(x: u32) -> u32 {
111111
x.trailing_zeros()
112112
}
113113

@@ -120,7 +120,7 @@ pub unsafe fn _tzcnt_u32(x: u32) -> u32 {
120120
#[target_feature(enable = "bmi1")]
121121
#[cfg_attr(test, assert_instr(tzcnt))]
122122
#[stable(feature = "simd_x86", since = "1.27.0")]
123-
pub unsafe fn _mm_tzcnt_32(x: u32) -> i32 {
123+
pub fn _mm_tzcnt_32(x: u32) -> i32 {
124124
x.trailing_zeros() as i32
125125
}
126126

Diff for: crates/core_arch/src/x86_64/bmi.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use stdarch_test::assert_instr;
2121
#[cfg_attr(test, assert_instr(bextr))]
2222
#[cfg(not(target_arch = "x86"))]
2323
#[stable(feature = "simd_x86", since = "1.27.0")]
24-
pub unsafe fn _bextr_u64(a: u64, start: u32, len: u32) -> u64 {
24+
pub fn _bextr_u64(a: u64, start: u32, len: u32) -> u64 {
2525
_bextr2_u64(a, ((start & 0xff) | ((len & 0xff) << 8)) as u64)
2626
}
2727

@@ -37,8 +37,8 @@ pub unsafe fn _bextr_u64(a: u64, start: u32, len: u32) -> u64 {
3737
#[cfg_attr(test, assert_instr(bextr))]
3838
#[cfg(not(target_arch = "x86"))]
3939
#[stable(feature = "simd_x86", since = "1.27.0")]
40-
pub unsafe fn _bextr2_u64(a: u64, control: u64) -> u64 {
41-
x86_bmi_bextr_64(a, control)
40+
pub fn _bextr2_u64(a: u64, control: u64) -> u64 {
41+
unsafe { x86_bmi_bextr_64(a, control) }
4242
}
4343

4444
/// Bitwise logical `AND` of inverted `a` with `b`.
@@ -48,7 +48,7 @@ pub unsafe fn _bextr2_u64(a: u64, control: u64) -> u64 {
4848
#[target_feature(enable = "bmi1")]
4949
#[cfg_attr(test, assert_instr(andn))]
5050
#[stable(feature = "simd_x86", since = "1.27.0")]
51-
pub unsafe fn _andn_u64(a: u64, b: u64) -> u64 {
51+
pub fn _andn_u64(a: u64, b: u64) -> u64 {
5252
!a & b
5353
}
5454

@@ -60,7 +60,7 @@ pub unsafe fn _andn_u64(a: u64, b: u64) -> u64 {
6060
#[cfg_attr(test, assert_instr(blsi))]
6161
#[cfg(not(target_arch = "x86"))] // generates lots of instructions
6262
#[stable(feature = "simd_x86", since = "1.27.0")]
63-
pub unsafe fn _blsi_u64(x: u64) -> u64 {
63+
pub fn _blsi_u64(x: u64) -> u64 {
6464
x & x.wrapping_neg()
6565
}
6666

@@ -72,7 +72,7 @@ pub unsafe fn _blsi_u64(x: u64) -> u64 {
7272
#[cfg_attr(test, assert_instr(blsmsk))]
7373
#[cfg(not(target_arch = "x86"))] // generates lots of instructions
7474
#[stable(feature = "simd_x86", since = "1.27.0")]
75-
pub unsafe fn _blsmsk_u64(x: u64) -> u64 {
75+
pub fn _blsmsk_u64(x: u64) -> u64 {
7676
x ^ (x.wrapping_sub(1_u64))
7777
}
7878

@@ -86,7 +86,7 @@ pub unsafe fn _blsmsk_u64(x: u64) -> u64 {
8686
#[cfg_attr(test, assert_instr(blsr))]
8787
#[cfg(not(target_arch = "x86"))] // generates lots of instructions
8888
#[stable(feature = "simd_x86", since = "1.27.0")]
89-
pub unsafe fn _blsr_u64(x: u64) -> u64 {
89+
pub fn _blsr_u64(x: u64) -> u64 {
9090
x & (x.wrapping_sub(1))
9191
}
9292

@@ -99,7 +99,7 @@ pub unsafe fn _blsr_u64(x: u64) -> u64 {
9999
#[target_feature(enable = "bmi1")]
100100
#[cfg_attr(test, assert_instr(tzcnt))]
101101
#[stable(feature = "simd_x86", since = "1.27.0")]
102-
pub unsafe fn _tzcnt_u64(x: u64) -> u64 {
102+
pub fn _tzcnt_u64(x: u64) -> u64 {
103103
x.trailing_zeros() as u64
104104
}
105105

@@ -112,7 +112,7 @@ pub unsafe fn _tzcnt_u64(x: u64) -> u64 {
112112
#[target_feature(enable = "bmi1")]
113113
#[cfg_attr(test, assert_instr(tzcnt))]
114114
#[stable(feature = "simd_x86", since = "1.27.0")]
115-
pub unsafe fn _mm_tzcnt_64(x: u64) -> i64 {
115+
pub fn _mm_tzcnt_64(x: u64) -> i64 {
116116
x.trailing_zeros() as i64
117117
}
118118

0 commit comments

Comments
 (0)