LLVM
8.0.1
|
Generic divergence analysis for reducible CFGs. More...
#include "llvm/Analysis/DivergenceAnalysis.h"
Public Member Functions | |
DivergenceAnalysis (const Function &F, const Loop *RegionLoop, const DominatorTree &DT, const LoopInfo &LI, SyncDependenceAnalysis &SDA, bool IsLCSSAForm) | |
This instance will analyze the whole function F or the loop RegionLoop . More... | |
const Loop * | getRegionLoop () const |
The loop that defines the analyzed region (if any). More... | |
const Function & | getFunction () const |
bool | inRegion (const BasicBlock &BB) const |
Whether BB is part of the region. More... | |
bool | inRegion (const Instruction &I) const |
Whether I is part of the region. More... | |
void | addUniformOverride (const Value &UniVal) |
Mark UniVal as a value that is always uniform. More... | |
void | markDivergent (const Value &DivVal) |
Mark DivVal as a value that is always divergent. More... | |
void | compute () |
Propagate divergence to all instructions in the region. More... | |
bool | hasDetectedDivergence () const |
Whether any value was marked or analyzed to be divergent. More... | |
bool | isAlwaysUniform (const Value &Val) const |
Whether Val will always return a uniform value regardless of its operands. More... | |
bool | isDivergent (const Value &Val) const |
Whether Val is a divergent value. More... | |
void | print (raw_ostream &OS, const Module *) const |
Generic divergence analysis for reducible CFGs.
This analysis propagates divergence in a data-parallel context from sources of divergence to all users. It requires reducible CFGs. All assignments should be in SSA form.
Definition at line 38 of file DivergenceAnalysis.h.
DivergenceAnalysis::DivergenceAnalysis | ( | const Function & | F, |
const Loop * | RegionLoop, | ||
const DominatorTree & | DT, | ||
const LoopInfo & | LI, | ||
SyncDependenceAnalysis & | SDA, | ||
bool | IsLCSSAForm | ||
) |
This instance will analyze the whole function F
or the loop RegionLoop
.
RegionLoop | if non-null the analysis is restricted to RegionLoop . Otherwise the whole function is analyzed. |
IsLCSSAForm | whether the analysis may assume that the IR in the region in in LCSSA form. |
Definition at line 95 of file DivergenceAnalysis.cpp.
Mark UniVal
as a value that is always uniform.
Definition at line 107 of file DivergenceAnalysis.cpp.
References assert(), llvm::LoopBase< BlockT, LoopT >::contains(), llvm::dyn_cast(), llvm::PHINode::getIncomingValue(), llvm::LoopInfoBase< BlockT, LoopT >::getLoopFor(), llvm::PHINode::getNumIncomingValues(), llvm::Instruction::getNumSuccessors(), llvm::Instruction::getParent(), llvm::LoopBase< BlockT, LoopT >::getParentLoop(), llvm::PHINode::hasConstantOrUndefValue(), I, llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), isDivergent(), llvm_unreachable, and llvm::User::operands().
Referenced by getFunction(), and llvm::GPUDivergenceAnalysis::GPUDivergenceAnalysis().
void DivergenceAnalysis::compute | ( | ) |
Propagate divergence to all instructions in the region.
Divergence is seeded by calls to markDivergent
.
Definition at line 364 of file DivergenceAnalysis.cpp.
References llvm::dyn_cast(), I, isAlwaysUniform(), isDivergent(), llvm::Instruction::isTerminator(), and markDivergent().
Referenced by getFunction(), and llvm::GPUDivergenceAnalysis::GPUDivergenceAnalysis().
Definition at line 53 of file DivergenceAnalysis.h.
References addUniformOverride(), compute(), I, inRegion(), and markDivergent().
Referenced by llvm::GPUDivergenceAnalysis::getFunction(), and llvm::GPUDivergenceAnalysis::print().
The loop that defines the analyzed region (if any).
Definition at line 52 of file DivergenceAnalysis.h.
|
inline |
Whether any value was marked or analyzed to be divergent.
Definition at line 71 of file DivergenceAnalysis.h.
References llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::empty(), isAlwaysUniform(), isDivergent(), and print().
Referenced by llvm::GPUDivergenceAnalysis::hasDivergence().
bool DivergenceAnalysis::inRegion | ( | const BasicBlock & | BB | ) | const |
Whether BB
is part of the region.
Definition at line 184 of file DivergenceAnalysis.cpp.
References assert(), llvm::LoopBase< BlockT, LoopT >::contains(), llvm::dbgs(), llvm::DominatorTree::dominates(), llvm::dyn_cast(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::LoopInfoBase< BlockT, LoopT >::getLoopFor(), llvm::Value::getName(), llvm::Loop::getName(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::LoopBase< BlockT, LoopT >::getParentLoop(), llvm::detail::DenseSetImpl< ValueT, DenseMap< ValueT, detail::DenseSetEmpty, ValueInfoT, detail::DenseSetPair< ValueT > >, ValueInfoT >::insert(), isAlwaysUniform(), isDivergent(), llvm::SyncDependenceAnalysis::join_blocks(), LLVM_DEBUG, markDivergent(), llvm::User::operands(), llvm::BasicBlock::phis(), llvm::successors(), and llvm::Value::users().
Referenced by getFunction(), and inRegion().
bool DivergenceAnalysis::inRegion | ( | const Instruction & | I | ) | const |
Whether I
is part of the region.
Definition at line 180 of file DivergenceAnalysis.cpp.
References llvm::Instruction::getParent(), and inRegion().
Whether Val
will always return a uniform value regardless of its operands.
Definition at line 408 of file DivergenceAnalysis.cpp.
References llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::end(), and llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::find().
Referenced by compute(), hasDetectedDivergence(), inRegion(), and markDivergent().
Whether Val
is a divergent value.
Definition at line 412 of file DivergenceAnalysis.cpp.
References llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::end(), and llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::find().
Referenced by addUniformOverride(), compute(), llvm::GPUDivergenceAnalysis::getFunction(), hasDetectedDivergence(), inRegion(), llvm::GPUDivergenceAnalysis::isDivergent(), llvm::GPUDivergenceAnalysis::isUniform(), and print().
Mark DivVal
as a value that is always divergent.
Definition at line 101 of file DivergenceAnalysis.cpp.
References assert(), llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::insert(), and isAlwaysUniform().
Referenced by compute(), getFunction(), llvm::GPUDivergenceAnalysis::GPUDivergenceAnalysis(), and inRegion().
void DivergenceAnalysis::print | ( | raw_ostream & | OS, |
const Module * | |||
) | const |
Definition at line 416 of file DivergenceAnalysis.cpp.
References llvm::detail::DenseSetImpl< ValueT, MapTy, ValueInfoT >::empty(), llvm::instructions(), and isDivergent().
Referenced by hasDetectedDivergence(), llvm::GPUDivergenceAnalysis::isUniform(), and llvm::GPUDivergenceAnalysis::print().