From 5e9fe4cd13ecf6b6a6b3222057477f4d8c73993b Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Fri, 14 Aug 2015 20:46:23 +0200 Subject: [PATCH 1/2] x64Emitter: check for immediates in BMI ops --- Source/Core/Common/x64Emitter.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Core/Common/x64Emitter.cpp b/Source/Core/Common/x64Emitter.cpp index eac841d162a9..4c45067e7f15 100644 --- a/Source/Core/Common/x64Emitter.cpp +++ b/Source/Core/Common/x64Emitter.cpp @@ -1447,8 +1447,10 @@ void XEmitter::WriteFMA4Op(u8 op, X64Reg dest, X64Reg regOp1, X64Reg regOp2, con void XEmitter::WriteBMIOp(int size, u8 opPrefix, u16 op, X64Reg regOp1, X64Reg regOp2, const OpArg& arg, int extrabytes) { CheckFlags(); + if (arg.IsImm()) + PanicAlert("BMI1/2 instructions don't support immediate operands."); if (size != 32 && size != 64) - PanicAlert("VEX GPR instructions only support 32-bit and 64-bit modes!"); + PanicAlert("BMI1/2 instructions only support 32-bit and 64-bit modes!"); int W = size == 64; WriteVEXOp(opPrefix, op, regOp1, regOp2, arg, W, extrabytes); } From e5a23347444ab9148114b6412d71dc229ffdce86 Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Fri, 14 Aug 2015 05:51:31 +0200 Subject: [PATCH 2/2] Jit64: make use of ANDN again This time, make sure not to use it with immediates. --- .../Core/Core/PowerPC/Jit64/Jit_Integer.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp index 407a39b8671d..0681a80af755 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp @@ -676,7 +676,11 @@ void Jit64::boolX(UGeckoInstruction inst) } else if (inst.SUBOP10 == 60) // andcx { - if (a == b) + if (cpu_info.bBMI1 && gpr.R(b).IsSimpleReg() && !gpr.R(s).IsImm()) + { + ANDN(32, gpr.RX(a), gpr.RX(b), gpr.R(s)); + } + else if (a == b) { NOT(32, gpr.R(a)); AND(32, gpr.R(a), operand); @@ -745,9 +749,16 @@ void Jit64::boolX(UGeckoInstruction inst) } else if (inst.SUBOP10 == 60) // andcx { - MOV(32, gpr.R(a), gpr.R(b)); - NOT(32, gpr.R(a)); - AND(32, gpr.R(a), gpr.R(s)); + if (cpu_info.bBMI1 && gpr.R(b).IsSimpleReg() && !gpr.R(s).IsImm()) + { + ANDN(32, gpr.RX(a), gpr.RX(b), gpr.R(s)); + } + else + { + MOV(32, gpr.R(a), gpr.R(b)); + NOT(32, gpr.R(a)); + AND(32, gpr.R(a), gpr.R(s)); + } } else if (inst.SUBOP10 == 444) // orx {