From b5dbc405878ae37dfb7379f6cc6fb64928c782e3 Mon Sep 17 00:00:00 2001 From: wheremyfoodat Date: Sat, 10 Jun 2023 23:18:33 +0300 Subject: [PATCH] [Shader JIT] Fix CMP instruction when cmpX == cmpY --- src/core/PICA/dynapica/shader_rec_emitter_x64.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/PICA/dynapica/shader_rec_emitter_x64.cpp b/src/core/PICA/dynapica/shader_rec_emitter_x64.cpp index 2e9b698f..4cd813c4 100644 --- a/src/core/PICA/dynapica/shader_rec_emitter_x64.cpp +++ b/src/core/PICA/dynapica/shader_rec_emitter_x64.cpp @@ -557,10 +557,11 @@ void ShaderEmitter::recCMP(const PICAShader& shader, u32 instruction) { // Cmp x and y are the same compare function, we can use a single cmp instruction if (cmpX == cmpY) { cmpps(lhs_x, rhs_x, compareFuncX); - movd(eax, lhs_x); - test(eax, eax); + movq(rax, lhs_x); // Move both comparison results to rax + test(eax, eax); // Check bottom 32 bits first + setne(byte[statePointer + cmpRegXOffset]); // set cmp.x - setne(byte[statePointer + cmpRegXOffset]); + shr(rax, 32); // Check top 32 bits (shr will set the zero flag properly) setne(byte[statePointer + cmpRegYOffset]); } else { movaps(scratch1, lhs_x); // Copy the left hand operands to temp registers