Skip to content

Commit a7d5156

Browse files
committed
[NFC][AArch64] Flatten a branch on AArch64InstrInfo::copyPhysReg
Simplifies the code and improves readability.
1 parent f059d2b commit a7d5156

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

llvm/lib/Target/AArch64/AArch64InstrInfo.cpp

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5081,33 +5081,31 @@ void AArch64InstrInfo::copyPhysReg(MachineBasicBlock &MBB,
50815081
BuildMI(MBB, I, DL, get(AArch64::MOVZWi), DestReg)
50825082
.addImm(0)
50835083
.addImm(AArch64_AM::getShifterImm(AArch64_AM::LSL, 0));
5084+
} else if (Subtarget.hasZeroCycleRegMoveGPR64() &&
5085+
!Subtarget.hasZeroCycleRegMoveGPR32()) {
5086+
// Cyclone recognizes "ORR Xd, XZR, Xm" as a zero-cycle register move.
5087+
MCRegister DestRegX = TRI->getMatchingSuperReg(DestReg, AArch64::sub_32,
5088+
&AArch64::GPR64spRegClass);
5089+
assert(DestRegX.isValid() && "Destination super-reg not valid");
5090+
MCRegister SrcRegX =
5091+
SrcReg == AArch64::WZR
5092+
? AArch64::XZR
5093+
: TRI->getMatchingSuperReg(SrcReg, AArch64::sub_32,
5094+
&AArch64::GPR64spRegClass);
5095+
assert(SrcRegX.isValid() && "Source super-reg not valid");
5096+
// This instruction is reading and writing X registers. This may upset
5097+
// the register scavenger and machine verifier, so we need to indicate
5098+
// that we are reading an undefined value from SrcRegX, but a proper
5099+
// value from SrcReg.
5100+
BuildMI(MBB, I, DL, get(AArch64::ORRXrr), DestRegX)
5101+
.addReg(AArch64::XZR)
5102+
.addReg(SrcRegX, RegState::Undef)
5103+
.addReg(SrcReg, RegState::Implicit | getKillRegState(KillSrc));
50845104
} else {
5085-
if (Subtarget.hasZeroCycleRegMoveGPR64() &&
5086-
!Subtarget.hasZeroCycleRegMoveGPR32()) {
5087-
// Cyclone recognizes "ORR Xd, XZR, Xm" as a zero-cycle register move.
5088-
MCRegister DestRegX = TRI->getMatchingSuperReg(
5089-
DestReg, AArch64::sub_32, &AArch64::GPR64spRegClass);
5090-
assert(DestRegX.isValid() && "Destination super-reg not valid");
5091-
MCRegister SrcRegX =
5092-
SrcReg == AArch64::WZR
5093-
? AArch64::XZR
5094-
: TRI->getMatchingSuperReg(SrcReg, AArch64::sub_32,
5095-
&AArch64::GPR64spRegClass);
5096-
assert(SrcRegX.isValid() && "Source super-reg not valid");
5097-
// This instruction is reading and writing X registers. This may upset
5098-
// the register scavenger and machine verifier, so we need to indicate
5099-
// that we are reading an undefined value from SrcRegX, but a proper
5100-
// value from SrcReg.
5101-
BuildMI(MBB, I, DL, get(AArch64::ORRXrr), DestRegX)
5102-
.addReg(AArch64::XZR)
5103-
.addReg(SrcRegX, RegState::Undef)
5104-
.addReg(SrcReg, RegState::Implicit | getKillRegState(KillSrc));
5105-
} else {
5106-
// Otherwise, expand to ORR WZR.
5107-
BuildMI(MBB, I, DL, get(AArch64::ORRWrr), DestReg)
5108-
.addReg(AArch64::WZR)
5109-
.addReg(SrcReg, getKillRegState(KillSrc));
5110-
}
5105+
// Otherwise, expand to ORR WZR.
5106+
BuildMI(MBB, I, DL, get(AArch64::ORRWrr), DestReg)
5107+
.addReg(AArch64::WZR)
5108+
.addReg(SrcReg, getKillRegState(KillSrc));
51115109
}
51125110
return;
51135111
}

0 commit comments

Comments
 (0)