Blame SOURCES/0040-x86-x64-Check-for-jcc-when-using-xor-r-r-in-emit_loa.patch

006bc1
From fb5e522fbc0750c838ef6a926b11c5d870826183 Mon Sep 17 00:00:00 2001
006bc1
From: Mike Pall <mike>
006bc1
Date: Sun, 20 May 2018 12:40:33 +0200
006bc1
Subject: [PATCH 40/72] x86/x64: Check for jcc when using xor r,r in
006bc1
 emit_loadi().
006bc1
006bc1
Thanks to Peter Cawley.
006bc1
---
006bc1
 src/lj_emit_x86.h | 6 ++++--
006bc1
 1 file changed, 4 insertions(+), 2 deletions(-)
006bc1
006bc1
diff --git a/src/lj_emit_x86.h b/src/lj_emit_x86.h
006bc1
index bcceb93..9c371a9 100644
006bc1
--- a/src/lj_emit_x86.h
006bc1
+++ b/src/lj_emit_x86.h
006bc1
@@ -268,10 +268,12 @@ static void emit_movmroi(ASMState *as, Reg base, int32_t ofs, int32_t i)
006bc1
 /* mov r, i / xor r, r */
006bc1
 static void emit_loadi(ASMState *as, Reg r, int32_t i)
006bc1
 {
006bc1
-  /* XOR r,r is shorter, but modifies the flags. This is bad for HIOP. */
006bc1
+  /* XOR r,r is shorter, but modifies the flags. This is bad for HIOP/jcc. */
006bc1
   if (i == 0 && !(LJ_32 && (IR(as->curins)->o == IR_HIOP ||
006bc1
 			    (as->curins+1 < as->T->nins &&
006bc1
-			     IR(as->curins+1)->o == IR_HIOP)))) {
006bc1
+			     IR(as->curins+1)->o == IR_HIOP))) &&
006bc1
+		!((*as->mcp == 0x0f && (as->mcp[1] & 0xf0) == XI_JCCn) ||
006bc1
+		  (*as->mcp & 0xf0) == XI_JCCs)) {
006bc1
     emit_rr(as, XO_ARITH(XOg_XOR), r, r);
006bc1
   } else {
006bc1
     MCode *p = as->mcp;
006bc1
-- 
006bc1
2.20.1
006bc1