27#define DEBUG_TYPE "amdgpu-set-wave-priority"
30 "amdgpu-set-wave-priority-valu-insts-threshold",
31 cl::desc(
"VALU instruction count threshold for adjusting wave priority"),
38 unsigned NumVALUInstsAtStart = 0;
39 bool MayReachVMEMLoad =
false;
58 unsigned priority)
const;
68char AMDGPUSetWavePriority::
ID = 0;
71 return new AMDGPUSetWavePriority();
77 unsigned priority)
const {
85 MBBInfoSet &MBBInfos) {
87 if (!MBBInfos[Pred].MayReachVMEMLoad)
90 if (MBBInfos[Succ].MayReachVMEMLoad)
102 const unsigned HighPriority = 3;
103 const unsigned LowPriority = 0;
110 TII =
ST.getInstrInfo();
113 Attribute A =
F.getFnAttribute(
"amdgpu-wave-priority-threshold");
115 A.getValueAsString().getAsInteger(0, VALUInstsThreshold);
126 unsigned MaxNumVALUInstsInMiddle = 0;
127 unsigned NumVALUInstsAtEnd = 0;
132 Info.NumVALUInstsAtStart = 0;
133 MaxNumVALUInstsInMiddle = 0;
134 NumVALUInstsAtEnd = 0;
138 MaxNumVALUInstsInMiddle =
139 std::max(MaxNumVALUInstsInMiddle, NumVALUInstsAtEnd);
140 NumVALUInstsAtEnd = 0;
143 ++MBBInfos[
MBB].NumVALUInstsAtStart;
148 bool SuccsMayReachVMEMLoad =
false;
149 unsigned NumFollowingVALUInsts = 0;
151 SuccsMayReachVMEMLoad |= MBBInfos[Succ].MayReachVMEMLoad;
152 NumFollowingVALUInsts =
153 std::max(NumFollowingVALUInsts, MBBInfos[Succ].NumVALUInstsAtStart);
157 Info.NumVALUInstsAtStart += NumFollowingVALUInsts;
158 NumVALUInstsAtEnd += NumFollowingVALUInsts;
160 unsigned MaxNumVALUInsts =
161 std::max(MaxNumVALUInstsInMiddle, NumVALUInstsAtEnd);
162 Info.MayReachVMEMLoad =
163 SuccsMayReachVMEMLoad ||
164 (
Info.LastVMEMLoad && MaxNumVALUInsts >= VALUInstsThreshold);
168 if (!MBBInfos[&Entry].MayReachVMEMLoad)
175 BuildSetprioMI(Entry,
I, HighPriority);
181 if (MBBInfos[&
MBB].MayReachVMEMLoad) {
189 if (MBBInfos[Pred].MayReachVMEMLoad)
190 PriorityLoweringBlocks.
insert(Pred);
207 MBBInfos[
MBB].LastVMEMLoad
Provides AMDGPU specific target descriptions.
static cl::opt< unsigned > DefaultVALUInstsThreshold("amdgpu-set-wave-priority-valu-insts-threshold", cl::desc("VALU instruction count threshold for adjusting wave priority"), cl::init(100), cl::Hidden)
static bool CanLowerPriorityDirectlyInPredecessors(const MachineBasicBlock &MBB, MBBInfoSet &MBBInfos)
static bool isVMEMLoad(const MachineInstr &MI)
This file defines the BumpPtrAllocator interface.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
Analysis containing CSE Info
AMD GCN specific subclass of TargetSubtarget.
const HexagonInstrInfo * TII
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file builds on the ADT/GraphTraits.h file to build a generic graph post order iterator.
Interface definition for SIInstrInfo.
FunctionPass class - This class is used to implement most global optimizations.
iterator_range< succ_iterator > successors()
iterator_range< pred_iterator > predecessors()
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Function & getFunction()
Return the LLVM function that this machine code represents.
const MachineBasicBlock & front() const
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
Representation of each machine instruction.
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
static bool isDS(const MachineInstr &MI)
static bool isVMEM(const MachineInstr &MI)
static bool isVALU(const MachineInstr &MI)
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
std::pair< const_iterator, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
StringRef - Represent a constant reference to a string, i.e.
bool isEntryFunctionCC(CallingConv::ID CC)
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
FunctionPass * createAMDGPUSetWavePriorityPass()
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
iterator_range< po_iterator< T > > post_order(const T &G)