Skip to content

Commit b9ea24b

Browse files
committed
Normalize XZR to no-reg instead, as it never violates register class
1 parent f7d5f4d commit b9ea24b

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3128,17 +3128,18 @@ void AArch64TargetLowering::fixupBlendComponents(
31283128
IntDisc = MaybeBlend->getOperand(2).getImm();
31293129
} else if (MaybeBlend->getOpcode() == AArch64::MOVi32imm &&
31303130
isUInt<16>(MaybeBlend->getOperand(1).getImm())) {
3131-
AddrDisc = AArch64::XZR;
3131+
AddrDisc = AArch64::NoRegister;
31323132
IntDisc = MaybeBlend->getOperand(1).getImm();
31333133
}
31343134
}
31353135

3136-
// Normalize NoRegister operands emitted by GlobalISel.
3137-
if (AddrDisc == AArch64::NoRegister)
3138-
AddrDisc = AArch64::XZR;
3136+
// For uniformity, always use NoRegister, as XZR is not necessarily contained
3137+
// in the requested register class.
3138+
if (AddrDisc == AArch64::XZR)
3139+
AddrDisc = AArch64::NoRegister;
31393140

31403141
// Make sure AddrDisc operand respects the register class imposed by MI.
3141-
if (AddrDisc != AArch64::XZR && MRI.getRegClass(AddrDisc) != AddrDiscRC) {
3142+
if (AddrDisc && MRI.getRegClass(AddrDisc) != AddrDiscRC) {
31423143
Register TmpReg = MRI.createVirtualRegister(AddrDiscRC);
31433144
BuildMI(*BB, MI, DL, TII->get(AArch64::COPY), TmpReg).addReg(AddrDisc);
31443145
AddrDisc = TmpReg;

llvm/test/CodeGen/AArch64/ptrauth-isel.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ define i64 @small_imm_disc(i64 %addr) {
3030
; DAGISEL-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0
3131
; DAGISEL-NEXT: [[MOVi32imm:%[0-9]+]]:gpr32 = MOVi32imm 42
3232
; DAGISEL-NEXT: [[SUBREG_TO_REG:%[0-9]+]]:gpr64noip = SUBREG_TO_REG 0, killed [[MOVi32imm]], %subreg.sub_32
33-
; DAGISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, killed $xzr, implicit-def dead $x17
33+
; DAGISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, killed $noreg, implicit-def dead $x17
3434
; DAGISEL-NEXT: $x0 = COPY [[PAC]]
3535
; DAGISEL-NEXT: RET_ReallyLR implicit $x0
3636
;
@@ -41,7 +41,7 @@ define i64 @small_imm_disc(i64 %addr) {
4141
; GISEL-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0
4242
; GISEL-NEXT: [[MOVi32imm:%[0-9]+]]:gpr32 = MOVi32imm 42
4343
; GISEL-NEXT: [[SUBREG_TO_REG:%[0-9]+]]:gpr64noip = SUBREG_TO_REG 0, [[MOVi32imm]], %subreg.sub_32
44-
; GISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, $xzr, implicit-def dead $x17
44+
; GISEL-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, $noreg, implicit-def dead $x17
4545
; GISEL-NEXT: $x0 = COPY [[PAC]]
4646
; GISEL-NEXT: RET_ReallyLR implicit $x0
4747
entry:

0 commit comments

Comments
 (0)