//! LoongArch64 LSX intrinsics - intrinsics::simd implementation

use super::super::{simd as ls, simd::*, *};
use crate::core_arch::simd::{self as cs, *};
use crate::intrinsics::simd as is;
use crate::mem::transmute;

#[inline(always)]
#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")]
const unsafe fn simd_pickev_b<T: Copy>(a: T, b: T) -> T {
    simd_shuffle!(b, a, [0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30])
}

#[inline(always)]
#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")]
const unsafe fn simd_pickev_h<T: Copy>(a: T, b: T) -> T {
    simd_shuffle!(b, a, [0, 2, 4, 6, 8, 10, 12, 14])
}

#[inline(always)]
#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")]
const unsafe fn simd_pickev_w<T: Copy>(a: T, b: T) -> T {
    simd_shuffle!(b, a, [0, 2, 4, 6])
}

#[inline(always)]
#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")]
const unsafe fn simd_pickev_d<T: Copy>(a: T, b: T) -> T {
    simd_shuffle!(b, a, [0, 2])
}

#[inline(always)]
#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")]
const unsafe fn simd_pickod_b<T: Copy>(a: T, b: T) -> T {
    simd_shuffle!(b, a, [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31])
}

#[inline(always)]
#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")]
const unsafe fn simd_pickod_h<T: Copy>(a: T, b: T) -> T {
    simd_shuffle!(b, a, [1, 3, 5, 7, 9, 11, 13, 15])
}

#[inline(always)]
#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")]
const unsafe fn simd_pickod_w<T: Copy>(a: T, b: T) -> T {
    simd_shuffle!(b, a, [1, 3, 5, 7])
}

#[inline(always)]
#[rustc_const_unstable(feature = "stdarch_const_helpers", issue = "none")]
const unsafe fn simd_pickod_d<T: Copy>(a: T, b: T) -> T {
    simd_shuffle!(b, a, [1, 3])
}

impl_vv!("lsx", lsx_vpcnt_b, is::simd_ctpop, m128i, i8x16);
impl_vv!("lsx", lsx_vpcnt_h, is::simd_ctpop, m128i, i16x8);
impl_vv!("lsx", lsx_vpcnt_w, is::simd_ctpop, m128i, i32x4);
impl_vv!("lsx", lsx_vpcnt_d, is::simd_ctpop, m128i, i64x2);
impl_vv!("lsx", lsx_vclz_b, is::simd_ctlz, m128i, i8x16);
impl_vv!("lsx", lsx_vclz_h, is::simd_ctlz, m128i, i16x8);
impl_vv!("lsx", lsx_vclz_w, is::simd_ctlz, m128i, i32x4);
impl_vv!("lsx", lsx_vclz_d, is::simd_ctlz, m128i, i64x2);
impl_vv!("lsx", lsx_vneg_b, is::simd_neg, m128i, i8x16);
impl_vv!("lsx", lsx_vneg_h, is::simd_neg, m128i, i16x8);
impl_vv!("lsx", lsx_vneg_w, is::simd_neg, m128i, i32x4);
impl_vv!("lsx", lsx_vneg_d, is::simd_neg, m128i, i64x2);
impl_vv!("lsx", lsx_vfsqrt_s, is::simd_fsqrt, m128, f32x4);
impl_vv!("lsx", lsx_vfsqrt_d, is::simd_fsqrt, m128d, f64x2);

impl_gv!("lsx", lsx_vreplgr2vr_b, ls::simd_splat, m128i, i8x16, i32);
impl_gv!("lsx", lsx_vreplgr2vr_h, ls::simd_splat, m128i, i16x8, i32);
impl_gv!("lsx", lsx_vreplgr2vr_w, ls::simd_splat, m128i, i32x4, i32);
impl_gv!("lsx", lsx_vreplgr2vr_d, ls::simd_splat, m128i, i64x2, i64);

