Skip to content

Commit

Permalink
Merge pull request #2050 from lioncash/vfcmplt
Browse files Browse the repository at this point in the history
IR: Handle 256-bit VFCMPLT/VFCMPGT/VFCMPLE
  • Loading branch information
Sonicadvance1 committed Oct 4, 2022
2 parents a67f742 + 280b15b commit 25a8a00
Show file tree
Hide file tree
Showing 3 changed files with 354 additions and 144 deletions.
69 changes: 45 additions & 24 deletions External/FEXCore/Source/Interface/Core/Interpreter/VectorOps.cpp
Expand Up @@ -1163,89 +1163,110 @@ DEF_OP(VFCMPNEQ) {
}

DEF_OP(VFCMPLT) {
auto Op = IROp->C<IR::IROp_VFCMPLT>();
const auto Op = IROp->C<IR::IROp_VFCMPLT>();
const uint8_t OpSize = IROp->Size;

void *Src1 = GetSrc<void*>(Data->SSAData, Op->Vector1);
void *Src2 = GetSrc<void*>(Data->SSAData, Op->Vector2);

const auto Func = [](auto a, auto b) { return a < b ? ~0ULL : 0; };

uint8_t Tmp[16];
const uint8_t Elements = OpSize / Op->Header.ElementSize;
uint8_t Tmp[Core::CPUState::XMM_AVX_REG_SIZE];

if (Op->Header.ElementSize == OpSize) {
switch (Op->Header.ElementSize) {
const uint8_t ElementSize = Op->Header.ElementSize;
const uint8_t Elements = OpSize / ElementSize;
const auto IsScalar = ElementSize == OpSize;

if (IsScalar) {
switch (ElementSize) {
DO_SCALAR_COMPARE_OP(4, float, uint32_t, Func);
DO_SCALAR_COMPARE_OP(8, double, uint64_t, Func);
default: LOGMAN_MSG_A_FMT("Unsupported elementSize: {}", Op->Header.ElementSize);
default:
LOGMAN_MSG_A_FMT("Unsupported elementSize: {}", ElementSize);
break;
}
}
else {
switch (Op->Header.ElementSize) {
switch (ElementSize) {
DO_VECTOR_COMPARE_OP(4, float, uint32_t, Func);
DO_VECTOR_COMPARE_OP(8, double, uint64_t, Func);
default: LOGMAN_MSG_A_FMT("Unsupported elementSize: {}", Op->Header.ElementSize);
default:
LOGMAN_MSG_A_FMT("Unsupported elementSize: {}", ElementSize);
break;
}
}

memcpy(GDP, Tmp, OpSize);
}

DEF_OP(VFCMPGT) {
auto Op = IROp->C<IR::IROp_VFCMPLT>();
const auto Op = IROp->C<IR::IROp_VFCMPLT>();
const uint8_t OpSize = IROp->Size;

void *Src1 = GetSrc<void*>(Data->SSAData, Op->Vector1);
void *Src2 = GetSrc<void*>(Data->SSAData, Op->Vector2);

const auto Func = [](auto a, auto b) { return a > b ? ~0ULL : 0; };

uint8_t Tmp[16];
const uint8_t Elements = OpSize / Op->Header.ElementSize;
uint8_t Tmp[Core::CPUState::XMM_AVX_REG_SIZE];

if (Op->Header.ElementSize == OpSize) {
switch (Op->Header.ElementSize) {
const uint8_t ElementSize = Op->Header.ElementSize;
const uint8_t Elements = OpSize / ElementSize;
const auto IsScalar = ElementSize == OpSize;

if (IsScalar) {
switch (ElementSize) {
DO_SCALAR_COMPARE_OP(4, float, uint32_t, Func);
DO_SCALAR_COMPARE_OP(8, double, uint64_t, Func);
default: LOGMAN_MSG_A_FMT("Unsupported elementSize: {}", Op->Header.ElementSize);
default:
LOGMAN_MSG_A_FMT("Unsupported elementSize: {}", ElementSize);
break;
}
}
else {
switch (Op->Header.ElementSize) {
switch (ElementSize) {
DO_VECTOR_COMPARE_OP(4, float, uint32_t, Func);
DO_VECTOR_COMPARE_OP(8, double, uint64_t, Func);
default: LOGMAN_MSG_A_FMT("Unsupported elementSize: {}", Op->Header.ElementSize);
default:
LOGMAN_MSG_A_FMT("Unsupported elementSize: {}", ElementSize);
break;
}
}

memcpy(GDP, Tmp, OpSize);
}

DEF_OP(VFCMPLE) {
auto Op = IROp->C<IR::IROp_VFCMPLE>();
const auto Op = IROp->C<IR::IROp_VFCMPLE>();
const uint8_t OpSize = IROp->Size;

void *Src1 = GetSrc<void*>(Data->SSAData, Op->Vector1);
void *Src2 = GetSrc<void*>(Data->SSAData, Op->Vector2);

const auto Func = [](auto a, auto b) { return a <= b ? ~0ULL : 0; };

uint8_t Tmp[16];
const uint8_t Elements = OpSize / Op->Header.ElementSize;
uint8_t Tmp[Core::CPUState::XMM_AVX_REG_SIZE];

if (Op->Header.ElementSize == OpSize) {
switch (Op->Header.ElementSize) {
const uint8_t ElementSize = Op->Header.ElementSize;
const uint8_t Elements = OpSize / ElementSize;
const auto IsScalar = ElementSize == OpSize;

if (IsScalar) {
switch (ElementSize) {
DO_SCALAR_COMPARE_OP(4, float, uint32_t, Func);
DO_SCALAR_COMPARE_OP(8, double, uint64_t, Func);
default: LOGMAN_MSG_A_FMT("Unsupported elementSize: {}", Op->Header.ElementSize);
default:
LOGMAN_MSG_A_FMT("Unsupported elementSize: {}", ElementSize);
break;
}
}
else {
switch (Op->Header.ElementSize) {
switch (ElementSize) {
DO_VECTOR_COMPARE_OP(4, float, uint32_t, Func);
DO_VECTOR_COMPARE_OP(8, double, uint64_t, Func);
default: LOGMAN_MSG_A_FMT("Unsupported elementSize: {}", Op->Header.ElementSize);
default:
LOGMAN_MSG_A_FMT("Unsupported elementSize: {}", ElementSize);
break;
}
}

Expand Down

0 comments on commit 25a8a00

Please sign in to comment.