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

Method ProtectLoop

source/opt/loop_peeling.cpp:419–438  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

417}
418
419BasicBlock* 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
440bool LoopPeeling::PeelBefore(uint32_t peel_factor) {
441 assert(CanPeelLoop() && "Cannot peel loop");

Callers

nothing calls this directly

Calls 8

SetPreHeaderBlockMethod · 0.80
AddConditionalBranchMethod · 0.80
KillInstMethod · 0.45
tailMethod · 0.45
result_idMethod · 0.45
idMethod · 0.45
GetHeaderBlockMethod · 0.45

Tested by

no test coverage detected