SPU LLVM: improve MPYH instruction

Rewritten to use 16-bit multiplication, as in SPU ASMJIT.
This commit is contained in:
Nekotekina 2021-05-13 23:14:27 +03:00
parent cdf25d902a
commit 6dca588370

View File

@ -6255,19 +6255,19 @@ public:
} }
template <typename TA, typename TB> template <typename TA, typename TB>
static auto mpyh(TA&& a, TB&& b) auto mpyh(TA&& a, TB&& b)
{ {
return (std::forward<TA>(a) >> 16) * (std::forward<TB>(b) << 16); return bitcast<u32[4]>(bitcast<u16[8]>((std::forward<TA>(a) >> 16)) * bitcast<u16[8]>(std::forward<TB>(b))) << 16;
} }
template <typename TA, typename TB> template <typename TA, typename TB>
static auto mpyu(TA&& a, TB&& b) auto mpyu(TA&& a, TB&& b)
{ {
return (std::forward<TA>(a) << 16 >> 16) * (std::forward<TB>(b) << 16 >> 16); return (std::forward<TA>(a) << 16 >> 16) * (std::forward<TB>(b) << 16 >> 16);
} }
template <typename TA, typename TB> template <typename TA, typename TB>
static auto fm(TA&& a, TB&& b) auto fm(TA&& a, TB&& b)
{ {
return (std::forward<TA>(a)) * (std::forward<TB>(b)); return (std::forward<TA>(a)) * (std::forward<TB>(b));
} }