From f2cbe79265a671ddd617ecfe3fbce3963a293ef0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Oliveira?= Date: Fri, 29 Sep 2017 15:31:57 +0100 Subject: [PATCH] Remove define_from! hack and use mem::transmute directly --- library/stdarch/src/v256.rs | 5 ----- library/stdarch/src/x86/avx.rs | 26 ++++++++++++++------------ 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/library/stdarch/src/v256.rs b/library/stdarch/src/v256.rs index ada2c2d22b4b..a5e163e45319 100644 --- a/library/stdarch/src/v256.rs +++ b/library/stdarch/src/v256.rs @@ -73,11 +73,6 @@ define_from!(i16x16, u64x4, i64x4, u32x8, i32x8, u16x16, u8x32, i8x32); define_from!(u8x32, u64x4, i64x4, u32x8, i32x8, u16x16, i16x16, i8x32); define_from!(i8x32, u64x4, i64x4, u32x8, i32x8, u16x16, i16x16, u8x32); -define_from!(f64x4, u64x4); -define_from!(u64x4, f64x4); -define_from!(f32x8, u32x8); -define_from!(u32x8, f32x8); - define_common_ops!( f64x4, f32x8, u64x4, i64x4, u32x8, i32x8, u16x16, i16x16, u8x32, i8x32); define_float_ops!(f64x4, f32x8); diff --git a/library/stdarch/src/x86/avx.rs b/library/stdarch/src/x86/avx.rs index 1501d063b8f7..b4237c4b4cfc 100644 --- a/library/stdarch/src/x86/avx.rs +++ b/library/stdarch/src/x86/avx.rs @@ -1,6 +1,8 @@ #[cfg(test)] use stdsimd_test::assert_instr; +use std::mem; + use v256::*; /// Add packed double-precision (64-bit) floating-point elements @@ -26,9 +28,9 @@ pub unsafe fn _mm256_add_ps(a: f32x8, b: f32x8) -> f32x8 { #[target_feature = "+avx"] #[cfg_attr(test, assert_instr(vandpd))] pub unsafe fn _mm256_and_pd(a: f64x4, b: f64x4) -> f64x4 { - let a: u64x4 = a.into(); - let b: u64x4 = b.into(); - (a & b).into() + let a: u64x4 = mem::transmute(a); + let b: u64x4 = mem::transmute(b); + mem::transmute(a & b) } /// Compute the bitwise AND of packed single-precision (32-bit) floating-point elements in `a` and `b`. @@ -36,9 +38,9 @@ pub unsafe fn _mm256_and_pd(a: f64x4, b: f64x4) -> f64x4 { #[target_feature = "+avx"] #[cfg_attr(test, assert_instr(vandps))] pub unsafe fn _mm256_and_ps(a: f32x8, b: f32x8) -> f32x8 { - let a: u32x8 = a.into(); - let b: u32x8 = b.into(); - (a & b).into() + let a: u32x8 = mem::transmute(a); + let b: u32x8 = mem::transmute(b); + mem::transmute(a & b) } /// Compute the bitwise OR packed double-precision (64-bit) floating-point elements @@ -47,9 +49,9 @@ pub unsafe fn _mm256_and_ps(a: f32x8, b: f32x8) -> f32x8 { #[target_feature = "+avx"] #[cfg_attr(test, assert_instr(vorpd))] pub unsafe fn _mm256_or_pd(a: f64x4, b: f64x4) -> f64x4 { - let a: u64x4 = a.into(); - let b: u64x4 = b.into(); - (a | b).into() + let a: u64x4 = mem::transmute(a); + let b: u64x4 = mem::transmute(b); + mem::transmute(a | b) } /// Compute the bitwise OR packed single-precision (32-bit) floating-point elements in `a` and `b`. @@ -57,9 +59,9 @@ pub unsafe fn _mm256_or_pd(a: f64x4, b: f64x4) -> f64x4 { #[target_feature = "+avx"] #[cfg_attr(test, assert_instr(vorps))] pub unsafe fn _mm256_or_ps(a: f32x8, b: f32x8) -> f32x8 { - let a: u32x8 = a.into(); - let b: u32x8 = b.into(); - (a | b).into() + let a: u32x8 = mem::transmute(a); + let b: u32x8 = mem::transmute(b); + mem::transmute(a | b) } /// Compare packed double-precision (64-bit) floating-point elements