MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / VisitBlock

Method VisitBlock

source/lint/divergence_analysis.cpp:63–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63opt::DataFlowAnalysis::VisitResult DivergenceAnalysis::VisitBlock(uint32_t id) {
64 if (!cd_.HasBlock(id)) {
65 return opt::DataFlowAnalysis::VisitResult::kResultFixed;
66 }
67 DivergenceLevel& cur_level = divergence_[id];
68 if (cur_level == DivergenceLevel::kDivergent) {
69 return opt::DataFlowAnalysis::VisitResult::kResultFixed;
70 }
71 DivergenceLevel orig = cur_level;
72 for (const spvtools::opt::ControlDependence& dep :
73 cd_.GetDependenceSources(id)) {
74 if (divergence_[dep.source_bb_id()] > cur_level) {
75 cur_level = divergence_[dep.source_bb_id()];
76 divergence_source_[id] = dep.source_bb_id();
77 } else if (dep.source_bb_id() != 0) {
78 uint32_t condition_id = dep.GetConditionID(*context().cfg());
79 DivergenceLevel dep_level = divergence_[condition_id];
80 // Check if we are along the chain of unconditional branches starting from
81 // the branch target.
82 if (follow_unconditional_branches_[dep.branch_target_bb_id()] !=
83 follow_unconditional_branches_[dep.target_bb_id()]) {
84 // We must have reconverged in order to reach this block.
85 // Promote partially uniform to divergent.
86 if (dep_level == DivergenceLevel::kPartiallyUniform) {
87 dep_level = DivergenceLevel::kDivergent;
88 }
89 }
90 if (dep_level > cur_level) {
91 cur_level = dep_level;
92 divergence_source_[id] = condition_id;
93 divergence_dependence_source_[id] = dep.source_bb_id();
94 }
95 }
96 }
97 return cur_level > orig ? VisitResult::kResultChanged
98 : VisitResult::kResultFixed;
99}
100
101opt::DataFlowAnalysis::VisitResult DivergenceAnalysis::VisitInstruction(
102 opt::Instruction* inst) {

Callers

nothing calls this directly

Calls 6

HasBlockMethod · 0.80
source_bb_idMethod · 0.80
GetConditionIDMethod · 0.80
branch_target_bb_idMethod · 0.80
target_bb_idMethod · 0.80
cfgMethod · 0.45

Tested by

no test coverage detected