@@ -708,12 +708,22 @@ RegisterBankInfo::OperandsMapper::getNewVRegsEnd(unsigned StartIdx,
708708 : &NewVRegs[StartIdx + NumVal];
709709}
710710
711+ static LLT inferType (LLT OrigType,
712+ const RegisterBankInfo::PartialMapping &PartMap) {
713+ if (PartMap.StartIdx == 0 && PartMap.Length == OrigType.getSizeInBits ())
714+ return OrigType;
715+ // TODO: check if this is a full lane of a vector type and extract the
716+ // element type.
717+ return LLT::integer (PartMap.Length );
718+ }
719+
711720void RegisterBankInfo::OperandsMapper::createVRegs (unsigned OpIdx) {
712721 assert (OpIdx < getInstrMapping ().getNumOperands () && " Out-of-bound access" );
713722 iterator_range<SmallVectorImpl<Register>::iterator> NewVRegsForOpIdx =
714723 getVRegsMem (OpIdx);
715724 const ValueMapping &ValMapping = getInstrMapping ().getOperandMapping (OpIdx);
716725 const PartialMapping *PartMap = ValMapping.begin ();
726+ LLT OrigType = getMRI ().getType (getMI ().getOperand (OpIdx).getReg ());
717727 for (Register &NewVReg : NewVRegsForOpIdx) {
718728 assert (PartMap != ValMapping.end () && " Out-of-bound access" );
719729 assert (NewVReg == 0 && " Register has already been created" );
@@ -722,7 +732,8 @@ void RegisterBankInfo::OperandsMapper::createVRegs(unsigned OpIdx) {
722732 // of the instruction.
723733 // The rationale is that this generic code cannot guess how the
724734 // target plans to split the input type.
725- NewVReg = MRI.createGenericVirtualRegister (LLT::scalar (PartMap->Length ));
735+ LLT NewType = inferType (OrigType, *PartMap);
736+ NewVReg = MRI.createGenericVirtualRegister (NewType);
726737 MRI.setRegBank (NewVReg, *PartMap->RegBank );
727738 ++PartMap;
728739 }
0 commit comments