25#define DEBUG_TYPE "amdgpu-set-wave-priority"
28 "amdgpu-set-wave-priority-valu-insts-threshold",
29 cl::desc(
"VALU instruction count threshold for adjusting wave priority"),
36 unsigned NumVALUInstsAtStart = 0;
37 bool MayReachVMEMLoad =
false;
56 unsigned priority)
const;
66char AMDGPUSetWavePriority::
ID = 0;
69 return new AMDGPUSetWavePriority();
75 unsigned priority)
const {
83 MBBInfoSet &MBBInfos) {
85 if (!MBBInfos[Pred].MayReachVMEMLoad)
88 if (MBBInfos[Succ].MayReachVMEMLoad)
100 const unsigned HighPriority = 3;
101 const unsigned LowPriority = 0;
108 TII =
ST.getInstrInfo();
111 Attribute A =
F.getFnAttribute(
"amdgpu-wave-priority-threshold");
113 A.getValueAsString().getAsInteger(0, VALUInstsThreshold);
124 unsigned MaxNumVALUInstsInMiddle = 0;
125 unsigned NumVALUInstsAtEnd = 0;
130 Info.NumVALUInstsAtStart = 0;
131 MaxNumVALUInstsInMiddle = 0;
132 NumVALUInstsAtEnd = 0;
136 MaxNumVALUInstsInMiddle =
137 std::max(MaxNumVALUInstsInMiddle, NumVALUInstsAtEnd);
138 NumVALUInstsAtEnd = 0;
141 ++MBBInfos[
MBB].NumVALUInstsAtStart;
146 bool SuccsMayReachVMEMLoad =
false;
147 unsigned NumFollowingVALUInsts = 0;
149 SuccsMayReachVMEMLoad |= MBBInfos[Succ].MayReachVMEMLoad;
150 NumFollowingVALUInsts =
151 std::max(NumFollowingVALUInsts, MBBInfos[Succ].NumVALUInstsAtStart);
155 Info.NumVALUInstsAtStart += NumFollowingVALUInsts;
156 NumVALUInstsAtEnd += NumFollowingVALUInsts;
158 unsigned MaxNumVALUInsts =
159 std::max(MaxNumVALUInstsInMiddle, NumVALUInstsAtEnd);
160 Info.MayReachVMEMLoad =
161 SuccsMayReachVMEMLoad ||
162 (
Info.LastVMEMLoad && MaxNumVALUInsts >= VALUInstsThreshold);
166 if (!MBBInfos[&Entry].MayReachVMEMLoad)
173 BuildSetprioMI(Entry,
I, HighPriority);
179 if (MBBInfos[&
MBB].MayReachVMEMLoad) {
187 if (MBBInfos[Pred].MayReachVMEMLoad)
188 PriorityLoweringBlocks.
insert(Pred);
205 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)
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)