Index: llvm/trunk/lib/CodeGen/SplitKit.cpp =================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp +++ llvm/trunk/lib/CodeGen/SplitKit.cpp @@ -522,6 +522,27 @@ Def = LIS.getSlotIndexes() ->insertMachineInstrInMaps(*CopyMI, Late) .getRegSlot(); + if (LI->hasSubRanges()) { + LaneBitmask LM = LaneBitmask::getNone(); + for (LiveInterval::SubRange &S : LI->subranges()) + LM |= S.LaneMask; + + if (MRI.getMaxLaneMaskForVReg(LI->reg) != LM) { + // Find subreg for the lane mask. + unsigned SubIdx = 0; + for (unsigned I = 1, E = TRI.getNumSubRegIndices(); I < E; ++I) { + if (TRI.getSubRegIndexLaneMask(I) == LM) { + SubIdx = I; + break; + } + } + if (SubIdx == 0) + report_fatal_error("Cannot find subreg index to cover all alive lanes"); + CopyMI->getOperand(0).setSubReg(SubIdx); + CopyMI->getOperand(1).setSubReg(SubIdx); + CopyMI->getOperand(0).setIsUndef(true); + } + } ++NumCopies; }