use fearless_simd::Simd;
pub type F64s<S> = <S as Simd>::f64s;
pub type U64s<S> = <S as Simd>::u64s;
pub type I64s<S> = <S as Simd>::i64s;
pub type M64s<S> = <S as Simd>::mask64s;
pub type F32s<S> = <S as Simd>::f32s;
pub type U32s<S> = <S as Simd>::u32s;
pub type I32s<S> = <S as Simd>::i32s;
pub type M32s<S> = <S as Simd>::mask32s;
use fearless_simd::prelude::*;
#[inline(always)]
pub fn mla<S: Simd, V: SimdFloat<S>>(_simd: S, x: V, y: V, z: V) -> V {
x.mul_add_precise(y, z)
}
#[inline(always)]
pub fn mul_sub<S: Simd, V: SimdFloat<S>>(_simd: S, x: V, y: V, z: V) -> V {
x.mul_sub_precise(y, z)
}
#[inline(always)]
pub fn neg_mul_add<S: Simd, V: SimdFloat<S>>(_simd: S, x: V, y: V, z: V) -> V {
(-x).mul_add_precise(y, z)
}
#[inline(always)]
pub fn hw_sqrt<S: Simd, V: SimdFloat<S>>(_simd: S, x: V) -> V {
x.sqrt()
}
#[allow(clippy::too_many_arguments)]
#[inline(always)]
pub fn poly2<S: Simd, V: SimdFloat<S> + Copy>(
simd: S,
x: V,
x2: V,
x4: V,
c1: V::Element,
c0: V::Element,
) -> V {
let _ = (x2, x4);
mla(simd, x, V::splat(simd, c1), V::splat(simd, c0))
}
#[allow(clippy::too_many_arguments)]
#[inline(always)]
pub fn poly3<S: Simd, V: SimdFloat<S> + Copy>(
simd: S,
x: V,
x2: V,
x4: V,
c2: V::Element,
c1: V::Element,
c0: V::Element,
) -> V {
mla(simd, x2, V::splat(simd, c2), poly2(simd, x, x2, x4, c1, c0))
}
#[allow(clippy::too_many_arguments)]
#[inline(always)]
pub fn poly4<S: Simd, V: SimdFloat<S> + Copy>(
simd: S,
x: V,
x2: V,
x4: V,
c3: V::Element,
c2: V::Element,
c1: V::Element,
c0: V::Element,
) -> V {
let _ = x4;
mla(
simd,
x2,
mla(simd, x, V::splat(simd, c3), V::splat(simd, c2)),
mla(simd, x, V::splat(simd, c1), V::splat(simd, c0)),
)
}
#[allow(clippy::too_many_arguments)]
#[inline(always)]
pub fn poly5<S: Simd, V: SimdFloat<S> + Copy>(
simd: S,
x: V,
x2: V,
x4: V,
c4: V::Element,
c3: V::Element,
c2: V::Element,
c1: V::Element,
c0: V::Element,
) -> V {
mla(
simd,
x4,
V::splat(simd, c4),
poly4(simd, x, x2, x4, c3, c2, c1, c0),
)
}
#[allow(clippy::too_many_arguments)]
#[inline(always)]
pub fn poly6<S: Simd, V: SimdFloat<S> + Copy>(
simd: S,
x: V,
x2: V,
x4: V,
c5: V::Element,
c4: V::Element,
c3: V::Element,
c2: V::Element,
c1: V::Element,
c0: V::Element,
) -> V {
mla(
simd,
x4,
poly2(simd, x, x2, x4, c5, c4),
poly4(simd, x, x2, x4, c3, c2, c1, c0),
)
}
#[allow(clippy::too_many_arguments)]
#[inline(always)]
pub fn poly7<S: Simd, V: SimdFloat<S> + Copy>(
simd: S,
x: V,
x2: V,
x4: V,
c6: V::Element,
c5: V::Element,
c4: V::Element,
c3: V::Element,
c2: V::Element,
c1: V::Element,
c0: V::Element,
) -> V {
mla(
simd,
x4,
poly3(simd, x, x2, x4, c6, c5, c4),
poly4(simd, x, x2, x4, c3, c2, c1, c0),
)
}
#[allow(clippy::too_many_arguments)]
#[inline(always)]
pub fn poly8<S: Simd, V: SimdFloat<S> + Copy>(
simd: S,
x: V,
x2: V,
x4: V,
c7: V::Element,
c6: V::Element,
c5: V::Element,
c4: V::Element,
c3: V::Element,
c2: V::Element,
c1: V::Element,
c0: V::Element,
) -> V {
mla(
simd,
x4,
poly4(simd, x, x2, x4, c7, c6, c5, c4),
poly4(simd, x, x2, x4, c3, c2, c1, c0),
)
}
#[allow(clippy::too_many_arguments)]
#[inline(always)]
pub fn poly9<S: Simd, V: SimdFloat<S> + Copy>(
simd: S,
x: V,
x2: V,
x4: V,
x8: V,
c8: V::Element,
c7: V::Element,
c6: V::Element,
c5: V::Element,
c4: V::Element,
c3: V::Element,
c2: V::Element,
c1: V::Element,
c0: V::Element,
) -> V {
mla(
simd,
x8,
V::splat(simd, c8),
poly8(simd, x, x2, x4, c7, c6, c5, c4, c3, c2, c1, c0),
)
}
#[allow(clippy::too_many_arguments)]
#[inline(always)]
pub fn poly10<S: Simd, V: SimdFloat<S> + Copy>(
simd: S,
x: V,
x2: V,
x4: V,
x8: V,
c9: V::Element,
c8: V::Element,
c7: V::Element,
c6: V::Element,
c5: V::Element,
c4: V::Element,
c3: V::Element,
c2: V::Element,
c1: V::Element,
c0: V::Element,
) -> V {
mla(
simd,
x8,
poly2(simd, x, x2, x4, c9, c8),
poly8(simd, x, x2, x4, c7, c6, c5, c4, c3, c2, c1, c0),
)
}
#[allow(clippy::too_many_arguments)]
#[inline(always)]
pub fn poly11<S: Simd, V: SimdFloat<S> + Copy>(
simd: S,
x: V,
x2: V,
x4: V,
x8: V,
ca: V::Element,
c9: V::Element,
c8: V::Element,
c7: V::Element,
c6: V::Element,
c5: V::Element,
c4: V::Element,
c3: V::Element,
c2: V::Element,
c1: V::Element,
c0: V::Element,
) -> V {
mla(
simd,
x8,
poly3(simd, x, x2, x4, ca, c9, c8),
poly8(simd, x, x2, x4, c7, c6, c5, c4, c3, c2, c1, c0),
)
}
#[allow(clippy::too_many_arguments)]
#[inline(always)]
pub fn poly12<S: Simd, V: SimdFloat<S> + Copy>(
simd: S,
x: V,
x2: V,
x4: V,
x8: V,
cb: V::Element,
ca: V::Element,
c9: V::Element,
c8: V::Element,
c7: V::Element,
c6: V::Element,
c5: V::Element,
c4: V::Element,
c3: V::Element,
c2: V::Element,
c1: V::Element,
c0: V::Element,
) -> V {
mla(
simd,
x8,
poly4(simd, x, x2, x4, cb, ca, c9, c8),
poly8(simd, x, x2, x4, c7, c6, c5, c4, c3, c2, c1, c0),
)
}
#[allow(clippy::too_many_arguments)]
#[inline(always)]
pub fn poly13<S: Simd, V: SimdFloat<S> + Copy>(
simd: S,
x: V,
x2: V,
x4: V,
x8: V,
cc: V::Element,
cb: V::Element,
ca: V::Element,
c9: V::Element,
c8: V::Element,
c7: V::Element,
c6: V::Element,
c5: V::Element,
c4: V::Element,
c3: V::Element,
c2: V::Element,
c1: V::Element,
c0: V::Element,
) -> V {
mla(
simd,
x8,
poly5(simd, x, x2, x4, cc, cb, ca, c9, c8),
poly8(simd, x, x2, x4, c7, c6, c5, c4, c3, c2, c1, c0),
)
}
#[allow(clippy::too_many_arguments)]
#[inline(always)]
pub fn poly14<S: Simd, V: SimdFloat<S> + Copy>(
simd: S,
x: V,
x2: V,
x4: V,
x8: V,
cd: V::Element,
cc: V::Element,
cb: V::Element,
ca: V::Element,
c9: V::Element,
c8: V::Element,
c7: V::Element,
c6: V::Element,
c5: V::Element,
c4: V::Element,
c3: V::Element,
c2: V::Element,
c1: V::Element,
c0: V::Element,
) -> V {
mla(
simd,
x8,
poly6(simd, x, x2, x4, cd, cc, cb, ca, c9, c8),
poly8(simd, x, x2, x4, c7, c6, c5, c4, c3, c2, c1, c0),
)
}
#[allow(clippy::too_many_arguments)]
#[inline(always)]
pub fn poly15<S: Simd, V: SimdFloat<S> + Copy>(
simd: S,
x: V,
x2: V,
x4: V,
x8: V,
ce: V::Element,
cd: V::Element,
cc: V::Element,
cb: V::Element,
ca: V::Element,
c9: V::Element,
c8: V::Element,
c7: V::Element,
c6: V::Element,
c5: V::Element,
c4: V::Element,
c3: V::Element,
c2: V::Element,
c1: V::Element,
c0: V::Element,
) -> V {
mla(
simd,
x8,
poly7(simd, x, x2, x4, ce, cd, cc, cb, ca, c9, c8),
poly8(simd, x, x2, x4, c7, c6, c5, c4, c3, c2, c1, c0),
)
}
#[allow(clippy::too_many_arguments)]
#[inline(always)]
pub fn poly16<S: Simd, V: SimdFloat<S> + Copy>(
simd: S,
x: V,
x2: V,
x4: V,
x8: V,
cf: V::Element,
ce: V::Element,
cd: V::Element,
cc: V::Element,
cb: V::Element,
ca: V::Element,
c9: V::Element,
c8: V::Element,
c7: V::Element,
c6: V::Element,
c5: V::Element,
c4: V::Element,
c3: V::Element,
c2: V::Element,
c1: V::Element,
c0: V::Element,
) -> V {
mla(
simd,
x8,
poly8(simd, x, x2, x4, cf, ce, cd, cc, cb, ca, c9, c8),
poly8(simd, x, x2, x4, c7, c6, c5, c4, c3, c2, c1, c0),
)
}
#[allow(clippy::too_many_arguments)]
#[inline(always)]
pub fn poly17<S: Simd, V: SimdFloat<S> + Copy>(
simd: S,
x: V,
x2: V,
x4: V,
x8: V,
x16: V,
d0: V::Element,
cf: V::Element,
ce: V::Element,
cd: V::Element,
cc: V::Element,
cb: V::Element,
ca: V::Element,
c9: V::Element,
c8: V::Element,
c7: V::Element,
c6: V::Element,
c5: V::Element,
c4: V::Element,
c3: V::Element,
c2: V::Element,
c1: V::Element,
c0: V::Element,
) -> V {
mla(
simd,
x16,
V::splat(simd, d0),
poly16(
simd, x, x2, x4, x8, cf, ce, cd, cc, cb, ca, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0,
),
)
}
#[allow(clippy::too_many_arguments)]
#[inline(always)]
pub fn poly18<S: Simd, V: SimdFloat<S> + Copy>(
simd: S,
x: V,
x2: V,
x4: V,
x8: V,
x16: V,
d1: V::Element,
d0: V::Element,
cf: V::Element,
ce: V::Element,
cd: V::Element,
cc: V::Element,
cb: V::Element,
ca: V::Element,
c9: V::Element,
c8: V::Element,
c7: V::Element,
c6: V::Element,
c5: V::Element,
c4: V::Element,
c3: V::Element,
c2: V::Element,
c1: V::Element,
c0: V::Element,
) -> V {
mla(
simd,
x16,
poly2(simd, x, x2, x4, d1, d0),
poly16(
simd, x, x2, x4, x8, cf, ce, cd, cc, cb, ca, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0,
),
)
}
#[allow(clippy::too_many_arguments)]
#[inline(always)]
pub fn poly19<S: Simd, V: SimdFloat<S> + Copy>(
simd: S,
x: V,
x2: V,
x4: V,
x8: V,
x16: V,
d2: V::Element,
d1: V::Element,
d0: V::Element,
cf: V::Element,
ce: V::Element,
cd: V::Element,
cc: V::Element,
cb: V::Element,
ca: V::Element,
c9: V::Element,
c8: V::Element,
c7: V::Element,
c6: V::Element,
c5: V::Element,
c4: V::Element,
c3: V::Element,
c2: V::Element,
c1: V::Element,
c0: V::Element,
) -> V {
mla(
simd,
x16,
poly3(simd, x, x2, x4, d2, d1, d0),
poly16(
simd, x, x2, x4, x8, cf, ce, cd, cc, cb, ca, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0,
),
)
}
#[allow(clippy::too_many_arguments)]
#[inline(always)]
pub fn poly20<S: Simd, V: SimdFloat<S> + Copy>(
simd: S,
x: V,
x2: V,
x4: V,
x8: V,
x16: V,
d3: V::Element,
d2: V::Element,
d1: V::Element,
d0: V::Element,
cf: V::Element,
ce: V::Element,
cd: V::Element,
cc: V::Element,
cb: V::Element,
ca: V::Element,
c9: V::Element,
c8: V::Element,
c7: V::Element,
c6: V::Element,
c5: V::Element,
c4: V::Element,
c3: V::Element,
c2: V::Element,
c1: V::Element,
c0: V::Element,
) -> V {
mla(
simd,
x16,
poly4(simd, x, x2, x4, d3, d2, d1, d0),
poly16(
simd, x, x2, x4, x8, cf, ce, cd, cc, cb, ca, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0,
),
)
}
#[allow(clippy::too_many_arguments)]
#[inline(always)]
pub fn poly21<S: Simd, V: SimdFloat<S> + Copy>(
simd: S,
x: V,
x2: V,
x4: V,
x8: V,
x16: V,
d4: V::Element,
d3: V::Element,
d2: V::Element,
d1: V::Element,
d0: V::Element,
cf: V::Element,
ce: V::Element,
cd: V::Element,
cc: V::Element,
cb: V::Element,
ca: V::Element,
c9: V::Element,
c8: V::Element,
c7: V::Element,
c6: V::Element,
c5: V::Element,
c4: V::Element,
c3: V::Element,
c2: V::Element,
c1: V::Element,
c0: V::Element,
) -> V {
mla(
simd,
x16,
poly5(simd, x, x2, x4, d4, d3, d2, d1, d0),
poly16(
simd, x, x2, x4, x8, cf, ce, cd, cc, cb, ca, c9, c8, c7, c6, c5, c4, c3, c2, c1, c0,
),
)
}