diff --git a/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile b/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile index 1422e8c80..e40f4b6fb 100644 --- a/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile +++ b/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile @@ -5,6 +5,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gcc-mips64-linux-gnuabi64 libc6-dev-mips64-cross \ qemu-system-mips64 qemu-user -ENV CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_LINKER=mips64-linux-gnuabi64-gcc \ +ENV CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_LINKER="mips64-linux-gnuabi64-gcc --with-mips-arch-variant=r6" \ CARGO_TARGET_MIPS64_UNKNOWN_LINUX_GNUABI64_RUNNER="qemu-mips64 -L /usr/mips64-linux-gnuabi64" \ OBJDUMP=mips64-linux-gnuabi64-objdump \ No newline at end of file diff --git a/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile b/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile index d94deb5b2..5175b8f30 100644 --- a/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile +++ b/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile @@ -5,6 +5,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ gcc-mips64el-linux-gnuabi64 libc6-dev-mips64el-cross \ qemu-system-mips64el -ENV CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_LINKER=mips64el-linux-gnuabi64-gcc \ +ENV CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_LINKER="mips64el-linux-gnuabi64-gcc --with-mips-arch-variant=r6" \ CARGO_TARGET_MIPS64EL_UNKNOWN_LINUX_GNUABI64_RUNNER="qemu-mips64el -L /usr/mips64el-linux-gnuabi64" \ OBJDUMP=mips64el-linux-gnuabi64-objdump \ No newline at end of file diff --git a/ci/run.sh b/ci/run.sh index 309511a9f..9f8257d66 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -143,11 +143,8 @@ case ${TARGET} in cargo_test cargo_test "--release" "--features=into_bits" - # FIXME: this doesn't compile succesfully - # https://github.com/rust-lang-nursery/packed_simd/issues/18 - # - # export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+msa -C target-cpu=mips64r6" - # cargo_test "--release" "--features=into_bits" + export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+msa -C target-cpu=mips64r6" + cargo_test "--release" "--features=into_bits" ;; powerpc-*) cargo_test diff --git a/src/api/reductions/min_max.rs b/src/api/reductions/min_max.rs index 7bc7c0697..1098dee43 100644 --- a/src/api/reductions/min_max.rs +++ b/src/api/reductions/min_max.rs @@ -2,66 +2,79 @@ macro_rules! impl_reduction_min_max { ([$elem_ty:ident; $elem_count:expr]: $id:ident) => { - impl $id { - /// Largest vector element value. - #[inline] - pub fn max_element(self) -> $elem_ty { - #[cfg(not(any(target_arch = "aarch64", target_arch = "arm")))] - { - use llvm::simd_reduce_max; - unsafe { simd_reduce_max(self.0) } + cfg_if! { + if #[cfg(any( + target_arch = "aarch64", + target_arch = "arm", + all(any(target_arch = "mips", + target_arch = "mips64"), + target_feature = "msa") + ))] { + impl $id { + /// Largest vector element value. + #[inline] + pub fn max_element(self) -> $elem_ty { + // FIXME: broken on AArch64 + // https://github.com/rust-lang-nursery/packed_simd/issues/15 + // FIXME: broken on MIPS + // https://github.com/rust-lang-nursery/packed_simd/issues/18 + let mut x = self.extract(0); + for i in 1..$id::lanes() { + x = x.max(self.extract(i)); + } + x + } } - #[cfg(any(target_arch = "aarch64", target_arch = "arm"))] - { - // FIXME: broken on AArch64 - // https://github.com/rust-lang-nursery/packed_simd/issues/15 - let mut x = self.extract(0); - for i in 1..$id::lanes() { - x = x.max(self.extract(i)); + } else { + impl $id { + /// Largest vector element value. + #[inline] + pub fn max_element(self) -> $elem_ty { + use llvm::simd_reduce_max; + unsafe { simd_reduce_max(self.0) } } - x } } + } - /// Smallest vector element value. - #[inline] - pub fn min_element(self) -> $elem_ty { - #[cfg( - not( - any( - target_arch = "aarch64", - target_arch = "arm", - all( - target_arch = "x86", - not(target_feature = "sse2") - ) - ) - ) - )] - { - use llvm::simd_reduce_min; - unsafe { simd_reduce_min(self.0) } + cfg_if! { + if #[cfg(any( + target_arch = "aarch64", + target_arch = "arm", + all(any(target_arch = "mips", target_arch = "mips64"), + target_feature = "msa"), + all(target_arch = "x86", not(target_feature = "sse2")) + ))] + { + impl $id { + /// Smallest vector element value. + #[inline] + pub fn min_element(self) -> $elem_ty { + // FIXME: broken on AArch64 + // https://github.com/rust-lang-nursery/packed_simd/issues/15 + // FIXME: broken on i586-unknown-linux-gnu + // https://github.com/rust-lang-nursery/packed_simd/issues/22 + // FIXME: broken on MIPS + // https://github.com/rust-lang-nursery/packed_simd/issues/18 + let mut x = self.extract(0); + for i in 1..$id::lanes() { + x = x.min(self.extract(i)); + } + x + } } - #[cfg( - any( - target_arch = "aarch64", - target_arch = "arm", - all(target_arch = "x86", not(target_feature = "sse2")) - ) - )] - { - // FIXME: broken on AArch64 - // https://github.com/rust-lang-nursery/packed_simd/issues/15 - // FIXME: broken on i586-unknown-linux-gnu - // https://github.com/rust-lang-nursery/packed_simd/issues/22 - let mut x = self.extract(0); - for i in 1..$id::lanes() { - x = x.min(self.extract(i)); + } else { + impl $id { + /// Smallest vector element value. + #[inline] + pub fn min_element(self) -> $elem_ty { + use llvm::simd_reduce_min; + unsafe { simd_reduce_min(self.0) } } - x } } } + #[cfg(test)] interpolate_idents! { mod [$id _reduction_min_max] { @@ -75,7 +88,7 @@ macro_rules! impl_reduction_min_max { assert_eq!(v.max_element(), 1 as $elem_ty); } let v = v.replace(0, 2 as $elem_ty); - assert_eq!(v.max_element(), 2 as $elem_ty); + assert_eq!(v.max_element(), 2 as $elem_ty); } #[test] @@ -121,6 +134,10 @@ macro_rules! test_reduction_float_min_max { let target_with_broken_last_lane_nan = !cfg!(any( target_arch = "arm", target_arch = "aarch64", + all( + any(target_arch = "mips",target_arch = "mips64"), + target_feature = "msa" + ), all(target_arch = "x86", not(target_feature = "sse2")) )); @@ -223,7 +240,11 @@ macro_rules! test_reduction_float_min_max { let v0 = $id::splat(-3.); let target_with_broken_last_lane_nan = !cfg!(any( - target_arch = "arm", target_arch = "aarch64" + target_arch = "arm", target_arch = "aarch64", + all( + any(target_arch = "mips",target_arch = "mips64"), + target_feature = "msa" + ) )); // The vector is initialized to `-3.`s: [-3, -3, -3, -3]