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

Method BuildGraphWithoutRecurrentTerm

source/opt/scalar_analysis.cpp:433–463  ·  view source on GitHub ↗

Rebuild the |node| eliminating, if it exists, the recurrent term which belongs to the |loop|.

Source from the content-addressed store, hash-verified

431// Rebuild the |node| eliminating, if it exists, the recurrent term which
432// belongs to the |loop|.
433SENode* ScalarEvolutionAnalysis::BuildGraphWithoutRecurrentTerm(
434 SENode* node, const Loop* loop) {
435 // If the node is already a recurrent expression belonging to loop then just
436 // return the offset.
437 SERecurrentNode* recurrent = node->AsSERecurrentNode();
438 if (recurrent) {
439 if (recurrent->GetLoop() == loop) {
440 return recurrent->GetOffset();
441 } else {
442 return node;
443 }
444 }
445
446 std::vector<SENode*> new_children;
447 // Otherwise find the recurrent node in the children of this node.
448 for (auto itr : *node) {
449 recurrent = itr->AsSERecurrentNode();
450 if (recurrent && recurrent->GetLoop() == loop) {
451 new_children.push_back(recurrent->GetOffset());
452 } else {
453 new_children.push_back(itr);
454 }
455 }
456
457 std::unique_ptr<SENode> add_node{new SEAddNode(this)};
458 for (SENode* child : new_children) {
459 add_node->AddChild(child);
460 }
461
462 return SimplifyExpression(GetCachedOrAdd(std::move(add_node)));
463}
464
465// Return the recurrent term belonging to |loop| if it appears in the graph
466// starting at |node| or null if it doesn't.

Callers 1

PropagateConstraintsMethod · 0.80

Calls 5

AsSERecurrentNodeMethod · 0.80
GetOffsetMethod · 0.80
GetLoopMethod · 0.45
push_backMethod · 0.45
AddChildMethod · 0.45

Tested by

no test coverage detected