impl_sv!("lsx", lsx_vrepli_b, ls::simd_splat, m128i, i8x16, 10);
impl_sv!("lsx", lsx_vrepli_h, ls::simd_splat, m128i, i16x8, 10);
impl_sv!("lsx", lsx_vrepli_w, ls::simd_splat, m128i, i32x4, 10);
impl_sv!("lsx", lsx_vrepli_d, ls::simd_splat, m128i, i64x2, 10);

impl_vvv!("lsx", lsx_vadd_b, is::simd_add, m128i, i8x16);
impl_vvv!("lsx", lsx_vadd_h, is::simd_add, m128i, i16x8);
impl_vvv!("lsx", lsx_vadd_w, is::simd_add, m128i, i32x4);
impl_vvv!("lsx", lsx_vadd_d, is::simd_add, m128i, i64x2);
impl_vvv!("lsx", lsx_vsub_b, is::simd_sub, m128i, i8x16);
impl_vvv!("lsx", lsx_vsub_h, is::simd_sub, m128i, i16x8);
impl_vvv!("lsx", lsx_vsub_w, is::simd_sub, m128i, i32x4);
impl_vvv!("lsx", lsx_vsub_d, is::simd_sub, m128i, i64x2);
impl_vvv!("lsx", lsx_vmax_b, cs::simd_imax, m128i, i8x16);
impl_vvv!("lsx", lsx_vmax_h, cs::simd_imax, m128i, i16x8);
impl_vvv!("lsx", lsx_vmax_w, cs::simd_imax, m128i, i32x4);
impl_vvv!("lsx", lsx_vmax_d, cs::simd_imax, m128i, i64x2);
impl_vvv!("lsx", lsx_vmax_bu, cs::simd_imax, m128i, u8x16);
impl_vvv!("lsx", lsx_vmax_hu, cs::simd_imax, m128i, u16x8);
impl_vvv!("lsx", lsx_vmax_wu, cs::simd_imax, m128i, u32x4);
impl_vvv!("lsx", lsx_vmax_du, cs::simd_imax, m128i, u64x2);
impl_vvv!("lsx", lsx_vmin_b, cs::simd_imin, m128i, i8x16);
impl_vvv!("lsx", lsx_vmin_h, cs::simd_imin, m128i, i16x8);
impl_vvv!("lsx", lsx_vmin_w, cs::simd_imin, m128i, i32x4);
impl_vvv!("lsx", lsx_vmin_d, cs::simd_imin, m128i, i64x2);
impl_vvv!("lsx", lsx_vmin_bu, cs::simd_imin, m128i, u8x16);
impl_vvv!("lsx", lsx_vmin_hu, cs::simd_imin, m128i, u16x8);
impl_vvv!("lsx", lsx_vmin_wu, cs::simd_imin, m128i, u32x4);
impl_vvv!("lsx", lsx_vmin_du, cs::simd_imin, m128i, u64x2);
impl_vvv!("lsx", lsx_vseq_b, is::simd_eq, m128i, i8x16);
impl_vvv!("lsx", lsx_vseq_h, is::simd_eq, m128i, i16x8);
impl_vvv!("lsx", lsx_vseq_w, is::simd_eq, m128i, i32x4);
impl_vvv!("lsx", lsx_vseq_d, is::simd_eq, m128i, i64x2);
impl_vvv!("lsx", lsx_vslt_b, is::simd_lt, m128i, i8x16);
impl_vvv!("lsx", lsx_vslt_h, is::simd_lt, m128i, i16x8);
impl_vvv!("lsx", lsx_vslt_w, is::simd_lt, m128i, i32x4);
impl_vvv!("lsx", lsx_vslt_d, is::simd_lt, m128i, i64x2);
impl_vvv!("lsx", lsx_vslt_bu, is::simd_lt, m128i, u8x16);
impl_vvv!("lsx", lsx_vslt_hu, is::simd_lt, m128i, u16x8);
impl_vvv!("lsx", lsx_vslt_wu, is::simd_lt, m128i, u32x4);
impl_vvv!("lsx", lsx_vslt_du, is::simd_lt, m128i, u64x2);
impl_vvv!("lsx", lsx_vsle_b, is::simd_le, m128i, i8x16);
impl_vvv!("lsx", lsx_vsle_h, is::simd_le, m128i, i16x8);
impl_vvv!("lsx", lsx_vsle_w, is::simd_le, m128i, i32x4);
impl_vvv!("lsx", lsx_vsle_d, is::simd_le, m128i, i64x2);
impl_vvv!("lsx", lsx_vsle_bu, is::simd_le, m128i, u8x16);
impl_vvv!("lsx", lsx_vsle_hu, is::simd_le, m128i, u16x8);
impl_vvv!("lsx", lsx_vsle_wu, is::simd_le, m128i, u32x4);
impl_vvv!("lsx", lsx_vsle_du, is::simd_le, m128i, u64x2);
impl_vvv!("lsx", lsx_vmul_b, is::simd_mul, m128i, i8x16);
impl_vvv!("lsx", lsx_vmul_h, is::simd_mul, m128i, i16x8);
impl_vvv!("lsx", lsx_vmul_w, is::simd_mul, m128i, i32x4);
impl_vvv!("lsx", lsx_vmul_d, is::simd_mul, m128i, i64x2);
impl_vvv!("lsx", lsx_vdiv_b, is::simd_div, m128i, i8x16);
impl_vvv!("lsx", lsx_vdiv_h, is::simd_div, m128i, i16x8);
impl_vvv!("lsx", lsx_vdiv_w, is::simd_div, m128i, i32x4);
impl_vvv!("lsx", lsx_vdiv_d, is::simd_div, m128i, i64x2);
impl_vvv!("lsx", lsx_vdiv_bu, is::simd_div, m128i, u8x16);
impl_vvv!("lsx", lsx_vdiv_hu, is::simd_div, m128i, u16x8);
impl_vvv!("lsx", lsx_vdiv_wu, is::simd_div, m128i, u32x4);
impl_vvv!("lsx", lsx_vdiv_du, is::simd_div, m128i, u64x2);
impl_vvv!("lsx", lsx_vmod_b, is::simd_rem, m128i, i8x16);
impl_vvv!("lsx", lsx_vmod_h, is::simd_rem, m128i, i16x8);
impl_vvv!("lsx", lsx_vmod_w, is::simd_rem, m128i, i32x4);
impl_vvv!("lsx", lsx_vmod_d, is::simd_rem, m128i, i64x2);
impl_vvv!("lsx", lsx_vmod_bu, is::simd_rem, m128i, u8x16);
impl_vvv!("lsx", lsx_vmod_hu, is::simd_rem, m128i, u16x8);
impl_vvv!("lsx", lsx_vmod_wu, is::simd_rem, m128i, u32x4);
impl_vvv!("lsx", lsx_vmod_du, is::simd_rem, m128i, u64x2);
impl_vvv!("lsx", lsx_vand_v, is::simd_and, m128i, u8x16);
impl_vvv!("lsx", lsx_vandn_v, ls::simd_andn, m128i, u8x16);
impl_vvv!("lsx", lsx_vor_v, is::simd_or, m128i, u8x16);
impl_vvv!("lsx", lsx_vorn_v, ls::simd_orn, m128i, u8x16);
impl_vvv!("lsx", lsx_vnor_v, ls::simd_nor, m128i, u8x16);
impl_vvv!("lsx", lsx_vxor_v, is::simd_xor, m128i, u8x16);
impl_vvv!("lsx", lsx_vfadd_s, is::simd_add, m128, f32x4);
impl_vvv!("lsx", lsx_vfadd_d, is::simd_add, m128d, f64x2);
impl_vvv!("lsx", lsx_vfsub_s, is::simd_sub, m128, f32x4);
impl_vvv!("lsx", lsx_vfsub_d, is::simd_sub, m128d, f64x2);
impl_vvv!("lsx", lsx_vfmul_s, is::simd_mul, m128, f32x4);
impl_vvv!("lsx", lsx_vfmul_d, is::simd_mul, m128d, f64x2);
impl_vvv!("lsx", lsx_vfdiv_s, is::simd_div, m128, f32x4);
impl_vvv!("lsx", lsx_vfdiv_d, is::simd_div, m128d, f64x2);
impl_vvv!("lsx", lsx_vsll_b, ls::simd_shl, m128i, i8x16);
impl_vvv!("lsx", lsx_vsll_h, ls::simd_shl, m128i, i16x8);
impl_vvv!("lsx", lsx_vsll_w, ls::simd_shl, m128i, i32x4);
impl_vvv!("lsx", lsx_vsll_d, ls::simd_shl, m128i, i64x2);
impl_vvv!("lsx", lsx_vsra_b, ls::simd_shr, m128i, i8x16);
impl_vvv!("lsx", lsx_vsra_h, ls::simd_shr, m128i, i16x8);
impl_vvv!("lsx", lsx_vsra_w, ls::simd_shr, m128i, i32x4);
impl_vvv!("lsx", lsx_vsra_d, ls::simd_shr, m128i, i64x2);
impl_vvv!("lsx", lsx_vsrl_b, ls::simd_shr, m128i, u8x16);
impl_vvv!("lsx", lsx_vsrl_h, ls::simd_shr, m128i, u16x8);
impl_vvv!("lsx", lsx_vsrl_w, ls::simd_shr, m128i, u32x4);
impl_vvv!("lsx", lsx_vsrl_d, ls::simd_shr, m128i, u64x2);
impl_vvv!("lsx", lsx_vbitclr_b, ls::simd_bitclr, m128i, u8x16);
impl_vvv!("lsx", lsx_vbitclr_h, ls::simd_bitclr, m128i, u16x8);
impl_vvv!("lsx", lsx_vbitclr_w, ls::simd_bitclr, m128i, u32x4);
impl_vvv!("lsx", lsx_vbitclr_d, ls::simd_bitclr, m128i, u64x2);
impl_vvv!("lsx", lsx_vbitset_b, ls::simd_bitset, m128i, u8x16);
impl_vvv!("lsx", lsx_vbitset_h, ls::simd_bitset, m128i, u16x8);
impl_vvv!("lsx", lsx_vbitset_w, ls::simd_bitset, m128i, u32x4);
impl_vvv!("lsx", lsx_vbitset_d, ls::simd_bitset, m128i, u64x2);
impl_vvv!("lsx", lsx_vbitrev_b, ls::simd_bitrev, m128i, u8x16);
impl_vvv!("lsx", lsx_vbitrev_h, ls::simd_bitrev, m128i, u16x8);
impl_vvv!("lsx", lsx_vbitrev_w, ls::simd_bitrev, m128i, u32x4);
impl_vvv!("lsx", lsx_vbitrev_d, ls::simd_bitrev, m128i, u64x2);
impl_vvv!("lsx", lsx_vsadd_b, is::simd_saturating_add, m128i, i8x16);
impl_vvv!("lsx", lsx_vsadd_h, is::simd_saturating_add, m128i, i16x8);
impl_vvv!("lsx", lsx_vsadd_w, is::simd_saturating_add, m128i, i32x4);
impl_vvv!("lsx", lsx_vsadd_d, is::simd_saturating_add, m128i, i64x2);
impl_vvv!("lsx", lsx_vsadd_bu, is::simd_saturating_add, m128i, u8x16);
impl_vvv!("lsx", lsx_vsadd_hu, is::simd_saturating_add, m128i, u16x8);
impl_vvv!("lsx", lsx_vsadd_wu, is::simd_saturating_add, m128i, u32x4);
impl_vvv!("lsx", lsx_vsadd_du, is::simd_saturating_add, m128i, u64x2);
impl_vvv!("lsx", lsx_vssub_b, is::simd_saturating_sub, m128i, i8x16);
impl_vvv!("lsx", lsx_vssub_h, is::simd_saturating_sub, m128i, i16x8);
impl_vvv!("lsx", lsx_vssub_w, is::simd_saturating_sub, m128i, i32x4);
impl_vvv!("lsx", lsx_vssub_d, is::simd_saturating_sub, m128i, i64x2);
impl_vvv!("lsx", lsx_vssub_bu, is::simd_saturating_sub, m128i, u8x16);
impl_vvv!("lsx", lsx_vssub_hu, is::simd_saturating_sub, m128i, u16x8);
impl_vvv!("lsx", lsx_vssub_wu, is::simd_saturating_sub, m128i, u32x4);
impl_vvv!("lsx", lsx_vssub_du, is::simd_saturating_sub, m128i, u64x2);
impl_vvv!("lsx", lsx_vadda_b, ls::simd_adda, m128i, i8x16);
impl_vvv!("lsx", lsx_vadda_h, ls::simd_adda, m128i, i16x8);
impl_vvv!("lsx", lsx_vadda_w, ls::simd_adda, m128i, i32x4);
impl_vvv!("lsx", lsx_vadda_d, ls::simd_adda, m128i, i64x2);
impl_vvv!("lsx", lsx_vabsd_b, ls::simd_absd, m128i, i8x16);
impl_vvv!("lsx", lsx_vabsd_h, ls::simd_absd, m128i, i16x8);
impl_vvv!("lsx", lsx_vabsd_w, ls::simd_absd, m128i, i32x4);
impl_vvv!("lsx", lsx_vabsd_d, ls::simd_absd, m128i, i64x2);
impl_vvv!("lsx", lsx_vabsd_bu, ls::simd_absd, m128i, u8x16);
impl_vvv!("lsx", lsx_vabsd_hu, ls::simd_absd, m128i, u16x8);
impl_vvv!("lsx", lsx_vabsd_wu, ls::simd_absd, m128i, u32x4);
impl_vvv!("lsx", lsx_vabsd_du, ls::simd_absd, m128i, u64x2);
impl_vvv!("lsx", lsx_vpickev_b, simd_pickev_b, m128i, i8x16);
impl_vvv!("lsx", lsx_vpickev_h, simd_pickev_h, m128i, i16x8);
impl_vvv!("lsx", lsx_vpickev_w, simd_pickev_w, m128i, i32x4);
impl_vvv!("lsx", lsx_vpickev_d, simd_pickev_d, m128i, i64x2);
impl_vvv!("lsx", lsx_vpickod_b, simd_pickod_b, m128i, i8x16);
impl_vvv!("lsx", lsx_vpickod_h, simd_pickod_h, m128i, i16x8);
impl_vvv!("lsx", lsx_vpickod_w, simd_pickod_w, m128i, i32x4);
impl_vvv!("lsx", lsx_vpickod_d, simd_pickod_d, m128i, i64x2);

