From fc998bbc3945cdd296c850ebd648792ef6b02239 Mon Sep 17 00:00:00 2001 From: wannacu Date: Fri, 29 Dec 2023 15:10:33 +0800 Subject: [PATCH] JIT: Fixes broken register in VTBX1 If the Dst register is allocated as VectorIndices or VectorTable, using Dst as an operand to perform the tbx operation will result in an error. For example: %131(FPR0) i128 = LoadNamedVectorIndexedConstant u8:Tmp:RegisterSize, #0x6, #0xaa0 %132(FPR0) i128 = VTBX1 u8:Tmp:RegisterSize, %129(FPRFixed6) i32v4, %126(FPRFixed10) i16v8, %131(FPR0) i128 Since the tbx instruction's destination register is also the original operand, this is consistent with the semantics of VTBX1. Therefore, directly using VectorSrcDst as the destination operand for the tbx instruction is safe. --- .../Interface/Core/JIT/Arm64/VectorOps.cpp | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/FEXCore/Source/Interface/Core/JIT/Arm64/VectorOps.cpp b/FEXCore/Source/Interface/Core/JIT/Arm64/VectorOps.cpp index 00214c3ee9..446a6a8085 100644 --- a/FEXCore/Source/Interface/Core/JIT/Arm64/VectorOps.cpp +++ b/FEXCore/Source/Interface/Core/JIT/Arm64/VectorOps.cpp @@ -5006,6 +5006,27 @@ DEF_OP(VTBX1) { const auto VectorIndices = GetVReg(Op->VectorIndices.ID()); const auto VectorTable = GetVReg(Op->VectorTable.ID()); + switch (OpSize) { + case 8: { + tbx(VectorSrcDst.D(), VectorTable.Q(), VectorIndices.D()); + break; + } + case 16: { + tbx(VectorSrcDst.Q(), VectorTable.Q(), VectorIndices.Q()); + break; + } + case 32: { + LOGMAN_THROW_AA_FMT(HostSupportsSVE256, + "Host does not support SVE. Cannot perform 256-bit table lookup"); + + tbx(ARMEmitter::SubRegSize::i8Bit, VectorSrcDst.Z(), VectorTable.Z(), VectorIndices.Z()); + break; + } + default: + LOGMAN_MSG_A_FMT("Unknown OpSize: {}", OpSize); + break; + } + if (Dst != VectorSrcDst) { switch (OpSize) { case 8: { @@ -5025,27 +5046,6 @@ DEF_OP(VTBX1) { break; } } - - switch (OpSize) { - case 8: { - tbx(Dst.D(), VectorTable.Q(), VectorIndices.D()); - break; - } - case 16: { - tbx(Dst.Q(), VectorTable.Q(), VectorIndices.Q()); - break; - } - case 32: { - LOGMAN_THROW_AA_FMT(HostSupportsSVE256, - "Host does not support SVE. Cannot perform 256-bit table lookup"); - - tbx(ARMEmitter::SubRegSize::i8Bit, Dst.Z(), VectorTable.Z(), VectorIndices.Z()); - break; - } - default: - LOGMAN_MSG_A_FMT("Unknown OpSize: {}", OpSize); - break; - } } DEF_OP(VRev32) {