Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 774415b

Browse files
committed
Remove unnecessary call to getAllocatableRegClass
This reapplies r252565 and r252674, effectively reverting r252956. This allows VS_32/VS_64 to be unallocatable like they should be. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280783 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 4cf44f1 commit 774415b

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

lib/CodeGen/SelectionDAG/InstrEmitter.cpp

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -330,16 +330,22 @@ InstrEmitter::AddRegisterOperand(MachineInstrBuilder &MIB,
330330
// shrink VReg's register class within reason. For example, if VReg == GR32
331331
// and II requires a GR32_NOSP, just constrain VReg to GR32_NOSP.
332332
if (II) {
333-
const TargetRegisterClass *DstRC = nullptr;
333+
const TargetRegisterClass *OpRC = nullptr;
334334
if (IIOpNum < II->getNumOperands())
335-
DstRC = TRI->getAllocatableClass(TII->getRegClass(*II,IIOpNum,TRI,*MF));
336-
assert((!DstRC || TargetRegisterInfo::isVirtualRegister(VReg)) &&
337-
"Expected VReg");
338-
if (DstRC && !MRI->constrainRegClass(VReg, DstRC, MinRCSize)) {
339-
unsigned NewVReg = MRI->createVirtualRegister(DstRC);
340-
BuildMI(*MBB, InsertPos, Op.getNode()->getDebugLoc(),
341-
TII->get(TargetOpcode::COPY), NewVReg).addReg(VReg);
342-
VReg = NewVReg;
335+
OpRC = TII->getRegClass(*II, IIOpNum, TRI, *MF);
336+
337+
if (OpRC) {
338+
const TargetRegisterClass *ConstrainedRC
339+
= MRI->constrainRegClass(VReg, OpRC, MinRCSize);
340+
if (!ConstrainedRC) {
341+
unsigned NewVReg = MRI->createVirtualRegister(OpRC);
342+
BuildMI(*MBB, InsertPos, Op.getNode()->getDebugLoc(),
343+
TII->get(TargetOpcode::COPY), NewVReg).addReg(VReg);
344+
VReg = NewVReg;
345+
} else {
346+
assert(ConstrainedRC->isAllocatable() &&
347+
"Constraining an allocatable VReg produced an unallocatable class?");
348+
}
343349
}
344350
}
345351

lib/Target/AMDGPU/SIRegisterInfo.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,6 @@ class SIRegisterInfo final : public AMDGPURegisterInfo {
107107
/// \returns true if this class contains VGPR registers.
108108
bool hasVGPRs(const TargetRegisterClass *RC) const;
109109

110-
/// returns true if this is a pseudoregister class combination of VGPRs and
111-
/// SGPRs for operand modeling. FIXME: We should set isAllocatable = 0 on
112-
/// them.
113-
static bool isPseudoRegClass(const TargetRegisterClass *RC) {
114-
return RC == &AMDGPU::VS_32RegClass || RC == &AMDGPU::VS_64RegClass;
115-
}
116-
117110
/// \returns A VGPR reg class with the same width as \p SRC
118111
const TargetRegisterClass *getEquivalentVGPRClass(
119112
const TargetRegisterClass *SRC) const;

lib/Target/AMDGPU/SIRegisterInfo.td

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,12 @@ def VReg_1 : RegisterClass<"AMDGPU", [i1], 32, (add VGPR_32)> {
346346
let Size = 32;
347347
}
348348

349-
def VS_32 : RegisterClass<"AMDGPU", [i32, f32], 32, (add VGPR_32, SReg_32)>;
349+
def VS_32 : RegisterClass<"AMDGPU", [i32, f32], 32, (add VGPR_32, SReg_32)> {
350+
let isAllocatable = 0;
351+
}
350352

351353
def VS_64 : RegisterClass<"AMDGPU", [i64, f64], 32, (add VReg_64, SReg_64)> {
352-
let CopyCost = 2;
354+
let isAllocatable = 0;
353355
}
354356

355357
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)