@@ -21,16 +21,6 @@ pub unsafe fn _bextr_u32(a: u32, start: u32, len: u32) -> u32 {
21
21
_bextr2_u32 ( a, ( start & 0xff_u32 ) | ( ( len & 0xff_u32 ) << 8_u32 ) )
22
22
}
23
23
24
- /// Extracts bits in range [`start`, `start` + `length`) from `a` into
25
- /// the least significant bits of the result.
26
- #[ inline( always) ]
27
- #[ target_feature( enable = "bmi" ) ]
28
- #[ cfg_attr( test, assert_instr( bextr) ) ]
29
- #[ cfg( not( target_arch = "x86" ) ) ]
30
- pub unsafe fn _bextr_u64 ( a : u64 , start : u32 , len : u32 ) -> u64 {
31
- _bextr2_u64 ( a, ( ( start & 0xff ) | ( ( len & 0xff ) << 8 ) ) as u64 )
32
- }
33
-
34
24
/// Extracts bits of `a` specified by `control` into
35
25
/// the least significant bits of the result.
36
26
///
@@ -43,19 +33,6 @@ pub unsafe fn _bextr2_u32(a: u32, control: u32) -> u32 {
43
33
x86_bmi_bextr_32 ( a, control)
44
34
}
45
35
46
- /// Extracts bits of `a` specified by `control` into
47
- /// the least significant bits of the result.
48
- ///
49
- /// Bits [7,0] of `control` specify the index to the first bit in the range to
50
- /// be extracted, and bits [15,8] specify the length of the range.
51
- #[ inline( always) ]
52
- #[ target_feature( enable = "bmi" ) ]
53
- #[ cfg_attr( test, assert_instr( bextr) ) ]
54
- #[ cfg( not( target_arch = "x86" ) ) ]
55
- pub unsafe fn _bextr2_u64 ( a : u64 , control : u64 ) -> u64 {
56
- x86_bmi_bextr_64 ( a, control)
57
- }
58
-
59
36
/// Bitwise logical `AND` of inverted `a` with `b`.
60
37
#[ inline( always) ]
61
38
#[ target_feature( enable = "bmi" ) ]
@@ -64,14 +41,6 @@ pub unsafe fn _andn_u32(a: u32, b: u32) -> u32 {
64
41
!a & b
65
42
}
66
43
67
- /// Bitwise logical `AND` of inverted `a` with `b`.
68
- #[ inline( always) ]
69
- #[ target_feature( enable = "bmi" ) ]
70
- #[ cfg_attr( test, assert_instr( andn) ) ]
71
- pub unsafe fn _andn_u64 ( a : u64 , b : u64 ) -> u64 {
72
- !a & b
73
- }
74
-
75
44
/// Extract lowest set isolated bit.
76
45
#[ inline( always) ]
77
46
#[ target_feature( enable = "bmi" ) ]
@@ -80,15 +49,6 @@ pub unsafe fn _blsi_u32(x: u32) -> u32 {
80
49
x & x. wrapping_neg ( )
81
50
}
82
51
83
- /// Extract lowest set isolated bit.
84
- #[ inline( always) ]
85
- #[ target_feature( enable = "bmi" ) ]
86
- #[ cfg_attr( test, assert_instr( blsi) ) ]
87
- #[ cfg( not( target_arch = "x86" ) ) ] // generates lots of instructions
88
- pub unsafe fn _blsi_u64 ( x : u64 ) -> u64 {
89
- x & x. wrapping_neg ( )
90
- }
91
-
92
52
/// Get mask up to lowest set bit.
93
53
#[ inline( always) ]
94
54
#[ target_feature( enable = "bmi" ) ]
@@ -97,15 +57,6 @@ pub unsafe fn _blsmsk_u32(x: u32) -> u32 {
97
57
x ^ ( x. wrapping_sub ( 1_u32 ) )
98
58
}
99
59
100
- /// Get mask up to lowest set bit.
101
- #[ inline( always) ]
102
- #[ target_feature( enable = "bmi" ) ]
103
- #[ cfg_attr( test, assert_instr( blsmsk) ) ]
104
- #[ cfg( not( target_arch = "x86" ) ) ] // generates lots of instructions
105
- pub unsafe fn _blsmsk_u64 ( x : u64 ) -> u64 {
106
- x ^ ( x. wrapping_sub ( 1_u64 ) )
107
- }
108
-
109
60
/// Resets the lowest set bit of `x`.
110
61
///
111
62
/// If `x` is sets CF.
@@ -116,17 +67,6 @@ pub unsafe fn _blsr_u32(x: u32) -> u32 {
116
67
x & ( x. wrapping_sub ( 1 ) )
117
68
}
118
69
119
- /// Resets the lowest set bit of `x`.
120
- ///
121
- /// If `x` is sets CF.
122
- #[ inline( always) ]
123
- #[ target_feature( enable = "bmi" ) ]
124
- #[ cfg_attr( test, assert_instr( blsr) ) ]
125
- #[ cfg( not( target_arch = "x86" ) ) ] // generates lots of instructions
126
- pub unsafe fn _blsr_u64 ( x : u64 ) -> u64 {
127
- x & ( x. wrapping_sub ( 1 ) )
128
- }
129
-
130
70
/// Counts the number of trailing least significant zero bits.
131
71
///
132
72
/// When the source operand is 0, it returns its size in bits.
@@ -137,16 +77,6 @@ pub unsafe fn _tzcnt_u32(x: u32) -> u32 {
137
77
x. trailing_zeros ( )
138
78
}
139
79
140
- /// Counts the number of trailing least significant zero bits.
141
- ///
142
- /// When the source operand is 0, it returns its size in bits.
143
- #[ inline( always) ]
144
- #[ target_feature( enable = "bmi" ) ]
145
- #[ cfg_attr( test, assert_instr( tzcnt) ) ]
146
- pub unsafe fn _tzcnt_u64 ( x : u64 ) -> u64 {
147
- x. trailing_zeros ( ) as u64
148
- }
149
-
150
80
/// Counts the number of trailing least significant zero bits.
151
81
///
152
82
/// When the source operand is 0, it returns its size in bits.
@@ -157,22 +87,9 @@ pub unsafe fn _mm_tzcnt_32(x: u32) -> i32 {
157
87
x. trailing_zeros ( ) as i32
158
88
}
159
89
160
- /// Counts the number of trailing least significant zero bits.
161
- ///
162
- /// When the source operand is 0, it returns its size in bits.
163
- #[ inline( always) ]
164
- #[ target_feature( enable = "bmi" ) ]
165
- #[ cfg_attr( test, assert_instr( tzcnt) ) ]
166
- pub unsafe fn _mm_tzcnt_64 ( x : u64 ) -> i64 {
167
- x. trailing_zeros ( ) as i64
168
- }
169
-
170
- #[ allow( dead_code) ]
171
90
extern "C" {
172
91
#[ link_name = "llvm.x86.bmi.bextr.32" ]
173
92
fn x86_bmi_bextr_32 ( x : u32 , y : u32 ) -> u32 ;
174
- #[ link_name = "llvm.x86.bmi.bextr.64" ]
175
- fn x86_bmi_bextr_64 ( x : u64 , y : u64 ) -> u64 ;
176
93
}
177
94
178
95
#[ cfg( test) ]
@@ -187,13 +104,6 @@ mod tests {
187
104
assert_eq ! ( r, 0b0000_0101u32 ) ;
188
105
}
189
106
190
- #[ simd_test = "bmi" ]
191
- #[ cfg( not( target_arch = "x86" ) ) ]
192
- unsafe fn _bextr_u64 ( ) {
193
- let r = bmi:: _bextr_u64 ( 0b0101_0000u64 , 4 , 4 ) ;
194
- assert_eq ! ( r, 0b0000_0101u64 ) ;
195
- }
196
-
197
107
#[ simd_test = "bmi" ]
198
108
unsafe fn _andn_u32 ( ) {
199
109
assert_eq ! ( bmi:: _andn_u32( 0 , 0 ) , 0 ) ;
@@ -217,81 +127,28 @@ mod tests {
217
127
assert_eq ! ( r, 0b0001_1101u32 ) ;
218
128
}
219
129
220
- #[ simd_test = "bmi" ]
221
- #[ cfg( not( target_arch = "x86" ) ) ]
222
- unsafe fn _andn_u64 ( ) {
223
- assert_eq ! ( bmi:: _andn_u64( 0 , 0 ) , 0 ) ;
224
- assert_eq ! ( bmi:: _andn_u64( 0 , 1 ) , 1 ) ;
225
- assert_eq ! ( bmi:: _andn_u64( 1 , 0 ) , 0 ) ;
226
- assert_eq ! ( bmi:: _andn_u64( 1 , 1 ) , 0 ) ;
227
-
228
- let r = bmi:: _andn_u64 ( 0b0000_0000u64 , 0b0000_0000u64 ) ;
229
- assert_eq ! ( r, 0b0000_0000u64 ) ;
230
-
231
- let r = bmi:: _andn_u64 ( 0b0000_0000u64 , 0b1111_1111u64 ) ;
232
- assert_eq ! ( r, 0b1111_1111u64 ) ;
233
-
234
- let r = bmi:: _andn_u64 ( 0b1111_1111u64 , 0b0000_0000u64 ) ;
235
- assert_eq ! ( r, 0b0000_0000u64 ) ;
236
-
237
- let r = bmi:: _andn_u64 ( 0b1111_1111u64 , 0b1111_1111u64 ) ;
238
- assert_eq ! ( r, 0b0000_0000u64 ) ;
239
-
240
- let r = bmi:: _andn_u64 ( 0b0100_0000u64 , 0b0101_1101u64 ) ;
241
- assert_eq ! ( r, 0b0001_1101u64 ) ;
242
- }
243
-
244
130
#[ simd_test = "bmi" ]
245
131
unsafe fn _blsi_u32 ( ) {
246
132
assert_eq ! ( bmi:: _blsi_u32( 0b1101_0000u32 ) , 0b0001_0000u32 ) ;
247
133
}
248
134
249
- #[ simd_test = "bmi" ]
250
- #[ cfg( not( target_arch = "x86" ) ) ]
251
- unsafe fn _blsi_u64 ( ) {
252
- assert_eq ! ( bmi:: _blsi_u64( 0b1101_0000u64 ) , 0b0001_0000u64 ) ;
253
- }
254
-
255
135
#[ simd_test = "bmi" ]
256
136
unsafe fn _blsmsk_u32 ( ) {
257
137
let r = bmi:: _blsmsk_u32 ( 0b0011_0000u32 ) ;
258
138
assert_eq ! ( r, 0b0001_1111u32 ) ;
259
139
}
260
140
261
- #[ simd_test = "bmi" ]
262
- #[ cfg( not( target_arch = "x86" ) ) ]
263
- unsafe fn _blsmsk_u64 ( ) {
264
- let r = bmi:: _blsmsk_u64 ( 0b0011_0000u64 ) ;
265
- assert_eq ! ( r, 0b0001_1111u64 ) ;
266
- }
267
-
268
141
#[ simd_test = "bmi" ]
269
142
unsafe fn _blsr_u32 ( ) {
270
143
// TODO: test the behavior when the input is 0
271
144
let r = bmi:: _blsr_u32 ( 0b0011_0000u32 ) ;
272
145
assert_eq ! ( r, 0b0010_0000u32 ) ;
273
146
}
274
147
275
- #[ simd_test = "bmi" ]
276
- #[ cfg( not( target_arch = "x86" ) ) ]
277
- unsafe fn _blsr_u64 ( ) {
278
- // TODO: test the behavior when the input is 0
279
- let r = bmi:: _blsr_u64 ( 0b0011_0000u64 ) ;
280
- assert_eq ! ( r, 0b0010_0000u64 ) ;
281
- }
282
-
283
148
#[ simd_test = "bmi" ]
284
149
unsafe fn _tzcnt_u32 ( ) {
285
150
assert_eq ! ( bmi:: _tzcnt_u32( 0b0000_0001u32 ) , 0u32 ) ;
286
151
assert_eq ! ( bmi:: _tzcnt_u32( 0b0000_0000u32 ) , 32u32 ) ;
287
152
assert_eq ! ( bmi:: _tzcnt_u32( 0b1001_0000u32 ) , 4u32 ) ;
288
153
}
289
-
290
- #[ simd_test = "bmi" ]
291
- #[ cfg( not( target_arch = "x86" ) ) ]
292
- unsafe fn _tzcnt_u64 ( ) {
293
- assert_eq ! ( bmi:: _tzcnt_u64( 0b0000_0001u64 ) , 0u64 ) ;
294
- assert_eq ! ( bmi:: _tzcnt_u64( 0b0000_0000u64 ) , 64u64 ) ;
295
- assert_eq ! ( bmi:: _tzcnt_u64( 0b1001_0000u64 ) , 4u64 ) ;
296
- }
297
154
}
0 commit comments