- // There are two possible candidates which can be changed to set CPSR:
- // One is MI, the other is a SUB instruction.
- // For CMPrr(r1,r2), we are looking for SUB(r1,r2) or SUB(r2,r1).
- // For CMPri(r1, CmpValue), we are looking for SUBri(r1, CmpValue).
- MachineInstr *Sub = NULL;
- unsigned SrcReg2 = 0;
- if (CmpInstr->getOpcode() == ARM::CMPrr ||
- CmpInstr->getOpcode() == ARM::t2CMPrr) {
- SrcReg2 = CmpInstr->getOperand(1).getReg();
- // MI is not a candidate for CMPrr.
- MI = NULL;
- } else if (MI->getParent() != CmpInstr->getParent() || CmpValue != 0)
- // Conservatively refuse to convert an instruction which isn't in the same
- // BB as the comparison.
- // For CMPri, we need to check Sub, thus we can't return here.
- if(CmpInstr->getOpcode() == ARM::CMPri ||
- CmpInstr->getOpcode() == ARM::t2CMPri)
- MI = NULL;
- else
- return false;
-
- // Check that CPSR isn't set between the comparison instruction and the one we
- // want to change. At the same time, search for Sub.