Skip to content

Commit 4e1c05f

Browse files
committed
Delete dead code instead
1 parent c275dd0 commit 4e1c05f

File tree

2 files changed

+16
-25
lines changed

2 files changed

+16
-25
lines changed

llvm/lib/Target/AMDGPU/GCNRegPressure.cpp

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -313,30 +313,22 @@ collectVirtualRegUses(SmallVectorImpl<VRegMaskOrUnit> &VRegMaskOrUnits,
313313
/// Mostly copy/paste from CodeGen/RegisterPressure.cpp
314314
static LaneBitmask getLanesWithProperty(
315315
const LiveIntervals &LIS, const MachineRegisterInfo &MRI,
316-
bool TrackLaneMasks, VirtRegOrUnit VRegOrUnit, SlotIndex Pos,
317-
LaneBitmask SafeDefault,
316+
bool TrackLaneMasks, Register Reg, SlotIndex Pos,
318317
function_ref<bool(const LiveRange &LR, SlotIndex Pos)> Property) {
319-
if (VRegOrUnit.isVirtualReg()) {
320-
const LiveInterval &LI = LIS.getInterval(VRegOrUnit.asVirtualReg());
321-
LaneBitmask Result;
322-
if (TrackLaneMasks && LI.hasSubRanges()) {
323-
for (const LiveInterval::SubRange &SR : LI.subranges()) {
324-
if (Property(SR, Pos))
325-
Result |= SR.LaneMask;
326-
}
327-
} else if (Property(LI, Pos)) {
328-
Result = TrackLaneMasks
329-
? MRI.getMaxLaneMaskForVReg(VRegOrUnit.asVirtualReg())
330-
: LaneBitmask::getAll();
318+
assert(Reg.isVirtual());
319+
const LiveInterval &LI = LIS.getInterval(Reg);
320+
LaneBitmask Result;
321+
if (TrackLaneMasks && LI.hasSubRanges()) {
322+
for (const LiveInterval::SubRange &SR : LI.subranges()) {
323+
if (Property(SR, Pos))
324+
Result |= SR.LaneMask;
331325
}
332-
333-
return Result;
326+
} else if (Property(LI, Pos)) {
327+
Result =
328+
TrackLaneMasks ? MRI.getMaxLaneMaskForVReg(Reg) : LaneBitmask::getAll();
334329
}
335330

336-
const LiveRange *LR = LIS.getCachedRegUnit(VRegOrUnit.asMCRegUnit());
337-
if (LR == nullptr)
338-
return SafeDefault;
339-
return Property(*LR, Pos) ? LaneBitmask::getAll() : LaneBitmask::getNone();
331+
return Result;
340332
}
341333

342334
/// Mostly copy/paste from CodeGen/RegisterPressure.cpp
@@ -504,10 +496,9 @@ void GCNRPTracker::reset(const MachineRegisterInfo &MRI_,
504496
}
505497

506498
/// Mostly copy/paste from CodeGen/RegisterPressure.cpp
507-
LaneBitmask GCNRPTracker::getLastUsedLanes(VirtRegOrUnit VRegOrUnit,
508-
SlotIndex Pos) const {
499+
LaneBitmask GCNRPTracker::getLastUsedLanes(Register Reg, SlotIndex Pos) const {
509500
return getLanesWithProperty(
510-
LIS, *MRI, true, VRegOrUnit, Pos.getBaseIndex(), LaneBitmask::getNone(),
501+
LIS, *MRI, true, Reg, Pos.getBaseIndex(),
511502
[](const LiveRange &LR, SlotIndex Pos) {
512503
const LiveRange::Segment *S = LR.getSegmentContaining(Pos);
513504
return S != nullptr && S->end == Pos.getRegSlot();
@@ -753,7 +744,7 @@ GCNDownwardRPTracker::bumpDownwardPressure(const MachineInstr *MI,
753744
if (!Use.VRegOrUnit.isVirtualReg())
754745
continue;
755746
Register Reg = Use.VRegOrUnit.asVirtualReg();
756-
LaneBitmask LastUseMask = getLastUsedLanes(Use.VRegOrUnit, SlotIdx);
747+
LaneBitmask LastUseMask = getLastUsedLanes(Reg, SlotIdx);
757748
if (LastUseMask.none())
758749
continue;
759750
// The LastUseMask is queried from the liveness information of instruction

llvm/lib/Target/AMDGPU/GCNRegPressure.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ class GCNRPTracker {
292292
/// Mostly copy/paste from CodeGen/RegisterPressure.cpp
293293
void bumpDeadDefs(ArrayRef<VRegMaskOrUnit> DeadDefs);
294294

295-
LaneBitmask getLastUsedLanes(VirtRegOrUnit VRegOrUnit, SlotIndex Pos) const;
295+
LaneBitmask getLastUsedLanes(Register Reg, SlotIndex Pos) const;
296296

297297
public:
298298
// reset tracker and set live register set to the specified value.

0 commit comments

Comments
 (0)