@@ -523,9 +523,14 @@ DemandedFields getDemanded(const MachineInstr &MI, const RISCVSubtarget *ST) {
523523 //
524524 // However it does need valid SEW, i.e. vill must be cleared. The entry to a
525525 // function, calls and inline assembly may all set it, so make sure we clear
526- // it for whole register copies.
527- if (isVectorCopy (ST->getRegisterInfo (), MI))
528- Res.VILL = true ;
526+ // it for whole register copies. Do this by leaving VILL demanded.
527+ if (isVectorCopy (ST->getRegisterInfo (), MI)) {
528+ Res.LMUL = DemandedFields::LMULNone;
529+ Res.SEW = DemandedFields::SEWNone;
530+ Res.SEWLMULRatio = false ;
531+ Res.TailPolicy = false ;
532+ Res.MaskPolicy = false ;
533+ }
529534
530535 return Res;
531536}
@@ -1463,10 +1468,13 @@ void RISCVInsertVSETVLI::emitVSETVLIs(MachineBasicBlock &MBB) {
14631468 PrefixTransparent = false ;
14641469 }
14651470
1466- if (isVectorCopy (ST->getRegisterInfo (), MI) &&
1467- !PrevInfo.isCompatible (DemandedFields::all (), CurInfo, LIS)) {
1468- insertVSETVLI (MBB, MI, MI.getDebugLoc (), CurInfo, PrevInfo);
1469- PrefixTransparent = false ;
1471+ if (isVectorCopy (ST->getRegisterInfo (), MI)) {
1472+ if (!PrevInfo.isCompatible (DemandedFields::all (), CurInfo, LIS)) {
1473+ insertVSETVLI (MBB, MI, MI.getDebugLoc (), CurInfo, PrevInfo);
1474+ PrefixTransparent = false ;
1475+ }
1476+ MI.addOperand (MachineOperand::CreateReg (RISCV::VTYPE, /* isDef*/ false ,
1477+ /* isImp*/ true ));
14701478 }
14711479
14721480 uint64_t TSFlags = MI.getDesc ().TSFlags ;
0 commit comments