26
26
#include " llvm/ADT/SmallVector.h"
27
27
#include " llvm/ADT/StringRef.h"
28
28
#include " llvm/Analysis/DomTreeUpdater.h"
29
- #include " llvm/Analysis/LegacyDivergenceAnalysis.h"
30
29
#include " llvm/Analysis/PostDominators.h"
31
30
#include " llvm/Analysis/TargetTransformInfo.h"
31
+ #include " llvm/Analysis/UniformityAnalysis.h"
32
32
#include " llvm/IR/BasicBlock.h"
33
33
#include " llvm/IR/CFG.h"
34
34
#include " llvm/IR/Constants.h"
@@ -82,7 +82,7 @@ INITIALIZE_PASS_BEGIN(AMDGPUUnifyDivergentExitNodes, DEBUG_TYPE,
82
82
" Unify divergent function exit nodes" , false , false )
83
83
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
84
84
INITIALIZE_PASS_DEPENDENCY(PostDominatorTreeWrapperPass)
85
- INITIALIZE_PASS_DEPENDENCY(LegacyDivergenceAnalysis )
85
+ INITIALIZE_PASS_DEPENDENCY(UniformityInfoWrapperPass )
86
86
INITIALIZE_PASS_END(AMDGPUUnifyDivergentExitNodes, DEBUG_TYPE,
87
87
" Unify divergent function exit nodes" , false , false )
88
88
@@ -92,15 +92,15 @@ void AMDGPUUnifyDivergentExitNodes::getAnalysisUsage(AnalysisUsage &AU) const{
92
92
93
93
AU.addRequired <PostDominatorTreeWrapperPass>();
94
94
95
- AU.addRequired <LegacyDivergenceAnalysis >();
95
+ AU.addRequired <UniformityInfoWrapperPass >();
96
96
97
97
if (RequireAndPreserveDomTree) {
98
98
AU.addPreserved <DominatorTreeWrapperPass>();
99
99
// FIXME: preserve PostDominatorTreeWrapperPass
100
100
}
101
101
102
102
// No divergent values are changed, only blocks and branch edges.
103
- AU.addPreserved <LegacyDivergenceAnalysis >();
103
+ AU.addPreserved <UniformityInfoWrapperPass >();
104
104
105
105
// We preserve the non-critical-edgeness property
106
106
AU.addPreservedID (BreakCriticalEdgesID);
@@ -114,14 +114,13 @@ void AMDGPUUnifyDivergentExitNodes::getAnalysisUsage(AnalysisUsage &AU) const{
114
114
115
115
// / \returns true if \p BB is reachable through only uniform branches.
116
116
// / XXX - Is there a more efficient way to find this?
117
- static bool isUniformlyReached (const LegacyDivergenceAnalysis &DA,
118
- BasicBlock &BB) {
117
+ static bool isUniformlyReached (const UniformityInfo &UA, BasicBlock &BB) {
119
118
SmallVector<BasicBlock *, 8 > Stack (predecessors (&BB));
120
119
SmallPtrSet<BasicBlock *, 8 > Visited;
121
120
122
121
while (!Stack.empty ()) {
123
122
BasicBlock *Top = Stack.pop_back_val ();
124
- if (!DA .isUniform (Top->getTerminator ()))
123
+ if (!UA .isUniform (Top->getTerminator ()))
125
124
return false ;
126
125
127
126
for (BasicBlock *Pred : predecessors (Top)) {
@@ -192,7 +191,8 @@ bool AMDGPUUnifyDivergentExitNodes::runOnFunction(Function &F) {
192
191
!isa<BranchInst>(PDT.getRoot ()->getTerminator ())))
193
192
return false ;
194
193
195
- LegacyDivergenceAnalysis &DA = getAnalysis<LegacyDivergenceAnalysis>();
194
+ UniformityInfo &UA =
195
+ getAnalysis<UniformityInfoWrapperPass>().getUniformityInfo ();
196
196
TTI = &getAnalysis<TargetTransformInfoWrapperPass>().getTTI (F);
197
197
198
198
// Loop over all of the blocks in a function, tracking all of the blocks that
@@ -213,7 +213,7 @@ bool AMDGPUUnifyDivergentExitNodes::runOnFunction(Function &F) {
213
213
// exits, we should only unify UnreachableBlocks that are not uniformly
214
214
// reachable.
215
215
bool HasDivergentExitBlock = llvm::any_of (
216
- PDT.roots (), [&](auto BB) { return !isUniformlyReached (DA , *BB); });
216
+ PDT.roots (), [&](auto BB) { return !isUniformlyReached (UA , *BB); });
217
217
218
218
for (BasicBlock *BB : PDT.roots ()) {
219
219
if (isa<ReturnInst>(BB->getTerminator ())) {
0 commit comments