@@ -8269,19 +8269,32 @@ AArch64InstrInfo::isCopyInstrImpl(const MachineInstr &MI) const {
8269
8269
// and zero immediate operands used as an alias for mov instruction.
8270
8270
if (MI.getOpcode () == AArch64::ORRWrs &&
8271
8271
MI.getOperand (1 ).getReg () == AArch64::WZR &&
8272
- MI.getOperand (3 ).getImm () == 0x0 ) {
8272
+ MI.getOperand (3 ).getImm () == 0x0 &&
8273
+ // Check that the w->w move is not a zero-extending w->x mov.
8274
+ (!MI.getOperand (0 ).getReg ().isVirtual () ||
8275
+ MI.getOperand (0 ).getSubReg () == 0 ) &&
8276
+ (!MI.getOperand (0 ).getReg ().isPhysical () ||
8277
+ MI.findRegisterDefOperandIdx (MI.getOperand (0 ).getReg () - AArch64::W0 +
8278
+ AArch64::X0) == -1 ))
8273
8279
return DestSourcePair{MI.getOperand (0 ), MI.getOperand (2 )};
8274
- }
8275
8280
8276
8281
if (MI.getOpcode () == AArch64::ORRXrs &&
8277
8282
MI.getOperand (1 ).getReg () == AArch64::XZR &&
8278
- MI.getOperand (3 ).getImm () == 0x0 ) {
8283
+ MI.getOperand (3 ).getImm () == 0x0 )
8279
8284
return DestSourcePair{MI.getOperand (0 ), MI.getOperand (2 )};
8280
- }
8281
8285
8282
8286
return std::nullopt;
8283
8287
}
8284
8288
8289
+ std::optional<DestSourcePair>
8290
+ AArch64InstrInfo::isCopyLikeInstrImpl (const MachineInstr &MI) const {
8291
+ if (MI.getOpcode () == AArch64::ORRWrs &&
8292
+ MI.getOperand (1 ).getReg () == AArch64::WZR &&
8293
+ MI.getOperand (3 ).getImm () == 0x0 )
8294
+ return DestSourcePair{MI.getOperand (0 ), MI.getOperand (2 )};
8295
+ return std::nullopt;
8296
+ }
8297
+
8285
8298
std::optional<RegImmPair>
8286
8299
AArch64InstrInfo::isAddImmediate (const MachineInstr &MI, Register Reg) const {
8287
8300
int Sign = 1 ;
@@ -8325,7 +8338,7 @@ static std::optional<ParamLoadedValue>
8325
8338
describeORRLoadedValue (const MachineInstr &MI, Register DescribedReg,
8326
8339
const TargetInstrInfo *TII,
8327
8340
const TargetRegisterInfo *TRI) {
8328
- auto DestSrc = TII->isCopyInstr (MI);
8341
+ auto DestSrc = TII->isCopyLikeInstr (MI);
8329
8342
if (!DestSrc)
8330
8343
return std::nullopt;
8331
8344
0 commit comments