+
+ // Scan the operands to find: (1) the use operand that kills regB (if
+ // any); (2) whether the kill operand is being replaced by regA on
+ // this iteration; and (3) the first use of regB that is not being
+ // replaced on this iteration. A use of regB will not replaced if it
+ // is tied to a different destination register and will be handled on
+ // a later iteration.
+ MachineOperand *KillMO = NULL;
+ MachineOperand *FirstKeptMO = NULL;
+ bool KillMOKept = false;
+ for (unsigned i = 0, e = mi->getNumOperands(); i != e; ++i) {
+ MachineOperand &MO = mi->getOperand(i);
+ if (MO.isReg() && MO.getReg() == regB && MO.isUse()) {
+
+ // Check if this operand is tied to a different destination.
+ bool isKept = false;
+ unsigned dsti = 0;
+ if (mi->isRegTiedToDefOperand(i, &dsti) && dsti != ti) {
+ isKept = true;
+ if (!FirstKeptMO)
+ FirstKeptMO = &MO;
+ }