Skip to content

Commit 447eb33

Browse files
committed
[AMDGPU][MachineRegisterInfo] Extend the MRI live-ins check by including
the check against the subregs for live-ins.
1 parent 49f60b4 commit 447eb33

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

llvm/include/llvm/CodeGen/MachineRegisterInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ class MachineRegisterInfo {
10201020
return LiveIns;
10211021
}
10221022

1023-
bool isLiveIn(Register Reg) const;
1023+
bool isLiveIn(Register Reg, bool CheckForSubreg = false) const;
10241024

10251025
/// getLiveInPhysReg - If VReg is a live-in virtual register, return the
10261026
/// corresponding live-in physical register.

llvm/lib/CodeGen/MachineRegisterInfo.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,10 +447,22 @@ void MachineRegisterInfo::clearKillFlags(Register Reg) const {
447447
MO.setIsKill(false);
448448
}
449449

450-
bool MachineRegisterInfo::isLiveIn(Register Reg) const {
451-
for (const std::pair<MCRegister, Register> &LI : liveins())
450+
bool MachineRegisterInfo::isLiveIn(Register Reg, bool CheckForSubreg) const {
451+
for (const std::pair<MCRegister, Register> &LI : liveins()) {
452452
if ((Register)LI.first == Reg || LI.second == Reg)
453453
return true;
454+
455+
// Check if Reg is a subreg of live-in register
456+
if (CheckForSubreg) {
457+
MCRegister PhysReg = LI.first;
458+
if (!PhysReg.isValid())
459+
continue;
460+
461+
for (MCPhysReg SubReg : getTargetRegisterInfo()->subregs(PhysReg))
462+
if (SubReg == Reg)
463+
return true;
464+
}
465+
}
454466
return false;
455467
}
456468

0 commit comments

Comments
 (0)