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

Method IsLoopInvariant

source/opt/scalar_analysis.cpp:375–394  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

373}
374
375bool ScalarEvolutionAnalysis::IsLoopInvariant(const Loop* loop,
376 const SENode* node) const {
377 for (auto itr = node->graph_cbegin(); itr != node->graph_cend(); ++itr) {
378 if (const SERecurrentNode* rec = itr->AsSERecurrentNode()) {
379 const BasicBlock* header = rec->GetLoop()->GetHeaderBlock();
380
381 // If the loop which the recurrent expression belongs to is either |loop
382 // or a nested loop inside |loop| then we assume it is variant.
383 if (loop->IsInsideLoop(header)) {
384 return false;
385 }
386 } else if (const SEValueUnknown* unknown = itr->AsSEValueUnknown()) {
387 // If the instruction is inside the loop we conservatively assume it is
388 // loop variant.
389 if (loop->IsInsideLoop(unknown->ResultId())) return false;
390 }
391 }
392
393 return true;
394}
395
396SENode* ScalarEvolutionAnalysis::GetCoefficientFromRecurrentTerm(
397 SENode* node, const Loop* loop) {

Callers 2

GetPeelingInfoMethod · 0.80
EvalOperatorMethod · 0.80

Calls 8

graph_cbeginMethod · 0.80
graph_cendMethod · 0.80
AsSERecurrentNodeMethod · 0.80
AsSEValueUnknownMethod · 0.80
ResultIdMethod · 0.80
GetHeaderBlockMethod · 0.45
GetLoopMethod · 0.45
IsInsideLoopMethod · 0.45

Tested by

no test coverage detected