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

Method UpdateChildNode

source/opt/scalar_analysis.cpp:408–429  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

406}
407
408SENode* ScalarEvolutionAnalysis::UpdateChildNode(SENode* parent,
409 SENode* old_child,
410 SENode* new_child) {
411 // Only handles add.
412 if (parent->GetType() != SENode::Add) return parent;
413
414 std::vector<SENode*> new_children;
415 for (SENode* child : *parent) {
416 if (child == old_child) {
417 new_children.push_back(new_child);
418 } else {
419 new_children.push_back(child);
420 }
421 }
422
423 std::unique_ptr<SENode> add_node{new SEAddNode(this)};
424 for (SENode* child : new_children) {
425 add_node->AddChild(child);
426 }
427
428 return SimplifyExpression(GetCachedOrAdd(std::move(add_node)));
429}
430
431// Rebuild the |node| eliminating, if it exists, the recurrent term which
432// belongs to the |loop|.

Callers 1

PropagateConstraintsMethod · 0.80

Calls 3

GetTypeMethod · 0.45
push_backMethod · 0.45
AddChildMethod · 0.45

Tested by

no test coverage detected