diff --git a/core/libs/prx/libSceAgcDriver/CMakeLists.txt b/core/libs/prx/libSceAgcDriver/CMakeLists.txt index 52cd05e97..989e50f1e 100644 --- a/core/libs/prx/libSceAgcDriver/CMakeLists.txt +++ b/core/libs/prx/libSceAgcDriver/CMakeLists.txt @@ -601,6 +601,14 @@ if(BUILD_TESTING) set_tests_properties(vector_compare_i16_u16 PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$") endif() + add_test_executable(vector_compare_const_tests ${LIBS_INCLUDE_DIR}/tests/VectorCompareConst.cpp) + target_link_libraries(vector_compare_const_tests PRIVATE shader_recompiler_agc_driver libc) + configure_windows_unwind(vector_compare_const_tests) + add_test(NAME vector_compare_const COMMAND vector_compare_const_tests) + if(WIN32) + set_tests_properties(vector_compare_const PROPERTIES ENVIRONMENT_MODIFICATION + "PATH=path_list_prepend:$") + endif() add_test_executable(vector_min_max_med16_tests ${LIBS_INCLUDE_DIR}/tests/VectorMinMaxMed16.cpp) target_link_libraries(vector_min_max_med16_tests PRIVATE shader_recompiler_agc_driver libc) configure_windows_unwind(vector_min_max_med16_tests) diff --git a/core/libs/tests/VectorCompareConst.cpp b/core/libs/tests/VectorCompareConst.cpp new file mode 100644 index 000000000..51ee5102f --- /dev/null +++ b/core/libs/tests/VectorCompareConst.cpp @@ -0,0 +1,46 @@ +#include "Translation/TranslationContext.hpp" +#include "RdnaDecoder/RdnaVectorOpDecoder.hpp" +#include +#include + +using namespace ShaderRecompiler; +static void Require(bool value) { if (!value) throw std::runtime_error("vector compare const regression"); } +static void Check(std::uint32_t encoding, RdnaOpcode opcode, bool exec) { + const std::array code{(encoding << 17u) | (1u << 9u) | 100u}; + const RdnaInstruction instruction = DecodeRdnaVopc(0u, code, 0u); + Require(instruction.op == opcode); + Require(instruction.family == RdnaInstructionFamily::VOPC); + Require(IsVectorAluOpcode(instruction.op)); + Require(instruction.destination.kind == (exec ? RdnaOperandKind::ExecLo : RdnaOperandKind::VccLo)); + IrProgram program; + auto& block = program.CreateBlock(); + program.SetEntryBlock(block); + TranslationContext context(program, block, 256); + context.TranslateInstruction(instruction); +} +int main() { + Check(0xa0u, RdnaOpcode::VCmpFI64, false); + Check(0xa7u, RdnaOpcode::VCmpTI64, false); + Check(0xe0u, RdnaOpcode::VCmpFU64, false); + Check(0xe7u, RdnaOpcode::VCmpTU64, false); + Check(0xc8u, RdnaOpcode::VCmpFF16, false); + Check(0xefu, RdnaOpcode::VCmpTruF16, false); + Check(0xcfu, RdnaOpcode::VCmpOF16, false); + Check(0xe8u, RdnaOpcode::VCmpUF16, false); + Check(0x10u, RdnaOpcode::VCmpxFF32, true); + Check(0x17u, RdnaOpcode::VCmpxOF32, true); + Check(0x18u, RdnaOpcode::VCmpxUF32, true); + Check(0x1fu, RdnaOpcode::VCmpxTruF32, true); + Check(0x90u, RdnaOpcode::VCmpxFI32, true); + Check(0x97u, RdnaOpcode::VCmpxTI32, true); + Check(0xd0u, RdnaOpcode::VCmpxFU32, true); + Check(0xd7u, RdnaOpcode::VCmpxTU32, true); + Check(0xb0u, RdnaOpcode::VCmpxFI64, true); + Check(0xb7u, RdnaOpcode::VCmpxTI64, true); + Check(0xf0u, RdnaOpcode::VCmpxFU64, true); + Check(0xf7u, RdnaOpcode::VCmpxTU64, true); + Check(0xd8u, RdnaOpcode::VCmpxFF16, true); + Check(0xffu, RdnaOpcode::VCmpxTruF16, true); + Check(0xdfu, RdnaOpcode::VCmpxOF16, true); + Check(0xf8u, RdnaOpcode::VCmpxUF16, true); +}