impl_vuv!("lsx", lsx_vslli_b, is::simd_shl, m128i, i8x16);
impl_vuv!("lsx", lsx_vslli_h, is::simd_shl, m128i, i16x8);
impl_vuv!("lsx", lsx_vslli_w, is::simd_shl, m128i, i32x4);
impl_vuv!("lsx", lsx_vslli_d, is::simd_shl, m128i, i64x2);
impl_vuv!("lsx", lsx_vsrai_b, is::simd_shr, m128i, i8x16);
impl_vuv!("lsx", lsx_vsrai_h, is::simd_shr, m128i, i16x8);
impl_vuv!("lsx", lsx_vsrai_w, is::simd_shr, m128i, i32x4);
impl_vuv!("lsx", lsx_vsrai_d, is::simd_shr, m128i, i64x2);
impl_vuv!("lsx", lsx_vsrli_b, is::simd_shr, m128i, u8x16);
impl_vuv!("lsx", lsx_vsrli_h, is::simd_shr, m128i, u16x8);
impl_vuv!("lsx", lsx_vsrli_w, is::simd_shr, m128i, u32x4);
impl_vuv!("lsx", lsx_vsrli_d, is::simd_shr, m128i, u64x2);
impl_vuv!("lsx", lsx_vaddi_bu, is::simd_add, m128i, u8x16, 5);
impl_vuv!("lsx", lsx_vaddi_hu, is::simd_add, m128i, u16x8, 5);
impl_vuv!("lsx", lsx_vaddi_wu, is::simd_add, m128i, u32x4, 5);
impl_vuv!("lsx", lsx_vaddi_du, is::simd_add, m128i, u64x2, 5);
impl_vuv!("lsx", lsx_vslti_bu, is::simd_lt, m128i, u8x16, 5);
impl_vuv!("lsx", lsx_vslti_hu, is::simd_lt, m128i, u16x8, 5);
impl_vuv!("lsx", lsx_vslti_wu, is::simd_lt, m128i, u32x4, 5);
impl_vuv!("lsx", lsx_vslti_du, is::simd_lt, m128i, u64x2, 5);
impl_vuv!("lsx", lsx_vslei_bu, is::simd_le, m128i, u8x16, 5);
impl_vuv!("lsx", lsx_vslei_hu, is::simd_le, m128i, u16x8, 5);
impl_vuv!("lsx", lsx_vslei_wu, is::simd_le, m128i, u32x4, 5);
impl_vuv!("lsx", lsx_vslei_du, is::simd_le, m128i, u64x2, 5);
impl_vuv!("lsx", lsx_vmaxi_bu, cs::simd_imax, m128i, u8x16, 5);
impl_vuv!("lsx", lsx_vmaxi_hu, cs::simd_imax, m128i, u16x8, 5);
impl_vuv!("lsx", lsx_vmaxi_wu, cs::simd_imax, m128i, u32x4, 5);
impl_vuv!("lsx", lsx_vmaxi_du, cs::simd_imax, m128i, u64x2, 5);
impl_vuv!("lsx", lsx_vmini_bu, cs::simd_imin, m128i, u8x16, 5);
impl_vuv!("lsx", lsx_vmini_hu, cs::simd_imin, m128i, u16x8, 5);
impl_vuv!("lsx", lsx_vmini_wu, cs::simd_imin, m128i, u32x4, 5);
impl_vuv!("lsx", lsx_vmini_du, cs::simd_imin, m128i, u64x2, 5);

