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

Method ReplaceInductionUseWithFinalValue

source/opt/loop_unroller.cpp:569–588  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

567}
568
569void LoopUnrollerUtilsImpl::ReplaceInductionUseWithFinalValue(Loop* loop) {
570 context_->InvalidateAnalysesExceptFor(
571 IRContext::Analysis::kAnalysisLoopAnalysis |
572 IRContext::Analysis::kAnalysisDefUse |
573 IRContext::Analysis::kAnalysisInstrToBlockMapping);
574
575 std::vector<Instruction*> inductions;
576 loop->GetInductionVariables(inductions);
577
578 for (size_t index = 0; index < inductions.size(); ++index) {
579 // We don't want the decorations that applied to the induction variable
580 // to be applied to the value that replace it.
581 context_->KillNamesAndDecorates(state_.previous_phis_[index]);
582
583 uint32_t trip_step_id = GetPhiDefID(state_.previous_phis_[index],
584 state_.previous_latch_block_->id());
585 context_->ReplaceAllUsesWith(inductions[index]->result_id(), trip_step_id);
586 invalidated_instructions_.push_back(inductions[index]);
587 }
588}
589
590// Fully unroll the loop by partially unrolling it by the number of loop
591// iterations minus one for the body already accounted for.

Callers

nothing calls this directly

Calls 8

GetInductionVariablesMethod · 0.80
KillNamesAndDecoratesMethod · 0.80
ReplaceAllUsesWithMethod · 0.80
sizeMethod · 0.45
idMethod · 0.45
result_idMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected