@@ -1102,13 +1102,20 @@ void PPCRegisterInfo::lowerCRBitSpilling(MachineBasicBlock::iterator II,
11021102 SpillsKnownBit = true ;
11031103 break ;
11041104 default :
1105+ // When spilling a CR bit, the super register may not be explicitly defined
1106+ // (i.e. it can be defined by a CR-logical that only defines the subreg) so
1107+ // we state that the CR field is undef. Also, in order to preserve the kill
1108+ // flag on the CR bit, we add it as an implicit use.
1109+
11051110 // On Power10, we can use SETNBC to spill all CR bits. SETNBC will set all
11061111 // bits (specifically, it produces a -1 if the CR bit is set). Ultimately,
11071112 // the bit that is of importance to us is bit 32 (bit 0 of a 32-bit
11081113 // register), and SETNBC will set this.
11091114 if (Subtarget.isISA3_1 ()) {
11101115 BuildMI (MBB, II, dl, TII.get (LP64 ? PPC::SETNBC8 : PPC::SETNBC), Reg)
1111- .addReg (SrcReg, RegState::Undef);
1116+ .addReg (SrcReg, RegState::Undef)
1117+ .addReg (SrcReg, RegState::Implicit |
1118+ getKillRegState (MI.getOperand (0 ).isKill ()));
11121119 break ;
11131120 }
11141121
@@ -1122,16 +1129,14 @@ void PPCRegisterInfo::lowerCRBitSpilling(MachineBasicBlock::iterator II,
11221129 SrcReg == PPC::CR4LT || SrcReg == PPC::CR5LT ||
11231130 SrcReg == PPC::CR6LT || SrcReg == PPC::CR7LT) {
11241131 BuildMI (MBB, II, dl, TII.get (LP64 ? PPC::SETB8 : PPC::SETB), Reg)
1125- .addReg (getCRFromCRBit (SrcReg), RegState::Undef);
1132+ .addReg (getCRFromCRBit (SrcReg), RegState::Undef)
1133+ .addReg (SrcReg, RegState::Implicit |
1134+ getKillRegState (MI.getOperand (0 ).isKill ()));
11261135 break ;
11271136 }
11281137 }
11291138
11301139 // We need to move the CR field that contains the CR bit we are spilling.
1131- // The super register may not be explicitly defined (i.e. it can be defined
1132- // by a CR-logical that only defines the subreg) so we state that the CR
1133- // field is undef. Also, in order to preserve the kill flag on the CR bit,
1134- // we add it as an implicit use.
11351140 BuildMI (MBB, II, dl, TII.get (LP64 ? PPC::MFOCRF8 : PPC::MFOCRF), Reg)
11361141 .addReg (getCRFromCRBit (SrcReg), RegState::Undef)
11371142 .addReg (SrcReg,
0 commit comments