From 5802ab56b6435e8ea39616d04751b32b9996bfb7 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Mon, 29 Apr 2019 17:38:05 +0200 Subject: [PATCH 1/2] ARM: Fix condition code check fusion. Reported by Qingjun Wei. --- src/lj_asm_arm.h | 28 +++++++++++++++------------- 1 file 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) +/* Try to drop cmp r, #0. */ +static ARMIns asm_drop_cmp0(ASMState *as, 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) -{ - 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); From 9bd5a722bee2ee2c5b159a89937778b81be49915 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Mon, 29 Apr 2019 18:02:50 +0200 Subject: [PATCH 2/2] ARM: Fix GCC 7 -Wimplicit-fallthrough warnings. --- src/lj_asm.c | 2 +- src/lj_asm_arm.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lj_asm.c b/src/lj_asm.c index dd7186f6..8ce7bbd6 100644 --- a/src/lj_asm.c +++ b/src/lj_asm.c @@ -1719,8 +1719,8 @@ static void asm_setup_regsp(ASMState *as) #if LJ_SOFTFP case IR_MIN: case IR_MAX: if ((ir+1)->o != IR_HIOP) break; - /* fallthrough */ #endif + /* fallthrough */ /* C calls evict all scratch regs and return results in RID_RET. */ case IR_SNEW: case IR_XSNEW: case IR_NEWREF: if (REGARG_NUMGPR < 3 && as->evenspill < 3) diff --git a/src/lj_asm_arm.h b/src/lj_asm_arm.h index 8e0ebd7a..ccd20545 100644 --- a/src/lj_asm_arm.h +++ b/src/lj_asm_arm.h @@ -1046,7 +1046,7 @@ static ARMIns asm_fxloadins(IRIns *ir) case IRT_I16: return ARMI_LDRSH; case IRT_U16: return ARMI_LDRH; case IRT_NUM: lua_assert(!LJ_SOFTFP); return ARMI_VLDR_D; - case IRT_FLOAT: if (!LJ_SOFTFP) return ARMI_VLDR_S; + case IRT_FLOAT: if (!LJ_SOFTFP) return ARMI_VLDR_S; /* fallthrough */ default: return ARMI_LDR; } } @@ -1057,7 +1057,7 @@ static ARMIns asm_fxstoreins(IRIns *ir) case IRT_I8: case IRT_U8: return ARMI_STRB; case IRT_I16: case IRT_U16: return ARMI_STRH; case IRT_NUM: lua_assert(!LJ_SOFTFP); return ARMI_VSTR_D; - case IRT_FLOAT: if (!LJ_SOFTFP) return ARMI_VSTR_S; + case IRT_FLOAT: if (!LJ_SOFTFP) return ARMI_VSTR_S; /* fallthrough */ default: return ARMI_STR; } }