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

Method Unroll

source/opt/loop_unroller.cpp:544–560  ·  view source on GitHub ↗

Duplicate the |loop| body |factor| - 1 number of times while keeping the loop backedge intact. This will leave the loop with |factor| number of bodies after accounting for the initial body.

Source from the content-addressed store, hash-verified

542// backedge intact. This will leave the loop with |factor| number of bodies
543// after accounting for the initial body.
544bool LoopUnrollerUtilsImpl::Unroll(Loop* loop, size_t factor) {
545 // If we unroll a loop partially it will not be safe to unroll it further.
546 // This is due to the current method of calculating the number of loop
547 // iterations.
548 MarkLoopControlAsDontUnroll(loop);
549
550 std::vector<Instruction*> inductions;
551 loop->GetInductionVariables(inductions);
552 state_ = LoopUnrollState{loop_induction_variable_, loop->GetLatchBlock(),
553 loop_condition_block_, std::move(inductions)};
554 for (size_t i = 0; i < factor - 1; ++i) {
555 if (!CopyBody(loop, true)) {
556 return false;
557 }
558 }
559 return true;
560}
561
562void LoopUnrollerUtilsImpl::RemoveDeadInstructions() {
563 // Remove the dead instructions.

Callers

nothing calls this directly

Calls 2

GetInductionVariablesMethod · 0.80
GetLatchBlockMethod · 0.80

Tested by

no test coverage detected