LLVM: lib/Analysis/UniformityAnalysis.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
17
18using namespace llvm;
19
20template <>
25
26template <>
31
34 if (TTI->isSourceOfDivergence(&I))
36 else if (TTI->isAlwaysUniform(&I))
38 }
39 for (auto &Arg : F.args()) {
40 if (TTI->isSourceOfDivergence(&Arg)) {
42 }
43 }
44}
45
46template <>
47void llvm::GenericUniformityAnalysisImpl::pushUsers(
49 for (const auto *User : V->users()) {
51 markDivergent(*UserInstr);
52 }
53 }
54}
55
56template <>
57void llvm::GenericUniformityAnalysisImpl::pushUsers(
59 assert(!isAlwaysUniform(Instr));
60 if (Instr.isTerminator())
61 return;
63}
64
65template <>
66bool llvm::GenericUniformityAnalysisImpl::usesValueFromCycle(
68 assert(!isAlwaysUniform(I));
69 for (const Use &U : I.operands()) {
71 if (DefCycle.contains(I->getParent()))
72 return true;
73 }
74 }
75 return false;
76}
77
78template <>
81 const Cycle &DefCycle) {
82 for (auto *User : I.users()) {
84 if (DefCycle.contains(UserInstr->getParent()))
85 continue;
86 markDivergent(*UserInstr);
87 recordTemporalDivergence(&I, UserInstr, &DefCycle);
88 }
89}
90
91template <>
93 const Use &U) const {
94 const auto *V = U.get();
96 return true;
99 return isTemporalDivergent(*UseInstr->getParent(), *DefInstr);
100 }
101 return false;
102}
103
104
105
109
110
111
112
113
120
121 if (TTI.hasBranchDivergence(&F))
122 UI.compute();
123
124 return UI;
125}
126
128
131
134 OS << "UniformityInfo for function '" << F.getName() << "':\n";
136
138}
139
140
141
142
143
145
147
149 "Uniformity Analysis", false, true)
155
157 AU.setPreservesAll();
161}
162
166 auto &targetTransformInfo =
168
169 m_function = &F;
170 m_uniformityInfo = UniformityInfo{domTree, cycleInfo, &targetTransformInfo};
171
172
173 if (targetTransformInfo.hasBranchDivergence(m_function))
174 m_uniformityInfo.compute();
175
176 return false;
177}
178
180 OS << "UniformityInfo for function '" << m_function->getName() << "':\n";
181 m_uniformityInfo.print(OS);
182}
183
186 m_function = nullptr;
187}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Expand Atomic instructions
This file declares an analysis pass that computes CycleInfo for LLVM IR, specialized from GenericCycl...
Implementation of uniformity analysis.
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)
This pass exposes codegen information to IR-level passes.
LLVM IR instance of the generic uniformity analysis.
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.
Analysis pass which computes a CycleInfo.
Legacy analysis pass which computes a CycleInfo.
Analysis pass which computes a DominatorTree.
Legacy analysis pass which computes a DominatorTree.
bool contains(const BlockT *Block) const
Return whether Block is contained in the cycle.
Analysis that identifies uniform values in a data-parallel execution.
bool isDivergentUse(const UseT &U) const
bool hasDivergentDefs(const InstructionT &I) const
bool markDefsDivergent(const InstructionT &Instr)
Mark outputs of Instr as divergent.
bool isDivergent(const InstructionT &I) const
const TargetTransformInfo * TTI
void markDivergent(const InstructionT &I)
Examine I for divergent outputs and add to the worklist.
void addUniformOverride(const InstructionT &Instr)
Mark UniVal as a value that is always uniform.
A Module instance is used to store all the information related to an LLVM module.
AnalysisType & getAnalysis() const
getAnalysis() - This function is used by subclasses to get to the analysis information ...
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.
Analysis pass providing the TargetTransformInfo.
Wrapper pass for TargetTransformInfo.
Analysis pass which computes UniformityInfo.
UniformityInfo run(Function &F, FunctionAnalysisManager &)
Run the analysis pass over a function and produce a dominator tree.
Definition UniformityAnalysis.cpp:114
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Definition UniformityAnalysis.cpp:132
UniformityInfoPrinterPass(raw_ostream &OS)
Definition UniformityAnalysis.cpp:129
Legacy analysis pass which computes a CycleInfo.
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
Definition UniformityAnalysis.cpp:163
void print(raw_ostream &OS, const Module *M=nullptr) const override
print - Print out the internal state of the pass.
Definition UniformityAnalysis.cpp:179
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Definition UniformityAnalysis.cpp:156
UniformityInfoWrapperPass()
Definition UniformityAnalysis.cpp:146
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
Definition UniformityAnalysis.cpp:184
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
iterator_range< user_iterator > users()
This class implements an extremely fast bulk output stream that can only output to a stream.
NodeAddr< InstrNode * > Instr
This is an optimization pass for GlobalISel generic memory operations.
GenericUniformityInfo< SSAContext > UniformityInfo
Printable print(const GCNRegPressure &RP, const GCNSubtarget *ST=nullptr, unsigned DynamicVGPRBlockSize=0)
GenericSSAContext< Function > SSAContext
decltype(auto) dyn_cast(const From &Val)
dyn_cast - Return the argument parameter cast to the specified type.
decltype(auto) cast(const From &Val)
cast - Return the argument parameter cast to the specified type.
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
A special type used by analysis passes to provide an address that identifies that particular analysis...