Skip to content

Commit e132fbe

Browse files
committed
mark F16C intrinsics as safe
Mark all F16C intrinsics as safe.
1 parent 8000e78 commit e132fbe

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

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

+16-12
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ unsafe extern "unadjusted" {
2828
#[target_feature(enable = "f16c")]
2929
#[cfg_attr(test, assert_instr("vcvtph2ps"))]
3030
#[stable(feature = "x86_f16c_intrinsics", since = "1.68.0")]
31-
pub unsafe fn _mm_cvtph_ps(a: __m128i) -> __m128 {
32-
transmute(llvm_vcvtph2ps_128(transmute(a)))
31+
pub fn _mm_cvtph_ps(a: __m128i) -> __m128 {
32+
unsafe { transmute(llvm_vcvtph2ps_128(transmute(a))) }
3333
}
3434

3535
/// Converts the 8 x 16-bit half-precision float values in the 128-bit vector
@@ -40,8 +40,8 @@ pub unsafe fn _mm_cvtph_ps(a: __m128i) -> __m128 {
4040
#[target_feature(enable = "f16c")]
4141
#[cfg_attr(test, assert_instr("vcvtph2ps"))]
4242
#[stable(feature = "x86_f16c_intrinsics", since = "1.68.0")]
43-
pub unsafe fn _mm256_cvtph_ps(a: __m128i) -> __m256 {
44-
transmute(llvm_vcvtph2ps_256(transmute(a)))
43+
pub fn _mm256_cvtph_ps(a: __m128i) -> __m256 {
44+
unsafe { transmute(llvm_vcvtph2ps_256(transmute(a))) }
4545
}
4646

4747
/// Converts the 4 x 32-bit float values in the 128-bit vector `a` into 4 x
@@ -62,11 +62,13 @@ pub unsafe fn _mm256_cvtph_ps(a: __m128i) -> __m256 {
6262
#[cfg_attr(test, assert_instr("vcvtps2ph", IMM_ROUNDING = 0))]
6363
#[rustc_legacy_const_generics(1)]
6464
#[stable(feature = "x86_f16c_intrinsics", since = "1.68.0")]
65-
pub unsafe fn _mm_cvtps_ph<const IMM_ROUNDING: i32>(a: __m128) -> __m128i {
65+
pub fn _mm_cvtps_ph<const IMM_ROUNDING: i32>(a: __m128) -> __m128i {
6666
static_assert_uimm_bits!(IMM_ROUNDING, 3);
67-
let a = a.as_f32x4();
68-
let r = llvm_vcvtps2ph_128(a, IMM_ROUNDING);
69-
transmute(r)
67+
unsafe {
68+
let a = a.as_f32x4();
69+
let r = llvm_vcvtps2ph_128(a, IMM_ROUNDING);
70+
transmute(r)
71+
}
7072
}
7173

7274
/// Converts the 8 x 32-bit float values in the 256-bit vector `a` into 8 x
@@ -86,11 +88,13 @@ pub unsafe fn _mm_cvtps_ph<const IMM_ROUNDING: i32>(a: __m128) -> __m128i {
8688
#[cfg_attr(test, assert_instr("vcvtps2ph", IMM_ROUNDING = 0))]
8789
#[rustc_legacy_const_generics(1)]
8890
#[stable(feature = "x86_f16c_intrinsics", since = "1.68.0")]
89-
pub unsafe fn _mm256_cvtps_ph<const IMM_ROUNDING: i32>(a: __m256) -> __m128i {
91+
pub fn _mm256_cvtps_ph<const IMM_ROUNDING: i32>(a: __m256) -> __m128i {
9092
static_assert_uimm_bits!(IMM_ROUNDING, 3);
91-
let a = a.as_f32x8();
92-
let r = llvm_vcvtps2ph_256(a, IMM_ROUNDING);
93-
transmute(r)
93+
unsafe {
94+
let a = a.as_f32x8();
95+
let r = llvm_vcvtps2ph_256(a, IMM_ROUNDING);
96+
transmute(r)
97+
}
9498
}
9599

96100
#[cfg(test)]

0 commit comments

Comments
 (0)