diff --git a/FEXCore/Source/Interface/Core/JIT/ALUOps.cpp b/FEXCore/Source/Interface/Core/JIT/ALUOps.cpp index f9b470d07..236622249 100644 --- a/FEXCore/Source/Interface/Core/JIT/ALUOps.cpp +++ b/FEXCore/Source/Interface/Core/JIT/ALUOps.cpp @@ -774,7 +774,7 @@ DEF_OP(PDep) { // Now, they're copied, so we can start setting Dest (even if it overlaps with // one of them). Handle early exit case mov(EmitSize, Dest, 0); - (void)cbz(EmitSize, OrigMask, &Done); + (void)cbz(EmitSize, Mask, &Done); // Setup for first iteration neg(EmitSize, T0, Mask); diff --git a/unittests/ASM/FEX_bugs/pdep_overlap.asm b/unittests/ASM/FEX_bugs/pdep_overlap.asm new file mode 100644 index 000000000..bb10e601f --- /dev/null +++ b/unittests/ASM/FEX_bugs/pdep_overlap.asm @@ -0,0 +1,43 @@ +%ifdef CONFIG +{ + "RegData": { + "RBX": "0xAAAAAAAAAAAAAAAA", + "RBX": "0x4444444444444444", + "RCX": "0x4444444444444444", + "RDX": "0x5555555555555555", + "R8": "0x0303030303030303", + "RSI": "0x3333333333333333", + "R8": "0x0303030303030303" + } +} +%endif + + +; dest and mask overlap +mov rax, 0xAAAAAAAAAAAAAAAA +mov rbx, 0x5555555555555555 + +pdep rbx, rax, rbx + + +; dest and input overlap +mov rcx, 0xAAAAAAAAAAAAAAAA +mov rdx, 0x5555555555555555 + +pdep rcx, rcx, rdx + + +; input and mask overlap +mov rdi, 0xDEADBEEFCAFEBABE +mov rsi, 0x3333333333333333 + +pdep rdi, rsi, rsi + + +; dest, input, mask overlap +mov r8, 0x3333333333333333 + +pdep r8, r8, r8 + + +hlt \ No newline at end of file diff --git a/unittests/InstructionCountCI/AVX128/VEX_map2_flagm.json b/unittests/InstructionCountCI/AVX128/VEX_map2_flagm.json index da85a4030..89679a1a2 100644 --- a/unittests/InstructionCountCI/AVX128/VEX_map2_flagm.json +++ b/unittests/InstructionCountCI/AVX128/VEX_map2_flagm.json @@ -672,7 +672,7 @@ "mov x0, x6", "mov x1, x7", "mov w4, #0x0", - "cbz w7, #+0x2c", + "cbz w1, #+0x2c", "neg w2, w1", "and w2, w2, w1", "sbfx w3, w0, #0, #1", @@ -694,7 +694,7 @@ "mov x0, x6", "mov x1, x7", "mov x4, #0x0", - "cbz x7, #+0x2c", + "cbz x1, #+0x2c", "neg x2, x1", "and x2, x2, x1", "sbfx x3, x0, #0, #1", diff --git a/unittests/InstructionCountCI/FlagM/VEX_map2.json b/unittests/InstructionCountCI/FlagM/VEX_map2.json index f357ee6e5..aad81e003 100644 --- a/unittests/InstructionCountCI/FlagM/VEX_map2.json +++ b/unittests/InstructionCountCI/FlagM/VEX_map2.json @@ -405,7 +405,7 @@ "mov x0, x6", "mov x1, x7", "mov w4, #0x0", - "cbz w7, #+0x2c", + "cbz w1, #+0x2c", "neg w2, w1", "and w2, w2, w1", "sbfx w3, w0, #0, #1", @@ -427,7 +427,7 @@ "mov x0, x6", "mov x1, x7", "mov x4, #0x0", - "cbz x7, #+0x2c", + "cbz x1, #+0x2c", "neg x2, x1", "and x2, x2, x1", "sbfx x3, x0, #0, #1", diff --git a/unittests/InstructionCountCI/VEX_map2.json b/unittests/InstructionCountCI/VEX_map2.json index 6600e2517..e811c6735 100644 --- a/unittests/InstructionCountCI/VEX_map2.json +++ b/unittests/InstructionCountCI/VEX_map2.json @@ -4980,7 +4980,7 @@ "mov x0, x6", "mov x1, x7", "mov w4, #0x0", - "cbz w7, #+0x2c", + "cbz w1, #+0x2c", "neg w2, w1", "and w2, w2, w1", "sbfx w3, w0, #0, #1", @@ -5002,7 +5002,7 @@ "mov x0, x6", "mov x1, x7", "mov x4, #0x0", - "cbz x7, #+0x2c", + "cbz x1, #+0x2c", "neg x2, x1", "and x2, x2, x1", "sbfx x3, x0, #0, #1",