Skip to content

Commit 2952af3

Browse files
author
git apple-llvm automerger
committed
Merge commit '3e55c84ab684' from llvm.org/release/21.x into stable/21.x
2 parents e5d2822 + 3e55c84 commit 2952af3

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

llvm/lib/Target/PowerPC/PPCRegisterInfo.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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,

llvm/test/CodeGen/PowerPC/NoCRFieldRedefWhenSpillingCRBIT.mir

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# RUN: llc -mcpu=pwr8 -mtriple=powerpc64le-unknown-linux-gnu -start-after \
22
# RUN: virtregrewriter -ppc-asm-full-reg-names -verify-machineinstrs %s \
33
# RUN: -o - | FileCheck %s
4+
# RUN: llc -mcpu=pwr9 -mtriple=powerpc64le-unknown-linux-gnu -start-after \
5+
# RUN: virtregrewriter -ppc-asm-full-reg-names -verify-machineinstrs %s \
6+
# RUN: -o - | FileCheck %s
7+
# RUN: llc -mcpu=pwr10 -mtriple=powerpc64le-unknown-linux-gnu -start-after \
8+
# RUN: virtregrewriter -ppc-asm-full-reg-names -verify-machineinstrs %s \
9+
# RUN: -o - | FileCheck %s
410

511
--- |
612
; ModuleID = 'a.ll'
@@ -30,7 +36,7 @@
3036
; Function Attrs: nounwind
3137
declare void @llvm.stackprotector(ptr, ptr) #1
3238

33-
attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="ppc64le" "target-features"="+altivec,+bpermd,+crypto,+direct-move,+extdiv,+htm,+power8-vector,+vsx,-power9-vector" "unsafe-fp-math"="false" "use-soft-float"="false" }
39+
attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
3440
attributes #1 = { nounwind }
3541

3642
!llvm.ident = !{!0}

0 commit comments

Comments
 (0)