45#define DEBUG_TYPE "nvptx-peephole"
62 return "NVPTX optimize redundant cvta.to.local instruction";
71char NVPTXPeephole::ID = 0;
73INITIALIZE_PASS(NVPTXPeephole,
"nvptx-peephole",
"NVPTX Peephole",
false,
false)
79 if (Root.getOpcode() != NVPTX::cvta_to_local_64 &&
80 Root.getOpcode() != NVPTX::cvta_to_local)
83 auto &
Op = Root.getOperand(1);
84 const auto &
MRI = MF.getRegInfo();
86 if (
Op.isReg() &&
Op.getReg().isVirtual()) {
87 GenericAddrDef =
MRI.getUniqueVRegDef(
Op.getReg());
91 if (!GenericAddrDef || GenericAddrDef->
getParent() != &
MBB ||
92 (GenericAddrDef->
getOpcode() != NVPTX::LEA_ADDRi64 &&
93 GenericAddrDef->
getOpcode() != NVPTX::LEA_ADDRi)) {
101 auto &BaseAddrOp = GenericAddrDef->
getOperand(1);
102 if (BaseAddrOp.isReg() && BaseAddrOp.getReg() == NRI->
getFrameRegister(MF)) {
112 const auto &
MRI = MF.getRegInfo();
123 .
add(Prev.getOperand(2));
128 if (
MRI.hasOneNonDBGUse(Prev.getOperand(0).getReg())) {
129 Prev.eraseFromParent();
138 bool Changed =
false;
140 for (
auto &
MBB : MF) {
144 while (BlockIter !=
MBB.
end()) {
145 auto &
MI = *BlockIter++;
157 const auto &
MRI = MF.getRegInfo();
160 MI->eraseFromParent();
unsigned const MachineRegisterInfo * MRI
const HexagonInstrInfo * TII
static bool isCVTAToLocalCombinationCandidate(MachineInstr &Root)
static void CombineCVTAToLocal(MachineInstr &Root)
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Represent the analysis usage information of a pass.
This class represents an Operation in the Expression.
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
Function & getFunction()
Return the LLVM function that this machine code represents.
const MachineInstrBuilder & add(const MachineOperand &MO) const
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MachineBasicBlock * getParent() const
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
const MachineOperand & getOperand(unsigned i) const
Register getReg() const
getReg - Returns the register number.
Register getFrameLocalRegister(const MachineFunction &MF) const
Register getFrameRegister(const MachineFunction &MF) const override
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
StringRef - Represent a constant reference to a string, i.e.
TargetInstrInfo - Interface to description of machine instruction set.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
MachineFunctionPass * createNVPTXPeephole()
void initializeNVPTXPeepholePass(PassRegistry &)