45#define DEBUG_TYPE "nvptx-peephole"
56 return "NVPTX optimize redundant cvta.to.local instruction";
65char NVPTXPeephole::ID = 0;
67INITIALIZE_PASS(NVPTXPeephole,
"nvptx-peephole",
"NVPTX Peephole",
false,
false)
73 if (Root.getOpcode() != NVPTX::cvta_to_local_64 &&
74 Root.getOpcode() != NVPTX::cvta_to_local)
77 auto &
Op = Root.getOperand(1);
78 const auto &
MRI = MF.getRegInfo();
80 if (
Op.isReg() &&
Op.getReg().isVirtual()) {
81 GenericAddrDef =
MRI.getUniqueVRegDef(
Op.getReg());
85 if (!GenericAddrDef || GenericAddrDef->
getParent() != &
MBB ||
86 (GenericAddrDef->
getOpcode() != NVPTX::LEA_ADDRi64 &&
87 GenericAddrDef->
getOpcode() != NVPTX::LEA_ADDRi)) {
95 auto &BaseAddrOp = GenericAddrDef->
getOperand(1);
96 if (BaseAddrOp.isReg() && BaseAddrOp.getReg() == NRI->
getFrameRegister(MF)) {
106 const auto &
MRI = MF.getRegInfo();
117 .
add(Prev.getOperand(2));
122 if (
MRI.hasOneNonDBGUse(Prev.getOperand(0).getReg())) {
123 Prev.eraseFromParent();
132 bool Changed =
false;
134 for (
auto &
MBB : MF) {
138 while (BlockIter !=
MBB.
end()) {
139 auto &
MI = *BlockIter++;
151 const auto &
MRI = MF.getRegInfo();
154 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.
LLVM_ABI 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.
LLVM_ABI 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
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()