24 for (
auto &
op :
I.all_defs()) {
25 if (isDivergent(
op.getReg()))
34 bool insertedDivergent =
false;
35 const auto &
MRI =
F.getRegInfo();
36 const auto &RBI = *
F.getSubtarget().getRegBankInfo();
37 const auto &
TRI = *
MRI.getTargetRegisterInfo();
38 for (
auto &
op : Instr.all_defs()) {
39 if (!
op.getReg().isVirtual())
42 if (
TRI.isUniformReg(
MRI, RBI,
op.getReg()))
44 insertedDivergent |= markDivergent(
op.getReg());
46 return insertedDivergent;
51 const auto &InstrInfo = *
F.getSubtarget().getInstrInfo();
56 if (
uniformity == InstructionUniformity::AlwaysUniform) {
57 addUniformOverride(
instr);
61 if (
uniformity == InstructionUniformity::NeverUniform) {
72 const auto &RegInfo =
F.getRegInfo();
73 for (
MachineInstr &UserInstr : RegInfo.use_instructions(Reg)) {
74 markDivergent(UserInstr);
81 assert(!isAlwaysUniform(Instr));
82 if (
Instr.isTerminator())
85 auto Reg =
op.getReg();
95 for (
auto &
Op :
I.operands()) {
96 if (!
Op.isReg() || !
Op.readsReg())
98 auto Reg =
Op.getReg();
102 if (
Reg.isPhysical())
105 auto *
Def =
F.getRegInfo().getVRegDef(Reg);
116 const auto &
RegInfo =
F.getRegInfo();
117 for (
auto &
Op :
I.all_defs()) {
118 if (!
Op.getReg().isVirtual())
120 auto Reg =
Op.getReg();
122 if (DefCycle.
contains(UserInstr.getParent()))
124 markDivergent(UserInstr);
126 recordTemporalDivergence(Reg, &UserInstr, &DefCycle);
137 auto Reg = U.getReg();
138 if (isDivergent(Reg))
141 const auto &RegInfo =
F.getRegInfo();
142 auto *Def = RegInfo.getOneDef(Reg);
146 auto *DefInstr = Def->getParent();
147 auto *UseInstr = U.getParent();
148 return isTemporalDivergent(*UseInstr->getParent(), *DefInstr);
160 assert(
F.getRegInfo().isSSA() &&
"Expected to be run on SSA form!");
162 if (HasBranchDivergence)
173 MachineUniformityInfoPrinterPass();
200 OS <<
"MachineUniformityInfo for function: ";
215 "Machine Uniformity Info Analysis",
false,
true)
222 AU.setPreservesAll();
229 auto &DomTree = getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree();
230 auto &CI = getAnalysis<MachineCycleInfoWrapperPass>().getCycleInfo();
239 OS <<
"MachineUniformityInfo for function: ";
245char MachineUniformityInfoPrinterPass::ID = 0;
247MachineUniformityInfoPrinterPass::MachineUniformityInfoPrinterPass()
254 "print-machine-uniformity",
255 "Print Machine Uniformity Info Analysis",
true,
true)
261void MachineUniformityInfoPrinterPass::getAnalysisUsage(
263 AU.setPreservesAll();
268bool MachineUniformityInfoPrinterPass::runOnMachineFunction(
270 auto &UI = getAnalysis<MachineUniformityAnalysisPass>();
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
block Block Frequency Analysis
COFF::MachineTypes Machine
This file declares a specialization of the GenericSSAContext<X> template class for Machine IR.
Register const TargetRegisterInfo * TRI
FunctionAnalysisManager FAM
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
unify loop Fixup each natural loop to have a single exit block
A container for analyses that lazily runs them and caches their results.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
This class represents an Operation in the Expression.
A possibly irreducible generalization of a Loop.
bool contains(const BlockT *Block) const
Return whether Block is contained in the cycle.
Legacy analysis pass which computes a MachineCycleInfo.
Analysis pass which computes a MachineDominatorTree.
Analysis pass which computes a MachineDominatorTree.
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
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.
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
A Module instance is used to store all the information related to an LLVM module.
static LLVM_ABI PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Wrapper class representing virtual and physical registers.
Analysis pass providing the TargetTransformInfo.
LLVM_ABI void printAsOperand(raw_ostream &O, bool PrintType=true, const Module *M=nullptr) const
Print the name of this Value out to the specified raw_ostream.
This class implements an extremely fast bulk output stream that can only output to a stream.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Reg
All possible values of the reg field in the ModR/M byte.
NodeAddr< InstrNode * > Instr
NodeAddr< DefNode * > Def
This is an optimization pass for GlobalISel generic memory operations.
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr, unsigned DynamicVGPRBlockSize=0)
LLVM_ABI void initializeMachineUniformityAnalysisPassPass(PassRegistry &)
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
MachineUniformityInfo computeMachineUniformityInfo(MachineFunction &F, const MachineCycleInfo &cycleInfo, const MachineDominatorTree &domTree, bool HasBranchDivergence)
Compute uniformity information for a Machine IR function.
LLVM_ABI void initializeMachineUniformityInfoPrinterPassPass(PassRegistry &)
A special type used by analysis passes to provide an address that identifies that particular analysis...