Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e98ecc3

Browse files
committedMay 29, 2025·
mark gfni, vaes, vpclmulqdq intrinsics as safe
1 parent e0e82ca commit e98ecc3

File tree

3 files changed

+165
-132
lines changed

3 files changed

+165
-132
lines changed
 

‎crates/core_arch/src/x86/gfni.rs

Lines changed: 145 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ unsafe extern "C" {
6262
#[target_feature(enable = "gfni,avx512f")]
6363
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
6464
#[cfg_attr(test, assert_instr(vgf2p8mulb))]
65-
pub unsafe fn _mm512_gf2p8mul_epi8(a: __m512i, b: __m512i) -> __m512i {
66-
transmute(vgf2p8mulb_512(a.as_i8x64(), b.as_i8x64()))
65+
pub fn _mm512_gf2p8mul_epi8(a: __m512i, b: __m512i) -> __m512i {
66+
unsafe { transmute(vgf2p8mulb_512(a.as_i8x64(), b.as_i8x64())) }
6767
}
6868

6969
/// Performs a multiplication in GF(2^8) on the packed bytes.
@@ -78,17 +78,14 @@ pub unsafe fn _mm512_gf2p8mul_epi8(a: __m512i, b: __m512i) -> __m512i {
7878
#[target_feature(enable = "gfni,avx512bw,avx512f")]
7979
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
8080
#[cfg_attr(test, assert_instr(vgf2p8mulb))]
81-
pub unsafe fn _mm512_mask_gf2p8mul_epi8(
82-
src: __m512i,
83-
k: __mmask64,
84-
a: __m512i,
85-
b: __m512i,
86-
) -> __m512i {
87-
transmute(simd_select_bitmask(
88-
k,
89-
vgf2p8mulb_512(a.as_i8x64(), b.as_i8x64()),
90-
src.as_i8x64(),
91-
))
81+
pub fn _mm512_mask_gf2p8mul_epi8(src: __m512i, k: __mmask64, a: __m512i, b: __m512i) -> __m512i {
82+
unsafe {
83+
transmute(simd_select_bitmask(
84+
k,
85+
vgf2p8mulb_512(a.as_i8x64(), b.as_i8x64()),
86+
src.as_i8x64(),
87+
))
88+
}
9289
}
9390

9491
/// Performs a multiplication in GF(2^8) on the packed bytes.
@@ -103,13 +100,15 @@ pub unsafe fn _mm512_mask_gf2p8mul_epi8(
103100
#[target_feature(enable = "gfni,avx512bw,avx512f")]
104101
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
105102
#[cfg_attr(test, assert_instr(vgf2p8mulb))]
106-
pub unsafe fn _mm512_maskz_gf2p8mul_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i {
103+
pub fn _mm512_maskz_gf2p8mul_epi8(k: __mmask64, a: __m512i, b: __m512i) -> __m512i {
107104
let zero = i8x64::ZERO;
108-
transmute(simd_select_bitmask(
109-
k,
110-
vgf2p8mulb_512(a.as_i8x64(), b.as_i8x64()),
111-
zero,
112-
))
105+
unsafe {
106+
transmute(simd_select_bitmask(
107+
k,
108+
vgf2p8mulb_512(a.as_i8x64(), b.as_i8x64()),
109+
zero,
110+
))
111+
}
113112
}
114113

115114
/// Performs a multiplication in GF(2^8) on the packed bytes.
@@ -121,8 +120,8 @@ pub unsafe fn _mm512_maskz_gf2p8mul_epi8(k: __mmask64, a: __m512i, b: __m512i) -
121120
#[target_feature(enable = "gfni,avx")]
122121
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
123122
#[cfg_attr(test, assert_instr(vgf2p8mulb))]
124-
pub unsafe fn _mm256_gf2p8mul_epi8(a: __m256i, b: __m256i) -> __m256i {
125-
transmute(vgf2p8mulb_256(a.as_i8x32(), b.as_i8x32()))
123+
pub fn _mm256_gf2p8mul_epi8(a: __m256i, b: __m256i) -> __m256i {
124+
unsafe { transmute(vgf2p8mulb_256(a.as_i8x32(), b.as_i8x32())) }
126125
}
127126

128127
/// Performs a multiplication in GF(2^8) on the packed bytes.
@@ -137,17 +136,14 @@ pub unsafe fn _mm256_gf2p8mul_epi8(a: __m256i, b: __m256i) -> __m256i {
137136
#[target_feature(enable = "gfni,avx512bw,avx512vl")]
138137
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
139138
#[cfg_attr(test, assert_instr(vgf2p8mulb))]
140-
pub unsafe fn _mm256_mask_gf2p8mul_epi8(
141-
src: __m256i,
142-
k: __mmask32,
143-
a: __m256i,
144-
b: __m256i,
145-
) -> __m256i {
146-
transmute(simd_select_bitmask(
147-
k,
148-
vgf2p8mulb_256(a.as_i8x32(), b.as_i8x32()),
149-
src.as_i8x32(),
150-
))
139+
pub fn _mm256_mask_gf2p8mul_epi8(src: __m256i, k: __mmask32, a: __m256i, b: __m256i) -> __m256i {
140+
unsafe {
141+
transmute(simd_select_bitmask(
142+
k,
143+
vgf2p8mulb_256(a.as_i8x32(), b.as_i8x32()),
144+
src.as_i8x32(),
145+
))
146+
}
151147
}
152148

153149
/// Performs a multiplication in GF(2^8) on the packed bytes.
@@ -162,13 +158,15 @@ pub unsafe fn _mm256_mask_gf2p8mul_epi8(
162158
#[target_feature(enable = "gfni,avx512bw,avx512vl")]
163159
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
164160
#[cfg_attr(test, assert_instr(vgf2p8mulb))]
165-
pub unsafe fn _mm256_maskz_gf2p8mul_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i {
161+
pub fn _mm256_maskz_gf2p8mul_epi8(k: __mmask32, a: __m256i, b: __m256i) -> __m256i {
166162
let zero = i8x32::ZERO;
167-
transmute(simd_select_bitmask(
168-
k,
169-
vgf2p8mulb_256(a.as_i8x32(), b.as_i8x32()),
170-
zero,
171-
))
163+
unsafe {
164+
transmute(simd_select_bitmask(
165+
k,
166+
vgf2p8mulb_256(a.as_i8x32(), b.as_i8x32()),
167+
zero,
168+
))
169+
}
172170
}
173171

174172
/// Performs a multiplication in GF(2^8) on the packed bytes.
@@ -180,8 +178,8 @@ pub unsafe fn _mm256_maskz_gf2p8mul_epi8(k: __mmask32, a: __m256i, b: __m256i) -
180178
#[target_feature(enable = "gfni")]
181179
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
182180
#[cfg_attr(test, assert_instr(gf2p8mulb))]
183-
pub unsafe fn _mm_gf2p8mul_epi8(a: __m128i, b: __m128i) -> __m128i {
184-
transmute(vgf2p8mulb_128(a.as_i8x16(), b.as_i8x16()))
181+
pub fn _mm_gf2p8mul_epi8(a: __m128i, b: __m128i) -> __m128i {
182+
unsafe { transmute(vgf2p8mulb_128(a.as_i8x16(), b.as_i8x16())) }
185183
}
186184

187185
/// Performs a multiplication in GF(2^8) on the packed bytes.
@@ -196,17 +194,14 @@ pub unsafe fn _mm_gf2p8mul_epi8(a: __m128i, b: __m128i) -> __m128i {
196194
#[target_feature(enable = "gfni,avx512bw,avx512vl")]
197195
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
198196
#[cfg_attr(test, assert_instr(vgf2p8mulb))]
199-
pub unsafe fn _mm_mask_gf2p8mul_epi8(
200-
src: __m128i,
201-
k: __mmask16,
202-
a: __m128i,
203-
b: __m128i,
204-
) -> __m128i {
205-
transmute(simd_select_bitmask(
206-
k,
207-
vgf2p8mulb_128(a.as_i8x16(), b.as_i8x16()),
208-
src.as_i8x16(),
209-
))
197+
pub fn _mm_mask_gf2p8mul_epi8(src: __m128i, k: __mmask16, a: __m128i, b: __m128i) -> __m128i {
198+
unsafe {
199+
transmute(simd_select_bitmask(
200+
k,
201+
vgf2p8mulb_128(a.as_i8x16(), b.as_i8x16()),
202+
src.as_i8x16(),
203+
))
204+
}
210205
}
211206

212207
/// Performs a multiplication in GF(2^8) on the packed bytes.
@@ -221,13 +216,15 @@ pub unsafe fn _mm_mask_gf2p8mul_epi8(
221216
#[target_feature(enable = "gfni,avx512bw,avx512vl")]
222217
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
223218
#[cfg_attr(test, assert_instr(vgf2p8mulb))]
224-
pub unsafe fn _mm_maskz_gf2p8mul_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i {
225-
let zero = i8x16::ZERO;
226-
transmute(simd_select_bitmask(
227-
k,
228-
vgf2p8mulb_128(a.as_i8x16(), b.as_i8x16()),
229-
zero,
230-
))
219+
pub fn _mm_maskz_gf2p8mul_epi8(k: __mmask16, a: __m128i, b: __m128i) -> __m128i {
220+
unsafe {
221+
let zero = i8x16::ZERO;
222+
transmute(simd_select_bitmask(
223+
k,
224+
vgf2p8mulb_128(a.as_i8x16(), b.as_i8x16()),
225+
zero,
226+
))
227+
}
231228
}
232229

233230
/// Performs an affine transformation on the packed bytes in x.
@@ -241,13 +238,15 @@ pub unsafe fn _mm_maskz_gf2p8mul_epi8(k: __mmask16, a: __m128i, b: __m128i) -> _
241238
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
242239
#[cfg_attr(test, assert_instr(vgf2p8affineqb, B = 0))]
243240
#[rustc_legacy_const_generics(2)]
244-
pub unsafe fn _mm512_gf2p8affine_epi64_epi8<const B: i32>(x: __m512i, a: __m512i) -> __m512i {
241+
pub fn _mm512_gf2p8affine_epi64_epi8<const B: i32>(x: __m512i, a: __m512i) -> __m512i {
245242
static_assert_uimm_bits!(B, 8);
246243
let b = B as u8;
247244
let x = x.as_i8x64();
248245
let a = a.as_i8x64();
249-
let r = vgf2p8affineqb_512(x, a, b);
250-
transmute(r)
246+
unsafe {
247+
let r = vgf2p8affineqb_512(x, a, b);
248+
transmute(r)
249+
}
251250
}
252251

253252
/// Performs an affine transformation on the packed bytes in x.
@@ -264,7 +263,7 @@ pub unsafe fn _mm512_gf2p8affine_epi64_epi8<const B: i32>(x: __m512i, a: __m512i
264263
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
265264
#[cfg_attr(test, assert_instr(vgf2p8affineqb, B = 0))]
266265
#[rustc_legacy_const_generics(3)]
267-
pub unsafe fn _mm512_maskz_gf2p8affine_epi64_epi8<const B: i32>(
266+
pub fn _mm512_maskz_gf2p8affine_epi64_epi8<const B: i32>(
268267
k: __mmask64,
269268
x: __m512i,
270269
a: __m512i,
@@ -274,8 +273,10 @@ pub unsafe fn _mm512_maskz_gf2p8affine_epi64_epi8<const B: i32>(
274273
let zero = i8x64::ZERO;
275274
let x = x.as_i8x64();
276275
let a = a.as_i8x64();
277-
let r = vgf2p8affineqb_512(x, a, b);
278-
transmute(simd_select_bitmask(k, r, zero))
276+
unsafe {
277+
let r = vgf2p8affineqb_512(x, a, b);
278+
transmute(simd_select_bitmask(k, r, zero))
279+
}
279280
}
280281

281282
/// Performs an affine transformation on the packed bytes in x.
@@ -292,7 +293,7 @@ pub unsafe fn _mm512_maskz_gf2p8affine_epi64_epi8<const B: i32>(
292293
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
293294
#[cfg_attr(test, assert_instr(vgf2p8affineqb, B = 0))]
294295
#[rustc_legacy_const_generics(4)]
295-
pub unsafe fn _mm512_mask_gf2p8affine_epi64_epi8<const B: i32>(
296+
pub fn _mm512_mask_gf2p8affine_epi64_epi8<const B: i32>(
296297
src: __m512i,
297298
k: __mmask64,
298299
x: __m512i,
@@ -302,8 +303,10 @@ pub unsafe fn _mm512_mask_gf2p8affine_epi64_epi8<const B: i32>(
302303
let b = B as u8;
303304
let x = x.as_i8x64();
304305
let a = a.as_i8x64();
305-
let r = vgf2p8affineqb_512(x, a, b);
306-
transmute(simd_select_bitmask(k, r, src.as_i8x64()))
306+
unsafe {
307+
let r = vgf2p8affineqb_512(x, a, b);
308+
transmute(simd_select_bitmask(k, r, src.as_i8x64()))
309+
}
307310
}
308311

309312
/// Performs an affine transformation on the packed bytes in x.
@@ -317,13 +320,15 @@ pub unsafe fn _mm512_mask_gf2p8affine_epi64_epi8<const B: i32>(
317320
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
318321
#[cfg_attr(test, assert_instr(vgf2p8affineqb, B = 0))]
319322
#[rustc_legacy_const_generics(2)]
320-
pub unsafe fn _mm256_gf2p8affine_epi64_epi8<const B: i32>(x: __m256i, a: __m256i) -> __m256i {
323+
pub fn _mm256_gf2p8affine_epi64_epi8<const B: i32>(x: __m256i, a: __m256i) -> __m256i {
321324
static_assert_uimm_bits!(B, 8);
322325
let b = B as u8;
323326
let x = x.as_i8x32();
324327
let a = a.as_i8x32();
325-
let r = vgf2p8affineqb_256(x, a, b);
326-
transmute(r)
328+
unsafe {
329+
let r = vgf2p8affineqb_256(x, a, b);
330+
transmute(r)
331+
}
327332
}
328333

329334
/// Performs an affine transformation on the packed bytes in x.
@@ -340,7 +345,7 @@ pub unsafe fn _mm256_gf2p8affine_epi64_epi8<const B: i32>(x: __m256i, a: __m256i
340345
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
341346
#[cfg_attr(test, assert_instr(vgf2p8affineqb, B = 0))]
342347
#[rustc_legacy_const_generics(3)]
343-
pub unsafe fn _mm256_maskz_gf2p8affine_epi64_epi8<const B: i32>(
348+
pub fn _mm256_maskz_gf2p8affine_epi64_epi8<const B: i32>(
344349
k: __mmask32,
345350
x: __m256i,
346351
a: __m256i,
@@ -350,8 +355,10 @@ pub unsafe fn _mm256_maskz_gf2p8affine_epi64_epi8<const B: i32>(
350355
let zero = i8x32::ZERO;
351356
let x = x.as_i8x32();
352357
let a = a.as_i8x32();
353-
let r = vgf2p8affineqb_256(x, a, b);
354-
transmute(simd_select_bitmask(k, r, zero))
358+
unsafe {
359+
let r = vgf2p8affineqb_256(x, a, b);
360+
transmute(simd_select_bitmask(k, r, zero))
361+
}
355362
}
356363

357364
/// Performs an affine transformation on the packed bytes in x.
@@ -368,7 +375,7 @@ pub unsafe fn _mm256_maskz_gf2p8affine_epi64_epi8<const B: i32>(
368375
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
369376
#[cfg_attr(test, assert_instr(vgf2p8affineqb, B = 0))]
370377
#[rustc_legacy_const_generics(4)]
371-
pub unsafe fn _mm256_mask_gf2p8affine_epi64_epi8<const B: i32>(
378+
pub fn _mm256_mask_gf2p8affine_epi64_epi8<const B: i32>(
372379
src: __m256i,
373380
k: __mmask32,
374381
x: __m256i,
@@ -378,8 +385,10 @@ pub unsafe fn _mm256_mask_gf2p8affine_epi64_epi8<const B: i32>(
378385
let b = B as u8;
379386
let x = x.as_i8x32();
380387
let a = a.as_i8x32();
381-
let r = vgf2p8affineqb_256(x, a, b);
382-
transmute(simd_select_bitmask(k, r, src.as_i8x32()))
388+
unsafe {
389+
let r = vgf2p8affineqb_256(x, a, b);
390+
transmute(simd_select_bitmask(k, r, src.as_i8x32()))
391+
}
383392
}
384393

385394
/// Performs an affine transformation on the packed bytes in x.
@@ -393,13 +402,15 @@ pub unsafe fn _mm256_mask_gf2p8affine_epi64_epi8<const B: i32>(
393402
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
394403
#[cfg_attr(test, assert_instr(gf2p8affineqb, B = 0))]
395404
#[rustc_legacy_const_generics(2)]
396-
pub unsafe fn _mm_gf2p8affine_epi64_epi8<const B: i32>(x: __m128i, a: __m128i) -> __m128i {
405+
pub fn _mm_gf2p8affine_epi64_epi8<const B: i32>(x: __m128i, a: __m128i) -> __m128i {
397406
static_assert_uimm_bits!(B, 8);
398407
let b = B as u8;
399408
let x = x.as_i8x16();
400409
let a = a.as_i8x16();
401-
let r = vgf2p8affineqb_128(x, a, b);
402-
transmute(r)
410+
unsafe {
411+
let r = vgf2p8affineqb_128(x, a, b);
412+
transmute(r)
413+
}
403414
}
404415

405416
/// Performs an affine transformation on the packed bytes in x.
@@ -416,7 +427,7 @@ pub unsafe fn _mm_gf2p8affine_epi64_epi8<const B: i32>(x: __m128i, a: __m128i) -
416427
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
417428
#[cfg_attr(test, assert_instr(vgf2p8affineqb, B = 0))]
418429
#[rustc_legacy_const_generics(3)]
419-
pub unsafe fn _mm_maskz_gf2p8affine_epi64_epi8<const B: i32>(
430+
pub fn _mm_maskz_gf2p8affine_epi64_epi8<const B: i32>(
420431
k: __mmask16,
421432
x: __m128i,
422433
a: __m128i,
@@ -426,8 +437,10 @@ pub unsafe fn _mm_maskz_gf2p8affine_epi64_epi8<const B: i32>(
426437
let zero = i8x16::ZERO;
427438
let x = x.as_i8x16();
428439
let a = a.as_i8x16();
429-
let r = vgf2p8affineqb_128(x, a, b);
430-
transmute(simd_select_bitmask(k, r, zero))
440+
unsafe {
441+
let r = vgf2p8affineqb_128(x, a, b);
442+
transmute(simd_select_bitmask(k, r, zero))
443+
}
431444
}
432445

433446
/// Performs an affine transformation on the packed bytes in x.
@@ -444,7 +457,7 @@ pub unsafe fn _mm_maskz_gf2p8affine_epi64_epi8<const B: i32>(
444457
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
445458
#[cfg_attr(test, assert_instr(vgf2p8affineqb, B = 0))]
446459
#[rustc_legacy_const_generics(4)]
447-
pub unsafe fn _mm_mask_gf2p8affine_epi64_epi8<const B: i32>(
460+
pub fn _mm_mask_gf2p8affine_epi64_epi8<const B: i32>(
448461
src: __m128i,
449462
k: __mmask16,
450463
x: __m128i,
@@ -454,8 +467,10 @@ pub unsafe fn _mm_mask_gf2p8affine_epi64_epi8<const B: i32>(
454467
let b = B as u8;
455468
let x = x.as_i8x16();
456469
let a = a.as_i8x16();
457-
let r = vgf2p8affineqb_128(x, a, b);
458-
transmute(simd_select_bitmask(k, r, src.as_i8x16()))
470+
unsafe {
471+
let r = vgf2p8affineqb_128(x, a, b);
472+
transmute(simd_select_bitmask(k, r, src.as_i8x16()))
473+
}
459474
}
460475

461476
/// Performs an affine transformation on the inverted packed bytes in x.
@@ -471,13 +486,15 @@ pub unsafe fn _mm_mask_gf2p8affine_epi64_epi8<const B: i32>(
471486
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
472487
#[cfg_attr(test, assert_instr(vgf2p8affineinvqb, B = 0))]
473488
#[rustc_legacy_const_generics(2)]
474-
pub unsafe fn _mm512_gf2p8affineinv_epi64_epi8<const B: i32>(x: __m512i, a: __m512i) -> __m512i {
489+
pub fn _mm512_gf2p8affineinv_epi64_epi8<const B: i32>(x: __m512i, a: __m512i) -> __m512i {
475490
static_assert_uimm_bits!(B, 8);
476491
let b = B as u8;
477492
let x = x.as_i8x64();
478493
let a = a.as_i8x64();
479-
let r = vgf2p8affineinvqb_512(x, a, b);
480-
transmute(r)
494+
unsafe {
495+
let r = vgf2p8affineinvqb_512(x, a, b);
496+
transmute(r)
497+
}
481498
}
482499

483500
/// Performs an affine transformation on the inverted packed bytes in x.
@@ -496,7 +513,7 @@ pub unsafe fn _mm512_gf2p8affineinv_epi64_epi8<const B: i32>(x: __m512i, a: __m5
496513
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
497514
#[cfg_attr(test, assert_instr(vgf2p8affineinvqb, B = 0))]
498515
#[rustc_legacy_const_generics(3)]
499-
pub unsafe fn _mm512_maskz_gf2p8affineinv_epi64_epi8<const B: i32>(
516+
pub fn _mm512_maskz_gf2p8affineinv_epi64_epi8<const B: i32>(
500517
k: __mmask64,
501518
x: __m512i,
502519
a: __m512i,
@@ -506,8 +523,10 @@ pub unsafe fn _mm512_maskz_gf2p8affineinv_epi64_epi8<const B: i32>(
506523
let zero = i8x64::ZERO;
507524
let x = x.as_i8x64();
508525
let a = a.as_i8x64();
509-
let r = vgf2p8affineinvqb_512(x, a, b);
510-
transmute(simd_select_bitmask(k, r, zero))
526+
unsafe {
527+
let r = vgf2p8affineinvqb_512(x, a, b);
528+
transmute(simd_select_bitmask(k, r, zero))
529+
}
511530
}
512531

513532
/// Performs an affine transformation on the inverted packed bytes in x.
@@ -526,7 +545,7 @@ pub unsafe fn _mm512_maskz_gf2p8affineinv_epi64_epi8<const B: i32>(
526545
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
527546
#[cfg_attr(test, assert_instr(vgf2p8affineinvqb, B = 0))]
528547
#[rustc_legacy_const_generics(4)]
529-
pub unsafe fn _mm512_mask_gf2p8affineinv_epi64_epi8<const B: i32>(
548+
pub fn _mm512_mask_gf2p8affineinv_epi64_epi8<const B: i32>(
530549
src: __m512i,
531550
k: __mmask64,
532551
x: __m512i,
@@ -536,8 +555,10 @@ pub unsafe fn _mm512_mask_gf2p8affineinv_epi64_epi8<const B: i32>(
536555
let b = B as u8;
537556
let x = x.as_i8x64();
538557
let a = a.as_i8x64();
539-
let r = vgf2p8affineinvqb_512(x, a, b);
540-
transmute(simd_select_bitmask(k, r, src.as_i8x64()))
558+
unsafe {
559+
let r = vgf2p8affineinvqb_512(x, a, b);
560+
transmute(simd_select_bitmask(k, r, src.as_i8x64()))
561+
}
541562
}
542563

543564
/// Performs an affine transformation on the inverted packed bytes in x.
@@ -553,13 +574,15 @@ pub unsafe fn _mm512_mask_gf2p8affineinv_epi64_epi8<const B: i32>(
553574
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
554575
#[cfg_attr(test, assert_instr(vgf2p8affineinvqb, B = 0))]
555576
#[rustc_legacy_const_generics(2)]
556-
pub unsafe fn _mm256_gf2p8affineinv_epi64_epi8<const B: i32>(x: __m256i, a: __m256i) -> __m256i {
577+
pub fn _mm256_gf2p8affineinv_epi64_epi8<const B: i32>(x: __m256i, a: __m256i) -> __m256i {
557578
static_assert_uimm_bits!(B, 8);
558579
let b = B as u8;
559580
let x = x.as_i8x32();
560581
let a = a.as_i8x32();
561-
let r = vgf2p8affineinvqb_256(x, a, b);
562-
transmute(r)
582+
unsafe {
583+
let r = vgf2p8affineinvqb_256(x, a, b);
584+
transmute(r)
585+
}
563586
}
564587

565588
/// Performs an affine transformation on the inverted packed bytes in x.
@@ -578,7 +601,7 @@ pub unsafe fn _mm256_gf2p8affineinv_epi64_epi8<const B: i32>(x: __m256i, a: __m2
578601
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
579602
#[cfg_attr(test, assert_instr(vgf2p8affineinvqb, B = 0))]
580603
#[rustc_legacy_const_generics(3)]
581-
pub unsafe fn _mm256_maskz_gf2p8affineinv_epi64_epi8<const B: i32>(
604+
pub fn _mm256_maskz_gf2p8affineinv_epi64_epi8<const B: i32>(
582605
k: __mmask32,
583606
x: __m256i,
584607
a: __m256i,
@@ -588,8 +611,10 @@ pub unsafe fn _mm256_maskz_gf2p8affineinv_epi64_epi8<const B: i32>(
588611
let zero = i8x32::ZERO;
589612
let x = x.as_i8x32();
590613
let a = a.as_i8x32();
591-
let r = vgf2p8affineinvqb_256(x, a, b);
592-
transmute(simd_select_bitmask(k, r, zero))
614+
unsafe {
615+
let r = vgf2p8affineinvqb_256(x, a, b);
616+
transmute(simd_select_bitmask(k, r, zero))
617+
}
593618
}
594619

595620
/// Performs an affine transformation on the inverted packed bytes in x.
@@ -608,7 +633,7 @@ pub unsafe fn _mm256_maskz_gf2p8affineinv_epi64_epi8<const B: i32>(
608633
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
609634
#[cfg_attr(test, assert_instr(vgf2p8affineinvqb, B = 0))]
610635
#[rustc_legacy_const_generics(4)]
611-
pub unsafe fn _mm256_mask_gf2p8affineinv_epi64_epi8<const B: i32>(
636+
pub fn _mm256_mask_gf2p8affineinv_epi64_epi8<const B: i32>(
612637
src: __m256i,
613638
k: __mmask32,
614639
x: __m256i,
@@ -618,8 +643,10 @@ pub unsafe fn _mm256_mask_gf2p8affineinv_epi64_epi8<const B: i32>(
618643
let b = B as u8;
619644
let x = x.as_i8x32();
620645
let a = a.as_i8x32();
621-
let r = vgf2p8affineinvqb_256(x, a, b);
622-
transmute(simd_select_bitmask(k, r, src.as_i8x32()))
646+
unsafe {
647+
let r = vgf2p8affineinvqb_256(x, a, b);
648+
transmute(simd_select_bitmask(k, r, src.as_i8x32()))
649+
}
623650
}
624651

625652
/// Performs an affine transformation on the inverted packed bytes in x.
@@ -635,13 +662,15 @@ pub unsafe fn _mm256_mask_gf2p8affineinv_epi64_epi8<const B: i32>(
635662
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
636663
#[cfg_attr(test, assert_instr(gf2p8affineinvqb, B = 0))]
637664
#[rustc_legacy_const_generics(2)]
638-
pub unsafe fn _mm_gf2p8affineinv_epi64_epi8<const B: i32>(x: __m128i, a: __m128i) -> __m128i {
665+
pub fn _mm_gf2p8affineinv_epi64_epi8<const B: i32>(x: __m128i, a: __m128i) -> __m128i {
639666
static_assert_uimm_bits!(B, 8);
640667
let b = B as u8;
641668
let x = x.as_i8x16();
642669
let a = a.as_i8x16();
643-
let r = vgf2p8affineinvqb_128(x, a, b);
644-
transmute(r)
670+
unsafe {
671+
let r = vgf2p8affineinvqb_128(x, a, b);
672+
transmute(r)
673+
}
645674
}
646675

647676
/// Performs an affine transformation on the inverted packed bytes in x.
@@ -660,7 +689,7 @@ pub unsafe fn _mm_gf2p8affineinv_epi64_epi8<const B: i32>(x: __m128i, a: __m128i
660689
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
661690
#[cfg_attr(test, assert_instr(vgf2p8affineinvqb, B = 0))]
662691
#[rustc_legacy_const_generics(3)]
663-
pub unsafe fn _mm_maskz_gf2p8affineinv_epi64_epi8<const B: i32>(
692+
pub fn _mm_maskz_gf2p8affineinv_epi64_epi8<const B: i32>(
664693
k: __mmask16,
665694
x: __m128i,
666695
a: __m128i,
@@ -670,8 +699,10 @@ pub unsafe fn _mm_maskz_gf2p8affineinv_epi64_epi8<const B: i32>(
670699
let zero = i8x16::ZERO;
671700
let x = x.as_i8x16();
672701
let a = a.as_i8x16();
673-
let r = vgf2p8affineinvqb_128(x, a, b);
674-
transmute(simd_select_bitmask(k, r, zero))
702+
unsafe {
703+
let r = vgf2p8affineinvqb_128(x, a, b);
704+
transmute(simd_select_bitmask(k, r, zero))
705+
}
675706
}
676707

677708
/// Performs an affine transformation on the inverted packed bytes in x.
@@ -690,7 +721,7 @@ pub unsafe fn _mm_maskz_gf2p8affineinv_epi64_epi8<const B: i32>(
690721
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
691722
#[cfg_attr(test, assert_instr(vgf2p8affineinvqb, B = 0))]
692723
#[rustc_legacy_const_generics(4)]
693-
pub unsafe fn _mm_mask_gf2p8affineinv_epi64_epi8<const B: i32>(
724+
pub fn _mm_mask_gf2p8affineinv_epi64_epi8<const B: i32>(
694725
src: __m128i,
695726
k: __mmask16,
696727
x: __m128i,
@@ -700,8 +731,10 @@ pub unsafe fn _mm_mask_gf2p8affineinv_epi64_epi8<const B: i32>(
700731
let b = B as u8;
701732
let x = x.as_i8x16();
702733
let a = a.as_i8x16();
703-
let r = vgf2p8affineinvqb_128(x, a, b);
704-
transmute(simd_select_bitmask(k, r, src.as_i8x16()))
734+
unsafe {
735+
let r = vgf2p8affineinvqb_128(x, a, b);
736+
transmute(simd_select_bitmask(k, r, src.as_i8x16()))
737+
}
705738
}
706739

707740
#[cfg(test)]

‎crates/core_arch/src/x86/vaes.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ unsafe extern "C" {
4141
#[target_feature(enable = "vaes")]
4242
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
4343
#[cfg_attr(test, assert_instr(vaesenc))]
44-
pub unsafe fn _mm256_aesenc_epi128(a: __m256i, round_key: __m256i) -> __m256i {
45-
aesenc_256(a, round_key)
44+
pub fn _mm256_aesenc_epi128(a: __m256i, round_key: __m256i) -> __m256i {
45+
unsafe { aesenc_256(a, round_key) }
4646
}
4747

4848
/// Performs the last round of an AES encryption flow on each 128-bit word (state) in `a` using
@@ -53,8 +53,8 @@ pub unsafe fn _mm256_aesenc_epi128(a: __m256i, round_key: __m256i) -> __m256i {
5353
#[target_feature(enable = "vaes")]
5454
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
5555
#[cfg_attr(test, assert_instr(vaesenclast))]
56-
pub unsafe fn _mm256_aesenclast_epi128(a: __m256i, round_key: __m256i) -> __m256i {
57-
aesenclast_256(a, round_key)
56+
pub fn _mm256_aesenclast_epi128(a: __m256i, round_key: __m256i) -> __m256i {
57+
unsafe { aesenclast_256(a, round_key) }
5858
}
5959

6060
/// Performs one round of an AES decryption flow on each 128-bit word (state) in `a` using
@@ -65,8 +65,8 @@ pub unsafe fn _mm256_aesenclast_epi128(a: __m256i, round_key: __m256i) -> __m256
6565
#[target_feature(enable = "vaes")]
6666
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
6767
#[cfg_attr(test, assert_instr(vaesdec))]
68-
pub unsafe fn _mm256_aesdec_epi128(a: __m256i, round_key: __m256i) -> __m256i {
69-
aesdec_256(a, round_key)
68+
pub fn _mm256_aesdec_epi128(a: __m256i, round_key: __m256i) -> __m256i {
69+
unsafe { aesdec_256(a, round_key) }
7070
}
7171

7272
/// Performs the last round of an AES decryption flow on each 128-bit word (state) in `a` using
@@ -77,8 +77,8 @@ pub unsafe fn _mm256_aesdec_epi128(a: __m256i, round_key: __m256i) -> __m256i {
7777
#[target_feature(enable = "vaes")]
7878
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
7979
#[cfg_attr(test, assert_instr(vaesdeclast))]
80-
pub unsafe fn _mm256_aesdeclast_epi128(a: __m256i, round_key: __m256i) -> __m256i {
81-
aesdeclast_256(a, round_key)
80+
pub fn _mm256_aesdeclast_epi128(a: __m256i, round_key: __m256i) -> __m256i {
81+
unsafe { aesdeclast_256(a, round_key) }
8282
}
8383

8484
/// Performs one round of an AES encryption flow on each 128-bit word (state) in `a` using
@@ -89,8 +89,8 @@ pub unsafe fn _mm256_aesdeclast_epi128(a: __m256i, round_key: __m256i) -> __m256
8989
#[target_feature(enable = "vaes,avx512f")]
9090
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
9191
#[cfg_attr(test, assert_instr(vaesenc))]
92-
pub unsafe fn _mm512_aesenc_epi128(a: __m512i, round_key: __m512i) -> __m512i {
93-
aesenc_512(a, round_key)
92+
pub fn _mm512_aesenc_epi128(a: __m512i, round_key: __m512i) -> __m512i {
93+
unsafe { aesenc_512(a, round_key) }
9494
}
9595

9696
/// Performs the last round of an AES encryption flow on each 128-bit word (state) in `a` using
@@ -101,8 +101,8 @@ pub unsafe fn _mm512_aesenc_epi128(a: __m512i, round_key: __m512i) -> __m512i {
101101
#[target_feature(enable = "vaes,avx512f")]
102102
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
103103
#[cfg_attr(test, assert_instr(vaesenclast))]
104-
pub unsafe fn _mm512_aesenclast_epi128(a: __m512i, round_key: __m512i) -> __m512i {
105-
aesenclast_512(a, round_key)
104+
pub fn _mm512_aesenclast_epi128(a: __m512i, round_key: __m512i) -> __m512i {
105+
unsafe { aesenclast_512(a, round_key) }
106106
}
107107

108108
/// Performs one round of an AES decryption flow on each 128-bit word (state) in `a` using
@@ -113,8 +113,8 @@ pub unsafe fn _mm512_aesenclast_epi128(a: __m512i, round_key: __m512i) -> __m512
113113
#[target_feature(enable = "vaes,avx512f")]
114114
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
115115
#[cfg_attr(test, assert_instr(vaesdec))]
116-
pub unsafe fn _mm512_aesdec_epi128(a: __m512i, round_key: __m512i) -> __m512i {
117-
aesdec_512(a, round_key)
116+
pub fn _mm512_aesdec_epi128(a: __m512i, round_key: __m512i) -> __m512i {
117+
unsafe { aesdec_512(a, round_key) }
118118
}
119119

120120
/// Performs the last round of an AES decryption flow on each 128-bit word (state) in `a` using
@@ -125,8 +125,8 @@ pub unsafe fn _mm512_aesdec_epi128(a: __m512i, round_key: __m512i) -> __m512i {
125125
#[target_feature(enable = "vaes,avx512f")]
126126
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
127127
#[cfg_attr(test, assert_instr(vaesdeclast))]
128-
pub unsafe fn _mm512_aesdeclast_epi128(a: __m512i, round_key: __m512i) -> __m512i {
129-
aesdeclast_512(a, round_key)
128+
pub fn _mm512_aesdeclast_epi128(a: __m512i, round_key: __m512i) -> __m512i {
129+
unsafe { aesdeclast_512(a, round_key) }
130130
}
131131

132132
#[cfg(test)]

‎crates/core_arch/src/x86/vpclmulqdq.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ unsafe extern "C" {
3737
// technically according to Intel's documentation we don't need avx512f here, however LLVM gets confused otherwise
3838
#[cfg_attr(test, assert_instr(vpclmul, IMM8 = 0))]
3939
#[rustc_legacy_const_generics(2)]
40-
pub unsafe fn _mm512_clmulepi64_epi128<const IMM8: i32>(a: __m512i, b: __m512i) -> __m512i {
40+
pub fn _mm512_clmulepi64_epi128<const IMM8: i32>(a: __m512i, b: __m512i) -> __m512i {
4141
static_assert_uimm_bits!(IMM8, 8);
42-
pclmulqdq_512(a, b, IMM8 as u8)
42+
unsafe { pclmulqdq_512(a, b, IMM8 as u8) }
4343
}
4444

4545
/// Performs a carry-less multiplication of two 64-bit polynomials over the
@@ -55,9 +55,9 @@ pub unsafe fn _mm512_clmulepi64_epi128<const IMM8: i32>(a: __m512i, b: __m512i)
5555
#[unstable(feature = "stdarch_x86_avx512", issue = "111137")]
5656
#[cfg_attr(test, assert_instr(vpclmul, IMM8 = 0))]
5757
#[rustc_legacy_const_generics(2)]
58-
pub unsafe fn _mm256_clmulepi64_epi128<const IMM8: i32>(a: __m256i, b: __m256i) -> __m256i {
58+
pub fn _mm256_clmulepi64_epi128<const IMM8: i32>(a: __m256i, b: __m256i) -> __m256i {
5959
static_assert_uimm_bits!(IMM8, 8);
60-
pclmulqdq_256(a, b, IMM8 as u8)
60+
unsafe { pclmulqdq_256(a, b, IMM8 as u8) }
6161
}
6262

6363
#[cfg(test)]

0 commit comments

Comments
 (0)
Please sign in to comment.