2
0
Эх сурвалжийг харах

ARM: Fix condition code check fusion.

Reported by Qingjun Wei.
Mike Pall 6 жил өмнө
parent
commit
5802ab56b6
1 өөрчлөгдсөн 15 нэмэгдсэн , 13 устгасан
  1. 15 13
      src/lj_asm_arm.h

+ 15 - 13
src/lj_asm_arm.h

@@ -1449,19 +1449,10 @@ static void asm_intop(ASMState *as, IRIns *ir, ARMIns ai)
   emit_dn(as, ai^m, dest, left);
 }
 
-static void asm_intop_s(ASMState *as, IRIns *ir, ARMIns ai)
-{
-  if (as->flagmcp == as->mcp) {  /* Drop cmp r, #0. */
-    as->flagmcp = NULL;
-    as->mcp++;
-    ai |= ARMI_S;
-  }
-  asm_intop(as, ir, ai);
-}
-
-static void asm_bitop(ASMState *as, IRIns *ir, ARMIns ai)
+/* Try to drop cmp r, #0. */
+static ARMIns asm_drop_cmp0(ASMState *as, ARMIns ai)
 {
-  if (as->flagmcp == as->mcp) {  /* Try to drop cmp r, #0. */
+  if (as->flagmcp == as->mcp) {
     uint32_t cc = (as->mcp[1] >> 28);
     as->flagmcp = NULL;
     if (cc <= CC_NE) {
@@ -1473,8 +1464,19 @@ static void asm_bitop(ASMState *as, IRIns *ir, ARMIns ai)
     } else if (cc == CC_LT) {
       *++as->mcp ^= ((CC_LT^CC_MI) << 28);
       ai |= ARMI_S;
-    }  /* else: other conds don't work with bit ops. */
+    }  /* else: other conds don't work in general. */
   }
+  return ai;
+}
+
+static void asm_intop_s(ASMState *as, IRIns *ir, ARMIns ai)
+{
+  asm_intop(as, ir, asm_drop_cmp0(as, ai));
+}
+
+static void asm_bitop(ASMState *as, IRIns *ir, ARMIns ai)
+{
+  ai = asm_drop_cmp0(as, ai);
   if (ir->op2 == 0) {
     Reg dest = ra_dest(as, ir, RSET_GPR);
     uint32_t m = asm_fuseopm(as, ai, ir->op1, RSET_GPR);