Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions llvm/lib/CodeGen/RenameIndependentSubregs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ void RenameIndependentSubregs::computeMainRangesFixFlags(
const IntEqClasses &Classes,
const SmallVectorImpl<SubRangeInfo> &SubRangeInfos,
const SmallVectorImpl<LiveInterval*> &Intervals) const {
const TargetRegisterInfo &TRI = TII->getRegisterInfo();
BumpPtrAllocator &Allocator = LIS->getVNInfoAllocator();
const SlotIndexes &Indexes = *LIS->getSlotIndexes();
for (size_t I = 0, E = Intervals.size(); I < E; ++I) {
Expand All @@ -314,6 +315,25 @@ void RenameIndependentSubregs::computeMainRangesFixFlags(

LI.removeEmptySubRanges();

// Try to establish a single subregister which covers all uses.
// Note: this is assuming the selected subregister will only be
// used for fixing up live intervals issues created by this pass.
LaneBitmask UsedMask, UnusedMask;
for (LiveInterval::SubRange &SR : LI.subranges())
UsedMask |= SR.LaneMask;
SmallVector<unsigned> SubRegIdxs;
unsigned Flags = 0;
unsigned SubReg = 0;
// TODO: Handle SubRegIdxs.size() > 1
if (TRI.getCoveringSubRegIndexes(MRI->getRegClass(Reg), UsedMask,
SubRegIdxs) &&
SubRegIdxs.size() == 1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should do this even for the multiple subreg case, but can leave for todo

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree it would be nice to handle, but potentially more complex/risky for unknown gain.
I will look at it is as a follow up.
I have added a comment to that effect.

SubReg = SubRegIdxs.front();
Flags = RegState::Undef;
} else {
UnusedMask = MRI->getMaxLaneMaskForVReg(Reg) & ~UsedMask;
}

// There must be a def (or live-in) before every use. Splitting vregs may
// violate this principle as the splitted vreg may not have a definition on
// every path. Fix this by creating IMPLICIT_DEF instruction as necessary.
Expand All @@ -336,19 +356,18 @@ void RenameIndependentSubregs::computeMainRangesFixFlags(
MachineBasicBlock::iterator InsertPos =
llvm::findPHICopyInsertPoint(PredMBB, &MBB, Reg);
const MCInstrDesc &MCDesc = TII->get(TargetOpcode::IMPLICIT_DEF);
MachineInstrBuilder ImpDef = BuildMI(*PredMBB, InsertPos,
DebugLoc(), MCDesc, Reg);
MachineInstrBuilder ImpDef =
BuildMI(*PredMBB, InsertPos, DebugLoc(), MCDesc)
.addDef(Reg, Flags, SubReg);
SlotIndex DefIdx = LIS->InsertMachineInstrInMaps(*ImpDef);
SlotIndex RegDefIdx = DefIdx.getRegSlot();
LaneBitmask Mask = MRI->getMaxLaneMaskForVReg(Reg);
for (LiveInterval::SubRange &SR : LI.subranges()) {
Mask = Mask & ~SR.LaneMask;
VNInfo *SRVNI = SR.getNextValue(RegDefIdx, Allocator);
SR.addSegment(LiveRange::Segment(RegDefIdx, PredEnd, SRVNI));
}

if (!Mask.none()) {
LiveInterval::SubRange *SR = LI.createSubRange(Allocator, Mask);
if (!UnusedMask.none()) {
LiveInterval::SubRange *SR =
LI.createSubRange(Allocator, UnusedMask);
SR->createDeadDef(RegDefIdx, Allocator);
}
}
Expand Down
315 changes: 147 additions & 168 deletions llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.intersect_ray.ll

Large diffs are not rendered by default.

14,172 changes: 5,478 additions & 8,694 deletions llvm/test/CodeGen/AMDGPU/amdgcn.bitcast.1024bit.ll

Large diffs are not rendered by default.

2,728 changes: 688 additions & 2,040 deletions llvm/test/CodeGen/AMDGPU/amdgcn.bitcast.640bit.ll

Large diffs are not rendered by default.

2,816 changes: 712 additions & 2,104 deletions llvm/test/CodeGen/AMDGPU/amdgcn.bitcast.704bit.ll

Large diffs are not rendered by default.

2,904 changes: 736 additions & 2,168 deletions llvm/test/CodeGen/AMDGPU/amdgcn.bitcast.768bit.ll

Large diffs are not rendered by default.

2,984 changes: 752 additions & 2,232 deletions llvm/test/CodeGen/AMDGPU/amdgcn.bitcast.832bit.ll

Large diffs are not rendered by default.

3,024 changes: 768 additions & 2,256 deletions llvm/test/CodeGen/AMDGPU/amdgcn.bitcast.896bit.ll

Large diffs are not rendered by default.

3,048 changes: 768 additions & 2,280 deletions llvm/test/CodeGen/AMDGPU/amdgcn.bitcast.960bit.ll

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions llvm/test/CodeGen/AMDGPU/collapse-endcf.ll
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ define void @scc_liveness(i32 %arg) local_unnamed_addr #0 {
; GCN-NEXT: v_cmp_gt_i32_e32 vcc, s4, v0
; GCN-NEXT: v_cmp_eq_u32_e64 s[4:5], 0, v0
; GCN-NEXT: s_mov_b64 s[8:9], 0
; GCN-NEXT: v_mov_b32_e32 v7, 0
; GCN-NEXT: v_mov_b32_e32 v0, 0
; GCN-NEXT: s_mov_b64 s[6:7], 0
; GCN-NEXT: s_branch .LBB5_3
; GCN-NEXT: .LBB5_1: ; %Flow
Expand All @@ -1004,36 +1004,36 @@ define void @scc_liveness(i32 %arg) local_unnamed_addr #0 {
; GCN-NEXT: ; %bb.4: ; %bb2
; GCN-NEXT: ; in Loop: Header=BB5_3 Depth=1
; GCN-NEXT: s_or_b64 exec, exec, s[6:7]
; GCN-NEXT: v_mov_b32_e32 v8, v7
; GCN-NEXT: v_mov_b32_e32 v2, v7
; GCN-NEXT: v_mov_b32_e32 v6, v7
; GCN-NEXT: v_mov_b32_e32 v1, v0
; GCN-NEXT: v_mov_b32_e32 v2, v0
; GCN-NEXT: v_mov_b32_e32 v3, v0
; GCN-NEXT: s_and_saveexec_b64 s[10:11], s[4:5]
; GCN-NEXT: s_cbranch_execz .LBB5_2
; GCN-NEXT: ; %bb.5: ; %bb4
; GCN-NEXT: ; in Loop: Header=BB5_3 Depth=1
; GCN-NEXT: buffer_load_dword v0, v0, s[0:3], 0 offen
; GCN-NEXT: v_mov_b32_e32 v8, v7
; GCN-NEXT: v_mov_b32_e32 v2, v7
; GCN-NEXT: v_mov_b32_e32 v6, v7
; GCN-NEXT: buffer_load_dword v3, v0, s[0:3], 0 offen
; GCN-NEXT: v_mov_b32_e32 v1, v0
; GCN-NEXT: v_mov_b32_e32 v2, v0
; GCN-NEXT: s_waitcnt vmcnt(0)
; GCN-NEXT: v_cmp_gt_f32_e64 s[6:7], 0, v0
; GCN-NEXT: v_cmp_gt_f32_e64 s[6:7], 0, v3
; GCN-NEXT: v_mov_b32_e32 v3, v0
; GCN-NEXT: s_and_saveexec_b64 s[12:13], s[6:7]
; GCN-NEXT: s_cbranch_execz .LBB5_1
; GCN-NEXT: ; %bb.6: ; %bb8
; GCN-NEXT: ; in Loop: Header=BB5_3 Depth=1
; GCN-NEXT: v_mov_b32_e32 v8, v7
; GCN-NEXT: ; implicit-def: $vgpr0_vgpr1_vgpr2_vgpr3
; GCN-NEXT: ; implicit-def: $vgpr3_vgpr4_vgpr5_vgpr6
; GCN-NEXT: v_mov_b32_e32 v1, v0
; GCN-NEXT: ; implicit-def: $vgpr2
; GCN-NEXT: ; implicit-def: $vgpr3
; GCN-NEXT: s_branch .LBB5_1
; GCN-NEXT: .LBB5_7: ; %bb12
; GCN-NEXT: s_or_b64 exec, exec, s[8:9]
; GCN-NEXT: buffer_store_dword v6, v0, s[0:3], 0 offen
; GCN-NEXT: buffer_store_dword v3, v0, s[0:3], 0 offen
; GCN-NEXT: s_waitcnt vmcnt(0)
; GCN-NEXT: buffer_store_dword v2, v0, s[0:3], 0 offen
; GCN-NEXT: s_waitcnt vmcnt(0)
; GCN-NEXT: buffer_store_dword v8, v0, s[0:3], 0 offen
; GCN-NEXT: buffer_store_dword v1, v0, s[0:3], 0 offen
; GCN-NEXT: s_waitcnt vmcnt(0)
; GCN-NEXT: buffer_store_dword v7, v0, s[0:3], 0 offen
; GCN-NEXT: buffer_store_dword v0, v0, s[0:3], 0 offen
; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0)
; GCN-NEXT: s_setpc_b64 s[30:31]
;
Expand Down
Loading