| 417 | } |
| 418 | |
| 419 | BasicBlock* LoopPeeling::ProtectLoop(Loop* loop, Instruction* condition, |
| 420 | BasicBlock* if_merge) { |
| 421 | BasicBlock* if_block = loop->GetOrCreatePreHeaderBlock(); |
| 422 | if (!if_block) { |
| 423 | return nullptr; |
| 424 | } |
| 425 | // Will no longer be a pre-header because of the if. |
| 426 | loop->SetPreHeaderBlock(nullptr); |
| 427 | // Kill the branch to the header. |
| 428 | context_->KillInst(&*if_block->tail()); |
| 429 | |
| 430 | InstructionBuilder builder( |
| 431 | context_, if_block, |
| 432 | IRContext::kAnalysisDefUse | IRContext::kAnalysisInstrToBlockMapping); |
| 433 | builder.AddConditionalBranch(condition->result_id(), |
| 434 | loop->GetHeaderBlock()->id(), if_merge->id(), |
| 435 | if_merge->id()); |
| 436 | |
| 437 | return if_block; |
| 438 | } |
| 439 | |
| 440 | bool LoopPeeling::PeelBefore(uint32_t peel_factor) { |
| 441 | assert(CanPeelLoop() && "Cannot peel loop"); |
nothing calls this directly
no test coverage detected