diff --git a/External/FEXCore/Source/Interface/Core/Interpreter/VectorOps.cpp b/External/FEXCore/Source/Interface/Core/Interpreter/VectorOps.cpp index 7a4ba3454..b8ee08d41 100644 --- a/External/FEXCore/Source/Interface/Core/Interpreter/VectorOps.cpp +++ b/External/FEXCore/Source/Interface/Core/Interpreter/VectorOps.cpp @@ -23,7 +23,7 @@ DEF_OP(VectorImm) { auto Op = IROp->C(); uint8_t OpSize = IROp->Size; - uint8_t Tmp[16]; + uint8_t Tmp[32]; uint8_t Elements = OpSize / Op->Header.ElementSize; uint8_t Imm = Op->Immediate; diff --git a/External/FEXCore/Source/Interface/Core/JIT/Arm64/VectorOps.cpp b/External/FEXCore/Source/Interface/Core/JIT/Arm64/VectorOps.cpp index 27d96a5cb..7eba50d2b 100644 --- a/External/FEXCore/Source/Interface/Core/JIT/Arm64/VectorOps.cpp +++ b/External/FEXCore/Source/Interface/Core/JIT/Arm64/VectorOps.cpp @@ -40,15 +40,37 @@ DEF_OP(VectorImm) { auto Op = IROp->C(); const uint8_t OpSize = IROp->Size; - const uint8_t Elements = OpSize / Op->Header.ElementSize; + const uint8_t ElementSize = Op->Header.ElementSize; + const uint8_t Elements = OpSize / ElementSize; - if (Op->Header.ElementSize == 8) { - // movi with 64bit element size doesn't do what we want here - LoadConstant(TMP1.X(), Op->Immediate); - dup(GetDst(Node).V2D(), TMP1.X()); - } - else { - movi(GetDst(Node).VCast(OpSize * 8, Elements), Op->Immediate); + if (CanUseSVE) { + const auto Dst = [&] { + const auto Tmp = GetDst(Node).Z(); + switch (ElementSize) { + case 1: + return Tmp.VnB(); + case 2: + return Tmp.VnH(); + case 4: + return Tmp.VnS(); + case 8: + return Tmp.VnD(); + default: + LOGMAN_MSG_A_FMT("Unhandled element size: {}", ElementSize); + return Tmp; + } + }(); + + dup(Dst, Op->Immediate); + } else { + if (ElementSize == 8) { + // movi with 64bit element size doesn't do what we want here + LoadConstant(TMP1.X(), Op->Immediate); + dup(GetDst(Node).V2D(), TMP1.X()); + } + else { + movi(GetDst(Node).VCast(OpSize * 8, Elements), Op->Immediate); + } } } diff --git a/External/FEXCore/Source/Interface/Core/JIT/x86_64/VectorOps.cpp b/External/FEXCore/Source/Interface/Core/JIT/x86_64/VectorOps.cpp index e54f472f2..968c673d5 100644 --- a/External/FEXCore/Source/Interface/Core/JIT/x86_64/VectorOps.cpp +++ b/External/FEXCore/Source/Interface/Core/JIT/x86_64/VectorOps.cpp @@ -24,10 +24,11 @@ DEF_OP(VectorZero) { DEF_OP(VectorImm) { auto Op = IROp->C(); - uint8_t OpSize = IROp->Size; - auto Dst = GetDst(Node); - uint64_t Imm = Op->Immediate; + const uint8_t OpSize = IROp->Size; + const uint64_t Imm = Op->Immediate; + + const auto Dst = GetDst(Node); uint64_t Element{}; switch (Op->Header.ElementSize) { @@ -61,9 +62,13 @@ DEF_OP(VectorImm) { mov(TMP1, Element); vmovq(Dst, TMP1); - if (OpSize == 16) { - // Duplicate to the upper 64bits if we are 128bits - movddup(Dst, Dst); + + if (OpSize >= 16) { + LOGMAN_THROW_AA_FMT(OpSize == 16 || OpSize == 32, + "Can't handle a vector of size: {}", OpSize); + + // Duplicate into upper elements + vbroadcastsd(ToYMM(Dst), Dst); } }