diff --git a/src/lj_asm.c b/src/lj_asm.c index 992dcf59..ff07b7ee 100644 --- a/src/lj_asm.c +++ b/src/lj_asm.c @@ -2130,8 +2130,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: case IR_BUFPUT: if (REGARG_NUMGPR < 3 && as->evenspill < 3) diff --git a/src/lj_asm_arm.h b/src/lj_asm_arm.h index 37bfa40f..e222e541 100644 --- a/src/lj_asm_arm.h +++ b/src/lj_asm_arm.h @@ -979,7 +979,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; } } @@ -990,7 +990,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; } } @@ -1412,14 +1412,29 @@ static void asm_intop(ASMState *as, IRIns *ir, ARMIns ai) emit_dn(as, ai^m, dest, left); } +/* Try to drop cmp r, #0. */ +static ARMIns asm_drop_cmp0(ASMState *as, ARMIns ai) +{ + if (as->flagmcp == as->mcp) { + uint32_t cc = (as->mcp[1] >> 28); + as->flagmcp = NULL; + if (cc <= CC_NE) { + as->mcp++; + ai |= ARMI_S; + } else if (cc == CC_GE) { + *++as->mcp ^= ((CC_GE^CC_PL) << 28); + ai |= ARMI_S; + } else if (cc == CC_LT) { + *++as->mcp ^= ((CC_LT^CC_MI) << 28); + ai |= ARMI_S; + } /* else: other conds don't work in general. */ + } + return ai; +} + 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); + asm_intop(as, ir, asm_drop_cmp0(as, ai)); } static void asm_intneg(ASMState *as, IRIns *ir, ARMIns ai) @@ -1514,20 +1529,7 @@ static void asm_neg(ASMState *as, IRIns *ir) static void asm_bitop(ASMState *as, IRIns *ir, ARMIns ai) { - if (as->flagmcp == as->mcp) { /* Try to drop cmp r, #0. */ - uint32_t cc = (as->mcp[1] >> 28); - as->flagmcp = NULL; - if (cc <= CC_NE) { - as->mcp++; - ai |= ARMI_S; - } else if (cc == CC_GE) { - *++as->mcp ^= ((CC_GE^CC_PL) << 28); - ai |= ARMI_S; - } else if (cc == CC_LT) { - *++as->mcp ^= ((CC_LT^CC_MI) << 28); - ai |= ARMI_S; - } /* else: other conds don't work with bit ops. */ - } + 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);