Path: blob/main/contrib/llvm-project/llvm/lib/Target/ARM/A15SDOptimizer.cpp
35266 views
//=== A15SDOptimizerPass.cpp - Optimize DPR and SPR register accesses on A15==//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// The Cortex-A15 processor employs a tracking scheme in its register renaming9// in order to process each instruction's micro-ops speculatively and10// out-of-order with appropriate forwarding. The ARM architecture allows VFP11// instructions to read and write 32-bit S-registers. Each S-register12// corresponds to one half (upper or lower) of an overlaid 64-bit D-register.13//14// There are several instruction patterns which can be used to provide this15// capability which can provide higher performance than other, potentially more16// direct patterns, specifically around when one micro-op reads a D-register17// operand that has recently been written as one or more S-register results.18//19// This file defines a pre-regalloc pass which looks for SPR producers which20// are going to be used by a DPR (or QPR) consumers and creates the more21// optimized access pattern.22//23//===----------------------------------------------------------------------===//2425#include "ARM.h"26#include "ARMBaseInstrInfo.h"27#include "ARMBaseRegisterInfo.h"28#include "ARMSubtarget.h"29#include "llvm/ADT/Statistic.h"30#include "llvm/CodeGen/MachineFunction.h"31#include "llvm/CodeGen/MachineFunctionPass.h"32#include "llvm/CodeGen/MachineInstr.h"33#include "llvm/CodeGen/MachineInstrBuilder.h"34#include "llvm/CodeGen/MachineRegisterInfo.h"35#include "llvm/CodeGen/TargetRegisterInfo.h"36#include "llvm/CodeGen/TargetSubtargetInfo.h"37#include "llvm/Support/Debug.h"38#include "llvm/Support/raw_ostream.h"39#include <map>40#include <set>4142using namespace llvm;4344#define DEBUG_TYPE "a15-sd-optimizer"4546namespace {47struct A15SDOptimizer : public MachineFunctionPass {48static char ID;49A15SDOptimizer() : MachineFunctionPass(ID) {}5051bool runOnMachineFunction(MachineFunction &Fn) override;5253StringRef getPassName() const override { return "ARM A15 S->D optimizer"; }5455private:56const ARMBaseInstrInfo *TII;57const TargetRegisterInfo *TRI;58MachineRegisterInfo *MRI;5960bool runOnInstruction(MachineInstr *MI);6162//63// Instruction builder helpers64//65unsigned createDupLane(MachineBasicBlock &MBB,66MachineBasicBlock::iterator InsertBefore,67const DebugLoc &DL, unsigned Reg, unsigned Lane,68bool QPR = false);6970unsigned createExtractSubreg(MachineBasicBlock &MBB,71MachineBasicBlock::iterator InsertBefore,72const DebugLoc &DL, unsigned DReg,73unsigned Lane, const TargetRegisterClass *TRC);7475unsigned createVExt(MachineBasicBlock &MBB,76MachineBasicBlock::iterator InsertBefore,77const DebugLoc &DL, unsigned Ssub0, unsigned Ssub1);7879unsigned createRegSequence(MachineBasicBlock &MBB,80MachineBasicBlock::iterator InsertBefore,81const DebugLoc &DL, unsigned Reg1,82unsigned Reg2);8384unsigned createInsertSubreg(MachineBasicBlock &MBB,85MachineBasicBlock::iterator InsertBefore,86const DebugLoc &DL, unsigned DReg,87unsigned Lane, unsigned ToInsert);8889unsigned createImplicitDef(MachineBasicBlock &MBB,90MachineBasicBlock::iterator InsertBefore,91const DebugLoc &DL);9293//94// Various property checkers95//96bool usesRegClass(MachineOperand &MO, const TargetRegisterClass *TRC);97bool hasPartialWrite(MachineInstr *MI);98SmallVector<unsigned, 8> getReadDPRs(MachineInstr *MI);99unsigned getDPRLaneFromSPR(unsigned SReg);100101//102// Methods used for getting the definitions of partial registers103//104105MachineInstr *elideCopies(MachineInstr *MI);106void elideCopiesAndPHIs(MachineInstr *MI,107SmallVectorImpl<MachineInstr*> &Outs);108109//110// Pattern optimization methods111//112unsigned optimizeAllLanesPattern(MachineInstr *MI, unsigned Reg);113unsigned optimizeSDPattern(MachineInstr *MI);114unsigned getPrefSPRLane(unsigned SReg);115116//117// Sanitizing method - used to make sure if don't leave dead code around.118//119void eraseInstrWithNoUses(MachineInstr *MI);120121//122// A map used to track the changes done by this pass.123//124std::map<MachineInstr*, unsigned> Replacements;125std::set<MachineInstr *> DeadInstr;126};127char A15SDOptimizer::ID = 0;128} // end anonymous namespace129130// Returns true if this is a use of a SPR register.131bool A15SDOptimizer::usesRegClass(MachineOperand &MO,132const TargetRegisterClass *TRC) {133if (!MO.isReg())134return false;135Register Reg = MO.getReg();136137if (Reg.isVirtual())138return MRI->getRegClass(Reg)->hasSuperClassEq(TRC);139else140return TRC->contains(Reg);141}142143unsigned A15SDOptimizer::getDPRLaneFromSPR(unsigned SReg) {144unsigned DReg = TRI->getMatchingSuperReg(SReg, ARM::ssub_1,145&ARM::DPRRegClass);146if (DReg != ARM::NoRegister) return ARM::ssub_1;147return ARM::ssub_0;148}149150// Get the subreg type that is most likely to be coalesced151// for an SPR register that will be used in VDUP32d pseudo.152unsigned A15SDOptimizer::getPrefSPRLane(unsigned SReg) {153if (!Register::isVirtualRegister(SReg))154return getDPRLaneFromSPR(SReg);155156MachineInstr *MI = MRI->getVRegDef(SReg);157if (!MI) return ARM::ssub_0;158MachineOperand *MO = MI->findRegisterDefOperand(SReg, /*TRI=*/nullptr);159if (!MO) return ARM::ssub_0;160assert(MO->isReg() && "Non-register operand found!");161162if (MI->isCopy() && usesRegClass(MI->getOperand(1),163&ARM::SPRRegClass)) {164SReg = MI->getOperand(1).getReg();165}166167if (Register::isVirtualRegister(SReg)) {168if (MO->getSubReg() == ARM::ssub_1) return ARM::ssub_1;169return ARM::ssub_0;170}171return getDPRLaneFromSPR(SReg);172}173174// MI is known to be dead. Figure out what instructions175// are also made dead by this and mark them for removal.176void A15SDOptimizer::eraseInstrWithNoUses(MachineInstr *MI) {177SmallVector<MachineInstr *, 8> Front;178DeadInstr.insert(MI);179180LLVM_DEBUG(dbgs() << "Deleting base instruction " << *MI << "\n");181Front.push_back(MI);182183while (Front.size() != 0) {184MI = Front.pop_back_val();185186// MI is already known to be dead. We need to see187// if other instructions can also be removed.188for (MachineOperand &MO : MI->operands()) {189if ((!MO.isReg()) || (!MO.isUse()))190continue;191Register Reg = MO.getReg();192if (!Reg.isVirtual())193continue;194MachineOperand *Op = MI->findRegisterDefOperand(Reg, /*TRI=*/nullptr);195196if (!Op)197continue;198199MachineInstr *Def = Op->getParent();200201// We don't need to do anything if we have already marked202// this instruction as being dead.203if (DeadInstr.find(Def) != DeadInstr.end())204continue;205206// Check if all the uses of this instruction are marked as207// dead. If so, we can also mark this instruction as being208// dead.209bool IsDead = true;210for (MachineOperand &MODef : Def->operands()) {211if ((!MODef.isReg()) || (!MODef.isDef()))212continue;213Register DefReg = MODef.getReg();214if (!DefReg.isVirtual()) {215IsDead = false;216break;217}218for (MachineInstr &Use : MRI->use_instructions(Reg)) {219// We don't care about self references.220if (&Use == Def)221continue;222if (DeadInstr.find(&Use) == DeadInstr.end()) {223IsDead = false;224break;225}226}227}228229if (!IsDead) continue;230231LLVM_DEBUG(dbgs() << "Deleting instruction " << *Def << "\n");232DeadInstr.insert(Def);233}234}235}236237// Creates the more optimized patterns and generally does all the code238// transformations in this pass.239unsigned A15SDOptimizer::optimizeSDPattern(MachineInstr *MI) {240if (MI->isCopy()) {241return optimizeAllLanesPattern(MI, MI->getOperand(1).getReg());242}243244if (MI->isInsertSubreg()) {245Register DPRReg = MI->getOperand(1).getReg();246Register SPRReg = MI->getOperand(2).getReg();247248if (DPRReg.isVirtual() && SPRReg.isVirtual()) {249MachineInstr *DPRMI = MRI->getVRegDef(MI->getOperand(1).getReg());250MachineInstr *SPRMI = MRI->getVRegDef(MI->getOperand(2).getReg());251252if (DPRMI && SPRMI) {253// See if the first operand of this insert_subreg is IMPLICIT_DEF254MachineInstr *ECDef = elideCopies(DPRMI);255if (ECDef && ECDef->isImplicitDef()) {256// Another corner case - if we're inserting something that is purely257// a subreg copy of a DPR, just use that DPR.258259MachineInstr *EC = elideCopies(SPRMI);260// Is it a subreg copy of ssub_0?261if (EC && EC->isCopy() &&262EC->getOperand(1).getSubReg() == ARM::ssub_0) {263LLVM_DEBUG(dbgs() << "Found a subreg copy: " << *SPRMI);264265// Find the thing we're subreg copying out of - is it of the same266// regclass as DPRMI? (i.e. a DPR or QPR).267Register FullReg = SPRMI->getOperand(1).getReg();268const TargetRegisterClass *TRC =269MRI->getRegClass(MI->getOperand(1).getReg());270if (TRC->hasSuperClassEq(MRI->getRegClass(FullReg))) {271LLVM_DEBUG(dbgs() << "Subreg copy is compatible - returning ");272LLVM_DEBUG(dbgs() << printReg(FullReg) << "\n");273eraseInstrWithNoUses(MI);274return FullReg;275}276}277278return optimizeAllLanesPattern(MI, MI->getOperand(2).getReg());279}280}281}282return optimizeAllLanesPattern(MI, MI->getOperand(0).getReg());283}284285if (MI->isRegSequence() && usesRegClass(MI->getOperand(1),286&ARM::SPRRegClass)) {287// See if all bar one of the operands are IMPLICIT_DEF and insert the288// optimizer pattern accordingly.289unsigned NumImplicit = 0, NumTotal = 0;290unsigned NonImplicitReg = ~0U;291292for (MachineOperand &MO : llvm::drop_begin(MI->explicit_operands())) {293if (!MO.isReg())294continue;295++NumTotal;296Register OpReg = MO.getReg();297298if (!OpReg.isVirtual())299break;300301MachineInstr *Def = MRI->getVRegDef(OpReg);302if (!Def)303break;304if (Def->isImplicitDef())305++NumImplicit;306else307NonImplicitReg = MO.getReg();308}309310if (NumImplicit == NumTotal - 1)311return optimizeAllLanesPattern(MI, NonImplicitReg);312else313return optimizeAllLanesPattern(MI, MI->getOperand(0).getReg());314}315316llvm_unreachable("Unhandled update pattern!");317}318319// Return true if this MachineInstr inserts a scalar (SPR) value into320// a D or Q register.321bool A15SDOptimizer::hasPartialWrite(MachineInstr *MI) {322// The only way we can do a partial register update is through a COPY,323// INSERT_SUBREG or REG_SEQUENCE.324if (MI->isCopy() && usesRegClass(MI->getOperand(1), &ARM::SPRRegClass))325return true;326327if (MI->isInsertSubreg() && usesRegClass(MI->getOperand(2),328&ARM::SPRRegClass))329return true;330331if (MI->isRegSequence() && usesRegClass(MI->getOperand(1), &ARM::SPRRegClass))332return true;333334return false;335}336337// Looks through full copies to get the instruction that defines the input338// operand for MI.339MachineInstr *A15SDOptimizer::elideCopies(MachineInstr *MI) {340if (!MI->isFullCopy())341return MI;342if (!MI->getOperand(1).getReg().isVirtual())343return nullptr;344MachineInstr *Def = MRI->getVRegDef(MI->getOperand(1).getReg());345if (!Def)346return nullptr;347return elideCopies(Def);348}349350// Look through full copies and PHIs to get the set of non-copy MachineInstrs351// that can produce MI.352void A15SDOptimizer::elideCopiesAndPHIs(MachineInstr *MI,353SmallVectorImpl<MachineInstr*> &Outs) {354// Looking through PHIs may create loops so we need to track what355// instructions we have visited before.356std::set<MachineInstr *> Reached;357SmallVector<MachineInstr *, 8> Front;358Front.push_back(MI);359while (Front.size() != 0) {360MI = Front.pop_back_val();361362// If we have already explored this MachineInstr, ignore it.363if (!Reached.insert(MI).second)364continue;365if (MI->isPHI()) {366for (unsigned I = 1, E = MI->getNumOperands(); I != E; I += 2) {367Register Reg = MI->getOperand(I).getReg();368if (!Reg.isVirtual()) {369continue;370}371MachineInstr *NewMI = MRI->getVRegDef(Reg);372if (!NewMI)373continue;374Front.push_back(NewMI);375}376} else if (MI->isFullCopy()) {377if (!MI->getOperand(1).getReg().isVirtual())378continue;379MachineInstr *NewMI = MRI->getVRegDef(MI->getOperand(1).getReg());380if (!NewMI)381continue;382Front.push_back(NewMI);383} else {384LLVM_DEBUG(dbgs() << "Found partial copy" << *MI << "\n");385Outs.push_back(MI);386}387}388}389390// Return the DPR virtual registers that are read by this machine instruction391// (if any).392SmallVector<unsigned, 8> A15SDOptimizer::getReadDPRs(MachineInstr *MI) {393if (MI->isCopyLike() || MI->isInsertSubreg() || MI->isRegSequence() ||394MI->isKill())395return SmallVector<unsigned, 8>();396397SmallVector<unsigned, 8> Defs;398for (MachineOperand &MO : MI->operands()) {399if (!MO.isReg() || !MO.isUse())400continue;401if (!usesRegClass(MO, &ARM::DPRRegClass) &&402!usesRegClass(MO, &ARM::QPRRegClass) &&403!usesRegClass(MO, &ARM::DPairRegClass)) // Treat DPair as QPR404continue;405406Defs.push_back(MO.getReg());407}408return Defs;409}410411// Creates a DPR register from an SPR one by using a VDUP.412unsigned A15SDOptimizer::createDupLane(MachineBasicBlock &MBB,413MachineBasicBlock::iterator InsertBefore,414const DebugLoc &DL, unsigned Reg,415unsigned Lane, bool QPR) {416Register Out =417MRI->createVirtualRegister(QPR ? &ARM::QPRRegClass : &ARM::DPRRegClass);418BuildMI(MBB, InsertBefore, DL,419TII->get(QPR ? ARM::VDUPLN32q : ARM::VDUPLN32d), Out)420.addReg(Reg)421.addImm(Lane)422.add(predOps(ARMCC::AL));423424return Out;425}426427// Creates a SPR register from a DPR by copying the value in lane 0.428unsigned A15SDOptimizer::createExtractSubreg(429MachineBasicBlock &MBB, MachineBasicBlock::iterator InsertBefore,430const DebugLoc &DL, unsigned DReg, unsigned Lane,431const TargetRegisterClass *TRC) {432Register Out = MRI->createVirtualRegister(TRC);433BuildMI(MBB,434InsertBefore,435DL,436TII->get(TargetOpcode::COPY), Out)437.addReg(DReg, 0, Lane);438439return Out;440}441442// Takes two SPR registers and creates a DPR by using a REG_SEQUENCE.443unsigned A15SDOptimizer::createRegSequence(444MachineBasicBlock &MBB, MachineBasicBlock::iterator InsertBefore,445const DebugLoc &DL, unsigned Reg1, unsigned Reg2) {446Register Out = MRI->createVirtualRegister(&ARM::QPRRegClass);447BuildMI(MBB,448InsertBefore,449DL,450TII->get(TargetOpcode::REG_SEQUENCE), Out)451.addReg(Reg1)452.addImm(ARM::dsub_0)453.addReg(Reg2)454.addImm(ARM::dsub_1);455return Out;456}457458// Takes two DPR registers that have previously been VDUPed (Ssub0 and Ssub1)459// and merges them into one DPR register.460unsigned A15SDOptimizer::createVExt(MachineBasicBlock &MBB,461MachineBasicBlock::iterator InsertBefore,462const DebugLoc &DL, unsigned Ssub0,463unsigned Ssub1) {464Register Out = MRI->createVirtualRegister(&ARM::DPRRegClass);465BuildMI(MBB, InsertBefore, DL, TII->get(ARM::VEXTd32), Out)466.addReg(Ssub0)467.addReg(Ssub1)468.addImm(1)469.add(predOps(ARMCC::AL));470return Out;471}472473unsigned A15SDOptimizer::createInsertSubreg(474MachineBasicBlock &MBB, MachineBasicBlock::iterator InsertBefore,475const DebugLoc &DL, unsigned DReg, unsigned Lane, unsigned ToInsert) {476Register Out = MRI->createVirtualRegister(&ARM::DPR_VFP2RegClass);477BuildMI(MBB,478InsertBefore,479DL,480TII->get(TargetOpcode::INSERT_SUBREG), Out)481.addReg(DReg)482.addReg(ToInsert)483.addImm(Lane);484485return Out;486}487488unsigned489A15SDOptimizer::createImplicitDef(MachineBasicBlock &MBB,490MachineBasicBlock::iterator InsertBefore,491const DebugLoc &DL) {492Register Out = MRI->createVirtualRegister(&ARM::DPRRegClass);493BuildMI(MBB,494InsertBefore,495DL,496TII->get(TargetOpcode::IMPLICIT_DEF), Out);497return Out;498}499500// This function inserts instructions in order to optimize interactions between501// SPR registers and DPR/QPR registers. It does so by performing VDUPs on all502// lanes, and the using VEXT instructions to recompose the result.503unsigned504A15SDOptimizer::optimizeAllLanesPattern(MachineInstr *MI, unsigned Reg) {505MachineBasicBlock::iterator InsertPt(MI);506DebugLoc DL = MI->getDebugLoc();507MachineBasicBlock &MBB = *MI->getParent();508InsertPt++;509unsigned Out;510511// DPair has the same length as QPR and also has two DPRs as subreg.512// Treat DPair as QPR.513if (MRI->getRegClass(Reg)->hasSuperClassEq(&ARM::QPRRegClass) ||514MRI->getRegClass(Reg)->hasSuperClassEq(&ARM::DPairRegClass)) {515unsigned DSub0 = createExtractSubreg(MBB, InsertPt, DL, Reg,516ARM::dsub_0, &ARM::DPRRegClass);517unsigned DSub1 = createExtractSubreg(MBB, InsertPt, DL, Reg,518ARM::dsub_1, &ARM::DPRRegClass);519520unsigned Out1 = createDupLane(MBB, InsertPt, DL, DSub0, 0);521unsigned Out2 = createDupLane(MBB, InsertPt, DL, DSub0, 1);522Out = createVExt(MBB, InsertPt, DL, Out1, Out2);523524unsigned Out3 = createDupLane(MBB, InsertPt, DL, DSub1, 0);525unsigned Out4 = createDupLane(MBB, InsertPt, DL, DSub1, 1);526Out2 = createVExt(MBB, InsertPt, DL, Out3, Out4);527528Out = createRegSequence(MBB, InsertPt, DL, Out, Out2);529530} else if (MRI->getRegClass(Reg)->hasSuperClassEq(&ARM::DPRRegClass)) {531unsigned Out1 = createDupLane(MBB, InsertPt, DL, Reg, 0);532unsigned Out2 = createDupLane(MBB, InsertPt, DL, Reg, 1);533Out = createVExt(MBB, InsertPt, DL, Out1, Out2);534535} else {536assert(MRI->getRegClass(Reg)->hasSuperClassEq(&ARM::SPRRegClass) &&537"Found unexpected regclass!");538539unsigned PrefLane = getPrefSPRLane(Reg);540unsigned Lane;541switch (PrefLane) {542case ARM::ssub_0: Lane = 0; break;543case ARM::ssub_1: Lane = 1; break;544default: llvm_unreachable("Unknown preferred lane!");545}546547// Treat DPair as QPR548bool UsesQPR = usesRegClass(MI->getOperand(0), &ARM::QPRRegClass) ||549usesRegClass(MI->getOperand(0), &ARM::DPairRegClass);550551Out = createImplicitDef(MBB, InsertPt, DL);552Out = createInsertSubreg(MBB, InsertPt, DL, Out, PrefLane, Reg);553Out = createDupLane(MBB, InsertPt, DL, Out, Lane, UsesQPR);554eraseInstrWithNoUses(MI);555}556return Out;557}558559bool A15SDOptimizer::runOnInstruction(MachineInstr *MI) {560// We look for instructions that write S registers that are then read as561// D/Q registers. These can only be caused by COPY, INSERT_SUBREG and562// REG_SEQUENCE pseudos that insert an SPR value into a DPR register or563// merge two SPR values to form a DPR register. In order avoid false564// positives we make sure that there is an SPR producer so we look past565// COPY and PHI nodes to find it.566//567// The best code pattern for when an SPR producer is going to be used by a568// DPR or QPR consumer depends on whether the other lanes of the569// corresponding DPR/QPR are currently defined.570//571// We can handle these efficiently, depending on the type of572// pseudo-instruction that is producing the pattern573//574// * COPY: * VDUP all lanes and merge the results together575// using VEXTs.576//577// * INSERT_SUBREG: * If the SPR value was originally in another DPR/QPR578// lane, and the other lane(s) of the DPR/QPR register579// that we are inserting in are undefined, use the580// original DPR/QPR value.581// * Otherwise, fall back on the same stategy as COPY.582//583// * REG_SEQUENCE: * If all except one of the input operands are584// IMPLICIT_DEFs, insert the VDUP pattern for just the585// defined input operand586// * Otherwise, fall back on the same stategy as COPY.587//588589// First, get all the reads of D-registers done by this instruction.590SmallVector<unsigned, 8> Defs = getReadDPRs(MI);591bool Modified = false;592593for (unsigned I : Defs) {594// Follow the def-use chain for this DPR through COPYs, and also through595// PHIs (which are essentially multi-way COPYs). It is because of PHIs that596// we can end up with multiple defs of this DPR.597598SmallVector<MachineInstr *, 8> DefSrcs;599if (!Register::isVirtualRegister(I))600continue;601MachineInstr *Def = MRI->getVRegDef(I);602if (!Def)603continue;604605elideCopiesAndPHIs(Def, DefSrcs);606607for (MachineInstr *MI : DefSrcs) {608// If we've already analyzed and replaced this operand, don't do609// anything.610if (Replacements.find(MI) != Replacements.end())611continue;612613// Now, work out if the instruction causes a SPR->DPR dependency.614if (!hasPartialWrite(MI))615continue;616617// Collect all the uses of this MI's DPR def for updating later.618SmallVector<MachineOperand*, 8> Uses;619Register DPRDefReg = MI->getOperand(0).getReg();620for (MachineOperand &MO : MRI->use_operands(DPRDefReg))621Uses.push_back(&MO);622623// We can optimize this.624unsigned NewReg = optimizeSDPattern(MI);625626if (NewReg != 0) {627Modified = true;628for (MachineOperand *Use : Uses) {629// Make sure to constrain the register class of the new register to630// match what we're replacing. Otherwise we can optimize a DPR_VFP2631// reference into a plain DPR, and that will end poorly. NewReg is632// always virtual here, so there will always be a matching subclass633// to find.634MRI->constrainRegClass(NewReg, MRI->getRegClass(Use->getReg()));635636LLVM_DEBUG(dbgs() << "Replacing operand " << *Use << " with "637<< printReg(NewReg) << "\n");638Use->substVirtReg(NewReg, 0, *TRI);639}640}641Replacements[MI] = NewReg;642}643}644return Modified;645}646647bool A15SDOptimizer::runOnMachineFunction(MachineFunction &Fn) {648if (skipFunction(Fn.getFunction()))649return false;650651const ARMSubtarget &STI = Fn.getSubtarget<ARMSubtarget>();652// Since the A15SDOptimizer pass can insert VDUP instructions, it can only be653// enabled when NEON is available.654if (!(STI.useSplatVFPToNeon() && STI.hasNEON()))655return false;656657TII = STI.getInstrInfo();658TRI = STI.getRegisterInfo();659MRI = &Fn.getRegInfo();660bool Modified = false;661662LLVM_DEBUG(dbgs() << "Running on function " << Fn.getName() << "\n");663664DeadInstr.clear();665Replacements.clear();666667for (MachineBasicBlock &MBB : Fn) {668for (MachineInstr &MI : MBB) {669Modified |= runOnInstruction(&MI);670}671}672673for (MachineInstr *MI : DeadInstr) {674MI->eraseFromParent();675}676677return Modified;678}679680FunctionPass *llvm::createA15SDOptimizerPass() {681return new A15SDOptimizer();682}683684685