]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
x86/x64: Don't use undefined MUL/IMUL zero flag. master v2.0
authorMike Pall <mike>
Thu, 24 Jul 2025 13:38:45 +0000 (15:38 +0200)
committerMike Pall <mike>
Thu, 24 Jul 2025 13:38:45 +0000 (15:38 +0200)
Reported by VrIgHtEr. #1376

src/lj_asm_x86.h

index 239066d4a5b2fe35e2cddbad408dfaf361ef98e2..8b6ce479833c5cff6d68bc6c3844c633bca82236 100644 (file)
@@ -1841,7 +1841,8 @@ static void asm_intarith(ASMState *as, IRIns *ir, x86Arith xa)
   RegSet allow = RSET_GPR;
   Reg dest, right;
   int32_t k = 0;
-  if (as->flagmcp == as->mcp) {  /* Drop test r,r instruction. */
+  if (as->flagmcp == as->mcp && xa != XOg_X_IMUL) {
+    /* Drop test r,r instruction. */
     MCode *p = as->mcp + ((LJ_64 && *as->mcp < XI_TESTb) ? 3 : 2);
     MCode *q = p[0] == 0x0f ? p+1 : p;
     if ((*q & 15) < 14) {