Skip to content

Commit 6b4760a

Browse files
authored
[AMDGPU] Make use of composeSubRegIndices. NFCI. (#95548)
Simplify SIInstrInfo::buildExtractSubReg by building one COPY with a composed subreg index instead of two COPYs.
1 parent db3a47c commit 6b4760a

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

llvm/lib/Target/AMDGPU/SIInstrInfo.cpp

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5651,24 +5651,9 @@ unsigned SIInstrInfo::buildExtractSubReg(
56515651
DebugLoc DL = MI->getDebugLoc();
56525652
Register SubReg = MRI.createVirtualRegister(SubRC);
56535653

5654-
if (SuperReg.getSubReg() == AMDGPU::NoSubRegister) {
5655-
BuildMI(*MBB, MI, DL, get(TargetOpcode::COPY), SubReg)
5656-
.addReg(SuperReg.getReg(), 0, SubIdx);
5657-
return SubReg;
5658-
}
5659-
5660-
// Just in case the super register is itself a sub-register, copy it to a new
5661-
// value so we don't need to worry about merging its subreg index with the
5662-
// SubIdx passed to this function. The register coalescer should be able to
5663-
// eliminate this extra copy.
5664-
Register NewSuperReg = MRI.createVirtualRegister(SuperRC);
5665-
5666-
BuildMI(*MBB, MI, DL, get(TargetOpcode::COPY), NewSuperReg)
5667-
.addReg(SuperReg.getReg(), 0, SuperReg.getSubReg());
5668-
5654+
unsigned NewSubIdx = RI.composeSubRegIndices(SuperReg.getSubReg(), SubIdx);
56695655
BuildMI(*MBB, MI, DL, get(TargetOpcode::COPY), SubReg)
5670-
.addReg(NewSuperReg, 0, SubIdx);
5671-
5656+
.addReg(SuperReg.getReg(), 0, NewSubIdx);
56725657
return SubReg;
56735658
}
56745659

0 commit comments

Comments
 (0)