[llvm] Greedy: Simplify collectHintInfo using MachineOperands. NFCI. (PR #159724)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 21 22:29:30 PDT 2025
================
@@ -2389,22 +2389,18 @@ void RAGreedy::initializeCSRCost() {
void RAGreedy::collectHintInfo(Register Reg, HintsInfo &Out) {
const TargetRegisterClass *RC = MRI->getRegClass(Reg);
- for (const MachineInstr &Instr : MRI->reg_nodbg_instructions(Reg)) {
- if (!Instr.isCopy())
+ for (const MachineOperand &Opnd : MRI->reg_nodbg_operands(Reg)) {
+ const MachineInstr &Instr = *Opnd.getParent();
+ if (!Instr.isCopy() || Opnd.isImplicit())
continue;
// Look for the other end of the copy.
- Register OtherReg = Instr.getOperand(0).getReg();
- unsigned OtherSubReg = Instr.getOperand(0).getSubReg();
- unsigned SubReg = Instr.getOperand(1).getSubReg();
-
- if (OtherReg == Reg) {
- OtherReg = Instr.getOperand(1).getReg();
- OtherSubReg = Instr.getOperand(1).getSubReg();
- SubReg = Instr.getOperand(0).getSubReg();
- if (OtherReg == Reg)
- continue;
- }
+ const MachineOperand &OtherOpnd = Instr.getOperand(1 - Opnd.getOperandNo());
----------------
arsenm wrote:
```suggestion
const MachineOperand &OtherOpnd = Instr.getOperand(Opnd.isDef());
```
https://github.com/llvm/llvm-project/pull/159724
More information about the llvm-commits
mailing list