@@ -310,10 +310,18 @@ RISCVRegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
310310 switch (Opc) {
311311 case TargetOpcode::G_LOAD: {
312312 LLT Ty = MRI.getType (MI.getOperand (0 ).getReg ());
313- OpdsMapping[0 ] = GPRValueMapping;
313+ TypeSize Size = Ty.getSizeInBits ();
314+ if (Ty.isVector ())
315+ OpdsMapping[0 ] = getVRBValueMapping (Size.getKnownMinValue ());
316+ else
317+ OpdsMapping[0 ] = GPRValueMapping;
318+
314319 OpdsMapping[1 ] = GPRValueMapping;
320+
321+ if (Ty.isVector ())
322+ break ;
315323 // Use FPR64 for s64 loads on rv32.
316- if (GPRSize == 32 && Ty. getSizeInBits () == 64 ) {
324+ if (GPRSize == 32 && Size. getFixedValue () == 64 ) {
317325 assert (MF.getSubtarget <RISCVSubtarget>().hasStdExtD ());
318326 OpdsMapping[0 ] = getFPValueMapping (Ty.getSizeInBits ());
319327 break ;
@@ -333,10 +341,19 @@ RISCVRegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
333341 }
334342 case TargetOpcode::G_STORE: {
335343 LLT Ty = MRI.getType (MI.getOperand (0 ).getReg ());
336- OpdsMapping[0 ] = GPRValueMapping;
344+ TypeSize Size = Ty.getSizeInBits ();
345+ if (Ty.isVector ())
346+ OpdsMapping[0 ] = getVRBValueMapping (Size.getKnownMinValue ());
347+ else
348+ OpdsMapping[0 ] = GPRValueMapping;
349+
337350 OpdsMapping[1 ] = GPRValueMapping;
351+
352+ if (Ty.isVector ())
353+ break ;
354+
338355 // Use FPR64 for s64 stores on rv32.
339- if (GPRSize == 32 && Ty. getSizeInBits () == 64 ) {
356+ if (GPRSize == 32 && Size. getFixedValue () == 64 ) {
340357 assert (MF.getSubtarget <RISCVSubtarget>().hasStdExtD ());
341358 OpdsMapping[0 ] = getFPValueMapping (Ty.getSizeInBits ());
342359 break ;
0 commit comments