Skip to content

Commit f245648

Browse files
committed
Use findRegisterDefOperandIdx
1 parent 736ba3a commit f245648

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

llvm/lib/Target/AArch64/AArch64InstrInfo.cpp

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9185,21 +9185,14 @@ AArch64InstrInfo::isCopyInstrImpl(const MachineInstr &MI) const {
91859185
// and zero immediate operands used as an alias for mov instruction.
91869186
if (MI.getOpcode() == AArch64::ORRWrs &&
91879187
MI.getOperand(1).getReg() == AArch64::WZR &&
9188-
MI.getOperand(3).getImm() == 0x0) {
9189-
Register Reg0 = MI.getOperand(0).getReg();
9190-
// ORRWrs is copy instruction when there's no implicit def of the X
9191-
// register.
9192-
if (Reg0.isPhysical()) {
9193-
const MachineFunction *MF = MI.getMF();
9194-
const TargetRegisterInfo *TRI = MF->getSubtarget().getRegisterInfo();
9195-
for (const MachineOperand &MO : MI.implicit_operands())
9196-
if (MO.isDef() && MO.isImplicit() &&
9197-
TRI->isSubRegister(MO.getReg(), Reg0)) {
9198-
return std::nullopt;
9199-
}
9200-
}
9188+
MI.getOperand(3).getImm() == 0x0 &&
9189+
// Check that the w->w move is not a zero-extending w->x mov.
9190+
(!MI.getOperand(0).getReg().isVirtual() ||
9191+
MI.getOperand(0).getSubReg() == 0) &&
9192+
(!MI.getOperand(0).getReg().isPhysical() ||
9193+
MI.findRegisterDefOperandIdx(MI.getOperand(0).getReg() - AArch64::W0 +
9194+
AArch64::X0) == -1))
92019195
return DestSourcePair{MI.getOperand(0), MI.getOperand(2)};
9202-
}
92039196

92049197
if (MI.getOpcode() == AArch64::ORRXrs &&
92059198
MI.getOperand(1).getReg() == AArch64::XZR &&

0 commit comments

Comments
 (0)