Skip to content

Commit 155e824

Browse files
tomershafiraokblast
authored andcommitted
[NFC][AArch64] Flatten a branch on AArch64InstrInfo::copyPhysReg (#161138)
Simplifies the code and improves readability.
1 parent c149efa commit 155e824

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
@@ -5098,33 +5098,31 @@ void AArch64InstrInfo::copyPhysReg(MachineBasicBlock &MBB,
50985098
BuildMI(MBB, I, DL, get(AArch64::MOVZWi), DestReg)
50995099
.addImm(0)
51005100
.addImm(AArch64_AM::getShifterImm(AArch64_AM::LSL, 0));
5101+
} else if (Subtarget.hasZeroCycleRegMoveGPR64() &&
5102+
!Subtarget.hasZeroCycleRegMoveGPR32()) {
5103+
// Cyclone recognizes "ORR Xd, XZR, Xm" as a zero-cycle register move.
5104+
MCRegister DestRegX = TRI->getMatchingSuperReg(DestReg, AArch64::sub_32,
5105+
&AArch64::GPR64spRegClass);
5106+
assert(DestRegX.isValid() && "Destination super-reg not valid");
5107+
MCRegister SrcRegX =
5108+
SrcReg == AArch64::WZR
5109+
? AArch64::XZR
5110+
: TRI->getMatchingSuperReg(SrcReg, AArch64::sub_32,
5111+
&AArch64::GPR64spRegClass);
5112+
assert(SrcRegX.isValid() && "Source super-reg not valid");
5113+
// This instruction is reading and writing X registers. This may upset
5114+
// the register scavenger and machine verifier, so we need to indicate
5115+
// that we are reading an undefined value from SrcRegX, but a proper
5116+
// value from SrcReg.
5117+
BuildMI(MBB, I, DL, get(AArch64::ORRXrr), DestRegX)
5118+
.addReg(AArch64::XZR)
5119+
.addReg(SrcRegX, RegState::Undef)
5120+
.addReg(SrcReg, RegState::Implicit | getKillRegState(KillSrc));
51015121
} else {
5102-
if (Subtarget.hasZeroCycleRegMoveGPR64() &&
5103-
!Subtarget.hasZeroCycleRegMoveGPR32()) {
5104-
// Cyclone recognizes "ORR Xd, XZR, Xm" as a zero-cycle register move.
5105-
MCRegister DestRegX = TRI->getMatchingSuperReg(
5106-
DestReg, AArch64::sub_32, &AArch64::GPR64spRegClass);
5107-
assert(DestRegX.isValid() && "Destination super-reg not valid");
5108-
MCRegister SrcRegX =
5109-
SrcReg == AArch64::WZR
5110-
? AArch64::XZR
5111-
: TRI->getMatchingSuperReg(SrcReg, AArch64::sub_32,
5112-
&AArch64::GPR64spRegClass);
5113-
assert(SrcRegX.isValid() && "Source super-reg not valid");
5114-
// This instruction is reading and writing X registers. This may upset
5115-
// the register scavenger and machine verifier, so we need to indicate
5116-
// that we are reading an undefined value from SrcRegX, but a proper
5117-
// value from SrcReg.
5118-
BuildMI(MBB, I, DL, get(AArch64::ORRXrr), DestRegX)
5119-
.addReg(AArch64::XZR)
5120-
.addReg(SrcRegX, RegState::Undef)
5121-
.addReg(SrcReg, RegState::Implicit | getKillRegState(KillSrc));
5122-
} else {
5123-
// Otherwise, expand to ORR WZR.
5124-
BuildMI(MBB, I, DL, get(AArch64::ORRWrr), DestReg)
5125-
.addReg(AArch64::WZR)
5126-
.addReg(SrcReg, getKillRegState(KillSrc));
5127-
}
5122+
// Otherwise, expand to ORR WZR.
5123+
BuildMI(MBB, I, DL, get(AArch64::ORRWrr), DestReg)
5124+
.addReg(AArch64::WZR)
5125+
.addReg(SrcReg, getKillRegState(KillSrc));
51285126
}
51295127
return;
51305128
}

0 commit comments

Comments
 (0)