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

Method FoldConditionBlock

source/opt/loop_unroller.cpp:779–803  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

777}
778
779bool LoopUnrollerUtilsImpl::FoldConditionBlock(BasicBlock* condition_block,
780 uint32_t operand_label) {
781 // Remove the old conditional branch to the merge and continue blocks.
782 Instruction& old_branch = *condition_block->tail();
783 uint32_t new_target = old_branch.GetSingleWordOperand(operand_label);
784
785 DebugScope scope = old_branch.GetDebugScope();
786 const std::vector<Instruction> lines = old_branch.dbg_line_insts();
787
788 context_->KillInst(&old_branch);
789 // Add the new unconditional branch to the merge block.
790 InstructionBuilder builder(
791 context_, condition_block,
792 IRContext::Analysis::kAnalysisDefUse |
793 IRContext::Analysis::kAnalysisInstrToBlockMapping);
794 Instruction* new_branch = builder.AddBranch(new_target);
795
796 if (!lines.empty()) {
797 if (!new_branch->AddDebugLine(&lines.back())) {
798 return false;
799 }
800 }
801 new_branch->SetDebugScope(scope);
802 return true;
803}
804
805void LoopUnrollerUtilsImpl::CloseUnrolledLoop(Loop* loop) {
806 // Remove the OpLoopMerge instruction from the function.

Callers

nothing calls this directly

Calls 8

GetSingleWordOperandMethod · 0.80
AddDebugLineMethod · 0.80
backMethod · 0.80
SetDebugScopeMethod · 0.80
tailMethod · 0.45
KillInstMethod · 0.45
AddBranchMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected