Skip to content

Commit

Permalink
AVX128: Implement support for vpsubsw
Browse files Browse the repository at this point in the history
  • Loading branch information
Sonicadvance1 committed Jun 18, 2024
1 parent 1849c79 commit b7f8202
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions FEXCore/Source/Interface/Core/OpcodeDispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,9 @@ class OpDispatchBuilder final : public IREmitter {
template<size_t ElementSize>
void AVX128_VPHSUB(OpcodeArgs);

Ref AVX128_PHSUBSWImpl(Ref Src1, Ref Src2);
void AVX128_VPHSUBSW(OpcodeArgs);

// End of AVX 128-bit implementation

void InvalidOp(OpcodeArgs);
Expand Down
16 changes: 15 additions & 1 deletion FEXCore/Source/Interface/Core/OpcodeDispatcher/AVX_128.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ void OpDispatchBuilder::InstallAVX128Handlers() {

{OPD(2, 0b01, 0x05), 1, &OpDispatchBuilder::AVX128_VPHSUB<2>},
{OPD(2, 0b01, 0x06), 1, &OpDispatchBuilder::AVX128_VPHSUB<4>},
// TODO: {OPD(2, 0b01, 0x07), 1, &OpDispatchBuilder::VPHSUBSWOp},
{OPD(2, 0b01, 0x07), 1, &OpDispatchBuilder::AVX128_VPHSUBSW},

{OPD(2, 0b01, 0x08), 1, &OpDispatchBuilder::AVX128_VPSIGN<1>},
{OPD(2, 0b01, 0x09), 1, &OpDispatchBuilder::AVX128_VPSIGN<2>},
Expand Down Expand Up @@ -1791,4 +1791,18 @@ void OpDispatchBuilder::AVX128_VPHSUB(OpcodeArgs) {
AVX128_VectorBinaryImpl(Op, GetDstSize(Op), ElementSize, [this](size_t _ElementSize, Ref Src1, Ref Src2) { return AVX128_PHSUBImpl(Src1, Src2, _ElementSize); });
}

Ref OpDispatchBuilder::AVX128_PHSUBSWImpl(Ref Src1, Ref Src2) {
const uint8_t ElementSize = 2;

auto Even = _VUnZip(OpSize::i128Bit, ElementSize, Src1, Src2);
auto Odd = _VUnZip2(OpSize::i128Bit, ElementSize, Src1, Src2);

// Saturate back down to the result
return _VSQSub(OpSize::i128Bit, ElementSize, Even, Odd);
}

void OpDispatchBuilder::AVX128_VPHSUBSW(OpcodeArgs) {
AVX128_VectorBinaryImpl(Op, GetDstSize(Op), OpSize::i16Bit, [this](size_t _ElementSize, Ref Src1, Ref Src2) { return AVX128_PHSUBSWImpl(Src1, Src2); });
}

} // namespace FEXCore::IR

0 comments on commit b7f8202

Please sign in to comment.