| 368 | } |
| 369 | |
| 370 | void Loop::GetMergingBlocks( |
| 371 | std::unordered_set<uint32_t>* merging_blocks) const { |
| 372 | assert(GetMergeBlock() && "This loop is not structured"); |
| 373 | CFG* cfg = context_->cfg(); |
| 374 | merging_blocks->clear(); |
| 375 | |
| 376 | std::stack<const BasicBlock*> to_visit; |
| 377 | to_visit.push(GetMergeBlock()); |
| 378 | while (!to_visit.empty()) { |
| 379 | const BasicBlock* bb = to_visit.top(); |
| 380 | to_visit.pop(); |
| 381 | merging_blocks->insert(bb->id()); |
| 382 | for (uint32_t pred_id : cfg->preds(bb->id())) { |
| 383 | if (!IsInsideLoop(pred_id) && !merging_blocks->count(pred_id)) { |
| 384 | to_visit.push(cfg->block(pred_id)); |
| 385 | } |
| 386 | } |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | namespace { |
| 391 | |