| 406 | } |
| 407 | |
| 408 | SENode* 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|. |
no test coverage detected