@@ -528,6 +528,10 @@ bool AArch64ExpandPseudo::expand_DestructiveOp(
528528 UseRev = true ;
529529 }
530530 break ;
531+ case AArch64::DestructiveRegRegImmUnpred:
532+ // EXT_ZZZI Zd, Zs1, Zs2, Imm ==> EXT_ZZI Zds1, Zs2, Imm
533+ std::tie (DOPIdx, SrcIdx, Src2Idx) = std::make_tuple (1 , 2 , 3 );
534+ break ;
531535 default :
532536 llvm_unreachable (" Unsupported Destructive Operand type" );
533537 }
@@ -538,6 +542,7 @@ bool AArch64ExpandPseudo::expand_DestructiveOp(
538542 bool DOPRegIsUnique = false ;
539543 switch (DType) {
540544 case AArch64::DestructiveBinary:
545+ case AArch64::DestructiveRegRegImmUnpred:
541546 DOPRegIsUnique = DstReg != MI.getOperand (SrcIdx).getReg ();
542547 break ;
543548 case AArch64::DestructiveBinaryComm:
@@ -639,10 +644,20 @@ bool AArch64ExpandPseudo::expand_DestructiveOp(
639644 .addImm (0 );
640645 }
641646 } else if (DstReg != MI.getOperand (DOPIdx).getReg ()) {
642- assert (DOPRegIsUnique && " The destructive operand should be unique" );
643- PRFX = BuildMI (MBB, MBBI, MI.getDebugLoc (), TII->get (MovPrfx))
644- .addReg (DstReg, RegState::Define)
645- .addReg (MI.getOperand (DOPIdx).getReg (), DOPRegState);
647+ if (DOPRegIsUnique) {
648+ PRFX = BuildMI (MBB, MBBI, MI.getDebugLoc (), TII->get (MovPrfx))
649+ .addReg (DstReg, RegState::Define)
650+ .addReg (MI.getOperand (DOPIdx).getReg (), DOPRegState);
651+ } else {
652+ // MOVPRFX requires unique operands: Just build a COPY (Using ORR directly
653+ // as we are past PostRAPseudo expansion).
654+ assert (DType == AArch64::DestructiveRegRegImmUnpred &&
655+ " Unexpected destructive operation type" );
656+ PRFX = BuildMI (MBB, MBBI, MI.getDebugLoc (), TII->get (AArch64::ORR_ZZZ))
657+ .addReg (DstReg, RegState::Define)
658+ .addReg (MI.getOperand (DOPIdx).getReg (), DOPRegState)
659+ .addReg (MI.getOperand (DOPIdx).getReg (), DOPRegState);
660+ }
646661 DOPIdx = 0 ;
647662 DOPRegState = 0 ;
648663 }
@@ -674,6 +689,11 @@ bool AArch64ExpandPseudo::expand_DestructiveOp(
674689 .add (MI.getOperand (SrcIdx))
675690 .add (MI.getOperand (Src2Idx));
676691 break ;
692+ case AArch64::DestructiveRegRegImmUnpred:
693+ DOP.addReg (MI.getOperand (DOPIdx).getReg (), DOPRegState)
694+ .add (MI.getOperand (SrcIdx))
695+ .add (MI.getOperand (Src2Idx));
696+ break ;
677697 }
678698
679699 if (PRFX) {
0 commit comments