From e159d3cbfc250115d1244f3a6219436a52f90f86 Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Wed, 15 Sep 2021 13:52:32 -0700 Subject: [PATCH] [AArch64][GlobalISel] Use MI::getIntrinsicID in more spots. NFC. There's technically a difference in the logic used by these findIntrinsicID and MachineInstr::getIntrinsicID, but it shouldn't be a meaningful difference here, with G_INTRINSIC instructions. getIntrinsicID's "first non-def" logic should be correct for those. --- .../AArch64/GISel/AArch64InstructionSelector.cpp | 19 ++----------------- .../lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp | 11 +---------- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp index 6634a19..effe3ea 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp @@ -5201,17 +5201,6 @@ bool AArch64InstructionSelector::selectBuildVector(MachineInstr &I, return true; } -/// Helper function to find an intrinsic ID on an a MachineInstr. Returns the -/// ID if it exists, and 0 otherwise. -static unsigned findIntrinsicID(MachineInstr &I) { - auto IntrinOp = find_if(I.operands(), [&](const MachineOperand &Op) { - return Op.isIntrinsicID(); - }); - if (IntrinOp == I.operands_end()) - return 0; - return IntrinOp->getIntrinsicID(); -} - bool AArch64InstructionSelector::selectVectorLoadIntrinsic(unsigned Opc, unsigned NumVecs, MachineInstr &I) { @@ -5244,9 +5233,7 @@ bool AArch64InstructionSelector::selectVectorLoadIntrinsic(unsigned Opc, bool AArch64InstructionSelector::selectIntrinsicWithSideEffects( MachineInstr &I, MachineRegisterInfo &MRI) { // Find the intrinsic ID. - unsigned IntrinID = findIntrinsicID(I); - if (!IntrinID) - return false; + unsigned IntrinID = I.getIntrinsicID(); const LLT S8 = LLT::scalar(8); const LLT S16 = LLT::scalar(16); @@ -5365,9 +5352,7 @@ bool AArch64InstructionSelector::selectIntrinsicWithSideEffects( bool AArch64InstructionSelector::selectIntrinsic(MachineInstr &I, MachineRegisterInfo &MRI) { - unsigned IntrinID = findIntrinsicID(I); - if (!IntrinID) - return false; + unsigned IntrinID = I.getIntrinsicID(); switch (IntrinID) { default: diff --git a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp index 8fabf29..fbae7c5 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp @@ -933,18 +933,9 @@ bool AArch64LegalizerInfo::legalizeSmallCMGlobalValue( return true; } -static unsigned findIntrinsicID(MachineInstr &I) { - auto IntrinOp = find_if(I.operands(), [&](const MachineOperand &Op) { - return Op.isIntrinsicID(); - }); - if (IntrinOp == I.operands_end()) - return 0; - return IntrinOp->getIntrinsicID(); -} - bool AArch64LegalizerInfo::legalizeIntrinsic(LegalizerHelper &Helper, MachineInstr &MI) const { - switch (findIntrinsicID(MI)) { + switch (MI.getIntrinsicID()) { case Intrinsic::vacopy: { unsigned PtrSize = ST->isTargetILP32() ? 4 : 8; unsigned VaListSize = -- 2.7.4