// shrink VReg's register class within reason. For example, if VReg == GR32
// and II requires a GR32_NOSP, just constrain VReg to GR32_NOSP.
if (II) {
- const TargetRegisterClass *DstRC = nullptr;
+ const TargetRegisterClass *OpRC = nullptr;
if (IIOpNum < II->getNumOperands())
- DstRC = TRI->getAllocatableClass(TII->getRegClass(*II,IIOpNum,TRI,*MF));
- if (DstRC && !MRI->constrainRegClass(VReg, DstRC, MinRCSize)) {
- unsigned NewVReg = MRI->createVirtualRegister(DstRC);
+ OpRC = TII->getRegClass(*II, IIOpNum, TRI, *MF);
+
+ if (OpRC && !MRI->constrainRegClass(VReg, OpRC, MinRCSize)) {
+ assert(OpRC->isAllocatable() &&
+ "Constraining an allocatable VReg produced an unallocatable class?");
+
+ unsigned NewVReg = MRI->createVirtualRegister(OpRC);
BuildMI(*MBB, InsertPos, Op.getNode()->getDebugLoc(),
TII->get(TargetOpcode::COPY), NewVReg).addReg(VReg);
VReg = NewVReg;