impl_vug!("lsx", lsx_vpickve2gr_b, is::simd_extract, m128i, i8x16, i32, 4);
impl_vug!("lsx", lsx_vpickve2gr_h, is::simd_extract, m128i, i16x8, i32, 3);
impl_vug!("lsx", lsx_vpickve2gr_w, is::simd_extract, m128i, i32x4, i32, 2);
impl_vug!("lsx", lsx_vpickve2gr_d, is::simd_extract, m128i, i64x2, i64, 1);
impl_vug!("lsx", lsx_vpickve2gr_bu, is::simd_extract, m128i, u8x16, u32, 4);
impl_vug!("lsx", lsx_vpickve2gr_hu, is::simd_extract, m128i, u16x8, u32, 3);
impl_vug!("lsx", lsx_vpickve2gr_wu, is::simd_extract, m128i, u32x4, u32, 2);
impl_vug!("lsx", lsx_vpickve2gr_du, is::simd_extract, m128i, u64x2, u64, 1);

impl_vsv!("lsx", lsx_vseqi_b, is::simd_eq, m128i, i8x16, 5);
impl_vsv!("lsx", lsx_vseqi_h, is::simd_eq, m128i, i16x8, 5);
impl_vsv!("lsx", lsx_vseqi_w, is::simd_eq, m128i, i32x4, 5);
impl_vsv!("lsx", lsx_vseqi_d, is::simd_eq, m128i, i64x2, 5);
impl_vsv!("lsx", lsx_vslti_b, is::simd_lt, m128i, i8x16, 5);
impl_vsv!("lsx", lsx_vslti_h, is::simd_lt, m128i, i16x8, 5);
impl_vsv!("lsx", lsx_vslti_w, is::simd_lt, m128i, i32x4, 5);
impl_vsv!("lsx", lsx_vslti_d, is::simd_lt, m128i, i64x2, 5);
impl_vsv!("lsx", lsx_vslei_b, is::simd_le, m128i, i8x16, 5);
impl_vsv!("lsx", lsx_vslei_h, is::simd_le, m128i, i16x8, 5);
impl_vsv!("lsx", lsx_vslei_w, is::simd_le, m128i, i32x4, 5);
impl_vsv!("lsx", lsx_vslei_d, is::simd_le, m128i, i64x2, 5);
impl_vsv!("lsx", lsx_vmaxi_b, cs::simd_imax, m128i, i8x16, 5);
impl_vsv!("lsx", lsx_vmaxi_h, cs::simd_imax, m128i, i16x8, 5);
impl_vsv!("lsx", lsx_vmaxi_w, cs::simd_imax, m128i, i32x4, 5);
impl_vsv!("lsx", lsx_vmaxi_d, cs::simd_imax, m128i, i64x2, 5);
impl_vsv!("lsx", lsx_vmini_b, cs::simd_imin, m128i, i8x16, 5);
impl_vsv!("lsx", lsx_vmini_h, cs::simd_imin, m128i, i16x8, 5);
impl_vsv!("lsx", lsx_vmini_w, cs::simd_imin, m128i, i32x4, 5);
impl_vsv!("lsx", lsx_vmini_d, cs::simd_imin, m128i, i64x2, 5);

