@@ -598,6 +598,9 @@ bool AArch64ExpandPseudo::expand_DestructiveOp(
598
598
llvm_unreachable (" Unsupported ElementSize" );
599
599
}
600
600
601
+ // Preserve undef state until DOP's reg is defined.
602
+ unsigned DOPRegState = MI.getOperand (DOPIdx).isUndef () ? RegState::Undef : 0 ;
603
+
601
604
//
602
605
// Create the destructive operation (if required)
603
606
//
@@ -616,10 +619,11 @@ bool AArch64ExpandPseudo::expand_DestructiveOp(
616
619
PRFX = BuildMI (MBB, MBBI, MI.getDebugLoc (), TII->get (MovPrfxZero))
617
620
.addReg (DstReg, RegState::Define)
618
621
.addReg (MI.getOperand (PredIdx).getReg ())
619
- .addReg (MI.getOperand (DOPIdx).getReg ());
622
+ .addReg (MI.getOperand (DOPIdx).getReg (), DOPRegState );
620
623
621
624
// After the movprfx, the destructive operand is same as Dst
622
625
DOPIdx = 0 ;
626
+ DOPRegState = 0 ;
623
627
624
628
// Create the additional LSL to zero the lanes when the DstReg is not
625
629
// unique. Zeros the lanes in z0 that aren't active in p0 with sequence
@@ -638,19 +642,21 @@ bool AArch64ExpandPseudo::expand_DestructiveOp(
638
642
assert (DOPRegIsUnique && " The destructive operand should be unique" );
639
643
PRFX = BuildMI (MBB, MBBI, MI.getDebugLoc (), TII->get (MovPrfx))
640
644
.addReg (DstReg, RegState::Define)
641
- .addReg (MI.getOperand (DOPIdx).getReg ());
645
+ .addReg (MI.getOperand (DOPIdx).getReg (), DOPRegState );
642
646
DOPIdx = 0 ;
647
+ DOPRegState = 0 ;
643
648
}
644
649
645
650
//
646
651
// Create the destructive operation
647
652
//
648
653
DOP = BuildMI (MBB, MBBI, MI.getDebugLoc (), TII->get (Opcode))
649
654
.addReg (DstReg, RegState::Define | getDeadRegState (DstIsDead));
655
+ DOPRegState = DOPRegState | RegState::Kill;
650
656
651
657
switch (DType) {
652
658
case AArch64::DestructiveUnaryPassthru:
653
- DOP.addReg (MI.getOperand (DOPIdx).getReg (), RegState::Kill )
659
+ DOP.addReg (MI.getOperand (DOPIdx).getReg (), DOPRegState )
654
660
.add (MI.getOperand (PredIdx))
655
661
.add (MI.getOperand (SrcIdx));
656
662
break ;
@@ -659,12 +665,12 @@ bool AArch64ExpandPseudo::expand_DestructiveOp(
659
665
case AArch64::DestructiveBinaryComm:
660
666
case AArch64::DestructiveBinaryCommWithRev:
661
667
DOP.add (MI.getOperand (PredIdx))
662
- .addReg (MI.getOperand (DOPIdx).getReg (), RegState::Kill )
663
- .add (MI.getOperand (SrcIdx));
668
+ .addReg (MI.getOperand (DOPIdx).getReg (), DOPRegState )
669
+ .add (MI.getOperand (SrcIdx));
664
670
break ;
665
671
case AArch64::DestructiveTernaryCommWithRev:
666
672
DOP.add (MI.getOperand (PredIdx))
667
- .addReg (MI.getOperand (DOPIdx).getReg (), RegState::Kill )
673
+ .addReg (MI.getOperand (DOPIdx).getReg (), DOPRegState )
668
674
.add (MI.getOperand (SrcIdx))
669
675
.add (MI.getOperand (Src2Idx));
670
676
break ;
0 commit comments