Skip to content

Commit 024af62

Browse files
author
git apple-llvm automerger
committed
Merge commit 'd6703bbe1853' from llvm.org/main into next
2 parents b2a29d9 + d6703bb commit 024af62

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ class AArch64InstructionSelector : public InstructionSelector {
310310
MachineIRBuilder &MIRBuilder) const;
311311
MachineInstr *emitSBCS(Register Dst, MachineOperand &LHS, MachineOperand &RHS,
312312
MachineIRBuilder &MIRBuilder) const;
313+
MachineInstr *emitCMP(MachineOperand &LHS, MachineOperand &RHS,
314+
MachineIRBuilder &MIRBuilder) const;
313315
MachineInstr *emitCMN(MachineOperand &LHS, MachineOperand &RHS,
314316
MachineIRBuilder &MIRBuilder) const;
315317
MachineInstr *emitTST(MachineOperand &LHS, MachineOperand &RHS,
@@ -4413,6 +4415,15 @@ AArch64InstructionSelector::emitSBCS(Register Dst, MachineOperand &LHS,
44134415
return emitInstr(OpcTable[Is32Bit], {Dst}, {LHS, RHS}, MIRBuilder);
44144416
}
44154417

4418+
MachineInstr *
4419+
AArch64InstructionSelector::emitCMP(MachineOperand &LHS, MachineOperand &RHS,
4420+
MachineIRBuilder &MIRBuilder) const {
4421+
MachineRegisterInfo &MRI = MIRBuilder.getMF().getRegInfo();
4422+
bool Is32Bit = MRI.getType(LHS.getReg()).getSizeInBits() == 32;
4423+
auto RC = Is32Bit ? &AArch64::GPR32RegClass : &AArch64::GPR64RegClass;
4424+
return emitSUBS(MRI.createVirtualRegister(RC), LHS, RHS, MIRBuilder);
4425+
}
4426+
44164427
MachineInstr *
44174428
AArch64InstructionSelector::emitCMN(MachineOperand &LHS, MachineOperand &RHS,
44184429
MachineIRBuilder &MIRBuilder) const {
@@ -4465,8 +4476,7 @@ MachineInstr *AArch64InstructionSelector::emitIntegerCompare(
44654476
// Fold the compare into a cmn or tst if possible.
44664477
if (auto FoldCmp = tryFoldIntegerCompare(LHS, RHS, Predicate, MIRBuilder))
44674478
return FoldCmp;
4468-
auto Dst = MRI.cloneVirtualRegister(LHS.getReg());
4469-
return emitSUBS(Dst, LHS, RHS, MIRBuilder);
4479+
return emitCMP(LHS, RHS, MIRBuilder);
44704480
}
44714481

44724482
MachineInstr *AArch64InstructionSelector::emitCSetForFCmp(
@@ -4871,9 +4881,8 @@ MachineInstr *AArch64InstructionSelector::emitConjunctionRec(
48714881

48724882
// Produce a normal comparison if we are first in the chain
48734883
if (!CCOp) {
4874-
auto Dst = MRI.cloneVirtualRegister(LHS);
48754884
if (isa<GICmp>(Cmp))
4876-
return emitSUBS(Dst, Cmp->getOperand(2), Cmp->getOperand(3), MIB);
4885+
return emitCMP(Cmp->getOperand(2), Cmp->getOperand(3), MIB);
48774886
return emitFPCompare(Cmp->getOperand(2).getReg(),
48784887
Cmp->getOperand(3).getReg(), MIB);
48794888
}

0 commit comments

Comments
 (0)