Skip to content

Commit cecdff9

Browse files
jayfoadarsenm
andauthored
Greedy: Simplify collectHintInfo using MachineOperands. NFCI. (#159724)
If a COPY uses Reg but only in an implicit operand then the new implementation ignores it but the old implementation would have treated it as a copy of Reg. Probably this case never occurs in practice. Other than that, this patch is NFC. Co-authored-by: Matt Arsenault <arsenm2@gmail.com>
1 parent ab76686 commit cecdff9

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

llvm/lib/CodeGen/RegAllocGreedy.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2389,22 +2389,18 @@ void RAGreedy::initializeCSRCost() {
23892389
void RAGreedy::collectHintInfo(Register Reg, HintsInfo &Out) {
23902390
const TargetRegisterClass *RC = MRI->getRegClass(Reg);
23912391

2392-
for (const MachineInstr &Instr : MRI->reg_nodbg_instructions(Reg)) {
2393-
if (!Instr.isCopy())
2392+
for (const MachineOperand &Opnd : MRI->reg_nodbg_operands(Reg)) {
2393+
const MachineInstr &Instr = *Opnd.getParent();
2394+
if (!Instr.isCopy() || Opnd.isImplicit())
23942395
continue;
23952396

23962397
// Look for the other end of the copy.
2397-
Register OtherReg = Instr.getOperand(0).getReg();
2398-
unsigned OtherSubReg = Instr.getOperand(0).getSubReg();
2399-
unsigned SubReg = Instr.getOperand(1).getSubReg();
2400-
2401-
if (OtherReg == Reg) {
2402-
OtherReg = Instr.getOperand(1).getReg();
2403-
OtherSubReg = Instr.getOperand(1).getSubReg();
2404-
SubReg = Instr.getOperand(0).getSubReg();
2405-
if (OtherReg == Reg)
2406-
continue;
2407-
}
2398+
const MachineOperand &OtherOpnd = Instr.getOperand(Opnd.isDef());
2399+
Register OtherReg = OtherOpnd.getReg();
2400+
if (OtherReg == Reg)
2401+
continue;
2402+
unsigned OtherSubReg = OtherOpnd.getSubReg();
2403+
unsigned SubReg = Opnd.getSubReg();
24082404

24092405
// Get the current assignment.
24102406
MCRegister OtherPhysReg =

0 commit comments

Comments
 (0)