@@ -341,15 +341,15 @@ bool RISCVExpandPseudo::expandRV32ZdinxStore(MachineBasicBlock &MBB,
341341 .addImm (MBBI->getOperand (2 ).getImm () + 4 );
342342 }
343343
344- if (!MBBI->memoperands_empty ()) {
345- assert (MBBI->hasOneMemOperand () && " Expected mem operand" );
346- MachineMemOperand *OldMMO = MBBI->memoperands ().front ();
347- MachineFunction *MF = MBB.getParent ();
348- MachineMemOperand *MMOLo = MF->getMachineMemOperand (OldMMO, 0 , 4 );
349- MachineMemOperand *MMOHi = MF->getMachineMemOperand (OldMMO, 4 , 4 );
350- MIBLo.setMemRefs (MMOLo);
351- MIBHi.setMemRefs (MMOHi);
344+ MachineFunction *MF = MBB.getParent ();
345+ SmallVector<MachineMemOperand *> NewLoMMOs;
346+ SmallVector<MachineMemOperand *> NewHiMMOs;
347+ for (const MachineMemOperand *MMO : MBBI->memoperands ()) {
348+ NewLoMMOs.push_back (MF->getMachineMemOperand (MMO, 0 , 4 ));
349+ NewHiMMOs.push_back (MF->getMachineMemOperand (MMO, 4 , 4 ));
352350 }
351+ MIBLo.setMemRefs (NewLoMMOs);
352+ MIBHi.setMemRefs (NewHiMMOs);
353353
354354 MBBI->eraseFromParent ();
355355 return true ;
@@ -401,15 +401,15 @@ bool RISCVExpandPseudo::expandRV32ZdinxLoad(MachineBasicBlock &MBB,
401401 .add (MBBI->getOperand (2 ));
402402 }
403403
404- if (!MBBI->memoperands_empty ()) {
405- assert (MBBI->hasOneMemOperand () && " Expected mem operand" );
406- MachineMemOperand *OldMMO = MBBI->memoperands ().front ();
407- MachineFunction *MF = MBB.getParent ();
408- MachineMemOperand *MMOLo = MF->getMachineMemOperand (OldMMO, 0 , 4 );
409- MachineMemOperand *MMOHi = MF->getMachineMemOperand (OldMMO, 4 , 4 );
410- MIBLo.setMemRefs (MMOLo);
411- MIBHi.setMemRefs (MMOHi);
404+ MachineFunction *MF = MBB.getParent ();
405+ SmallVector<MachineMemOperand *> NewLoMMOs;
406+ SmallVector<MachineMemOperand *> NewHiMMOs;
407+ for (const MachineMemOperand *MMO : MBBI->memoperands ()) {
408+ NewLoMMOs.push_back (MF->getMachineMemOperand (MMO, 0 , 4 ));
409+ NewHiMMOs.push_back (MF->getMachineMemOperand (MMO, 4 , 4 ));
412410 }
411+ MIBLo.setMemRefs (NewLoMMOs);
412+ MIBHi.setMemRefs (NewHiMMOs);
413413
414414 MBBI->eraseFromParent ();
415415 return true ;
0 commit comments