ARM: Fix condition code check fusion.

Reported by Qingjun Wei.
This commit is contained in:
Mike Pall 2019-04-29 17:38:05 +02:00
parent 61464b0a5b
commit 5802ab56b6

View File

@ -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);