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.
| 542 | // backedge intact. This will leave the loop with |factor| number of bodies |
| 543 | // after accounting for the initial body. |
| 544 | bool 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 | |
| 562 | void LoopUnrollerUtilsImpl::RemoveDeadInstructions() { |
| 563 | // Remove the dead instructions. |
nothing calls this directly
no test coverage detected