summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Pall <mike>2019-04-29 17:38:05 +0200
committerMike Pall <mike>2019-04-29 17:38:05 +0200
commit5802ab56b6435e8ea39616d04751b32b9996bfb7 (patch)
treed81d9f2363d5ab111db0cc2a6f84c9cb6a5ee474
parent61464b0a5b685489bee7b6680c0e9663f2143a84 (diff)
downloadluajit2-5802ab56b6435e8ea39616d04751b32b9996bfb7.tar.gz
ARM: Fix condition code check fusion.
Reported by Qingjun Wei.
-rw-r--r--src/lj_asm_arm.h28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/lj_asm_arm.h b/src/lj_asm_arm.h
index 961f7e39..8e0ebd7a 100644
--- a/src/lj_asm_arm.h
+++ b/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);