[llvm] 6b4760a - [AMDGPU] Make use of composeSubRegIndices. NFCI. (#95548)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 14 07:07:09 PDT 2024
Author: Jay Foad
Date: 2024-06-14T15:07:04+01:00
New Revision: 6b4760acc73394f841fb66bfd04c501826f5c7f7
URL: https://github.com/llvm/llvm-project/commit/6b4760acc73394f841fb66bfd04c501826f5c7f7
DIFF: https://github.com/llvm/llvm-project/commit/6b4760acc73394f841fb66bfd04c501826f5c7f7.diff
LOG: [AMDGPU] Make use of composeSubRegIndices. NFCI. (#95548)
Simplify SIInstrInfo::buildExtractSubReg by building one COPY with a
composed subreg index instead of two COPYs.
Added:
Modified:
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
index 0edcdb337b5af..30c27b6439fc0 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
@@ -5651,24 +5651,9 @@ unsigned SIInstrInfo::buildExtractSubReg(
DebugLoc DL = MI->getDebugLoc();
Register SubReg = MRI.createVirtualRegister(SubRC);
- if (SuperReg.getSubReg() == AMDGPU::NoSubRegister) {
- BuildMI(*MBB, MI, DL, get(TargetOpcode::COPY), SubReg)
- .addReg(SuperReg.getReg(), 0, SubIdx);
- return SubReg;
- }
-
- // Just in case the super register is itself a sub-register, copy it to a new
- // value so we don't need to worry about merging its subreg index with the
- // SubIdx passed to this function. The register coalescer should be able to
- // eliminate this extra copy.
- Register NewSuperReg = MRI.createVirtualRegister(SuperRC);
-
- BuildMI(*MBB, MI, DL, get(TargetOpcode::COPY), NewSuperReg)
- .addReg(SuperReg.getReg(), 0, SuperReg.getSubReg());
-
+ unsigned NewSubIdx = RI.composeSubRegIndices(SuperReg.getSubReg(), SubIdx);
BuildMI(*MBB, MI, DL, get(TargetOpcode::COPY), SubReg)
- .addReg(NewSuperReg, 0, SubIdx);
-
+ .addReg(SuperReg.getReg(), 0, NewSubIdx);
return SubReg;
}
More information about the llvm-commits
mailing list