impl_vvvv!("lsx", lsx_vmadd_b, ls::simd_madd, m128i, i8x16);
impl_vvvv!("lsx", lsx_vmadd_h, ls::simd_madd, m128i, i16x8);
impl_vvvv!("lsx", lsx_vmadd_w, ls::simd_madd, m128i, i32x4);
impl_vvvv!("lsx", lsx_vmadd_d, ls::simd_madd, m128i, i64x2);
impl_vvvv!("lsx", lsx_vmsub_b, ls::simd_msub, m128i, i8x16);
impl_vvvv!("lsx", lsx_vmsub_h, ls::simd_msub, m128i, i16x8);
impl_vvvv!("lsx", lsx_vmsub_w, ls::simd_msub, m128i, i32x4);
impl_vvvv!("lsx", lsx_vmsub_d, ls::simd_msub, m128i, i64x2);
impl_vvvv!("lsx", lsx_vfmadd_s, is::simd_fma, m128, f32x4);
impl_vvvv!("lsx", lsx_vfmadd_d, is::simd_fma, m128d, f64x2);
impl_vvvv!("lsx", lsx_vfmsub_s, ls::simd_fmsub, m128, f32x4);
impl_vvvv!("lsx", lsx_vfmsub_d, ls::simd_fmsub, m128d, f64x2);
impl_vvvv!("lsx", lsx_vfnmadd_s, ls::simd_fnmadd, m128, f32x4);
impl_vvvv!("lsx", lsx_vfnmadd_d, ls::simd_fnmadd, m128d, f64x2);
impl_vvvv!("lsx", lsx_vfnmsub_s, ls::simd_fnmsub, m128, f32x4);
impl_vvvv!("lsx", lsx_vfnmsub_d, ls::simd_fnmsub, m128d, f64x2);

impl_vugv!("lsx", lsx_vinsgr2vr_b, is::simd_insert, m128i, i8x16, i32, 4);
impl_vugv!("lsx", lsx_vinsgr2vr_h, is::simd_insert, m128i, i16x8, i32, 3);
impl_vugv!("lsx", lsx_vinsgr2vr_w, is::simd_insert, m128i, i32x4, i32, 2);
impl_vugv!("lsx", lsx_vinsgr2vr_d, is::simd_insert, m128i, i64x2, i64, 1);
