Lines Matching refs:loop

28 static void RotateEntryPhiFirst(HLoopInformation* loop,  in RotateEntryPhiFirst()  argument
32 const HInstructionList& phis = loop->GetHeader()->GetPhis(); in RotateEntryPhiFirst()
99 static bool IsGuardedBy(HLoopInformation* loop, in IsGuardedBy() argument
112 HBasicBlock* guard = loop->GetPreHeader(); in IsGuardedBy()
113 HBasicBlock* entry = loop->GetHeader(); in IsGuardedBy()
146 HInstruction* FindFirstLoopHeaderPhiUse(HLoopInformation* loop, HInstruction* instruction) { in FindFirstLoopHeaderPhiUse() argument
148 if (use.GetUser()->GetBlock() == loop->GetHeader() && in FindFirstLoopHeaderPhiUse()
160 bool FixOutsideUse(HLoopInformation* loop, in FixOutsideUse() argument
170 if (user->GetBlock()->GetLoopInformation() != loop) { in FixOutsideUse()
184 if (user->GetHolder()->GetBlock()->GetLoopInformation() != loop) { in FixOutsideUse()
200 bool RewriteBreakLoopBody(HLoopInformation* loop, in RewriteBreakLoopBody() argument
207 for (HInstructionIterator it(loop->GetHeader()->GetPhis()); !it.Done(); it.Advance()) { in RewriteBreakLoopBody()
209 if (!FixOutsideUse(loop, it.Current(), exit_value, rewrite)) { in RewriteBreakLoopBody()
219 if (!FixOutsideUse(loop, m, FindFirstLoopHeaderPhiUse(loop, m), rewrite)) { in RewriteBreakLoopBody()
259 void HInductionVarAnalysis::VisitLoop(HLoopInformation* loop) { in VisitLoop() argument
266 for (HBlocksInLoopIterator it_loop(*loop); !it_loop.Done(); it_loop.Advance()) { in VisitLoop()
269 if (loop_block->GetLoopInformation() != loop) { in VisitLoop()
276 VisitNode(loop, instruction); in VisitLoop()
282 VisitNode(loop, instruction); in VisitLoop()
291 VisitControl(loop); in VisitLoop()
294 void HInductionVarAnalysis::VisitNode(HLoopInformation* loop, HInstruction* instruction) { in VisitNode() argument
302 low = std::min(low, VisitDescendant(loop, input)); in VisitNode()
328 ClassifyTrivial(loop, scc_[0]); in VisitNode()
330 ClassifyNonTrivial(loop); in VisitNode()
338 uint32_t HInductionVarAnalysis::VisitDescendant(HLoopInformation* loop, HInstruction* instruction) { in VisitDescendant() argument
342 if (otherLoop != loop) { in VisitDescendant()
348 VisitNode(loop, instruction); in VisitDescendant()
356 void HInductionVarAnalysis::ClassifyTrivial(HLoopInformation* loop, HInstruction* instruction) { in ClassifyTrivial() argument
359 info = TransferPhi(loop, instruction, /*input_index*/ 0, /*adjust_input_size*/ 0); in ClassifyTrivial()
361 info = TransferAddSub(LookupInfo(loop, instruction->InputAt(0)), in ClassifyTrivial()
362 LookupInfo(loop, instruction->InputAt(1)), kAdd); in ClassifyTrivial()
364 info = TransferAddSub(LookupInfo(loop, instruction->InputAt(0)), in ClassifyTrivial()
365 LookupInfo(loop, instruction->InputAt(1)), kSub); in ClassifyTrivial()
367 info = TransferNeg(LookupInfo(loop, instruction->InputAt(0))); in ClassifyTrivial()
369 info = TransferMul(LookupInfo(loop, instruction->InputAt(0)), in ClassifyTrivial()
370 LookupInfo(loop, instruction->InputAt(1))); in ClassifyTrivial()
372 HInstruction* mulc = GetShiftConstant(loop, instruction, /*initial*/ nullptr); in ClassifyTrivial()
374 info = TransferMul(LookupInfo(loop, instruction->InputAt(0)), in ClassifyTrivial()
375 LookupInfo(loop, mulc)); in ClassifyTrivial()
378 info = TransferPhi(loop, instruction, /*input_index*/ 0, /*adjust_input_size*/ 1); in ClassifyTrivial()
380 info = TransferConversion(LookupInfo(loop, instruction->InputAt(0)), in ClassifyTrivial()
384 info = LookupInfo(loop, instruction->InputAt(0)); // Pass-through. in ClassifyTrivial()
389 AssignInfo(loop, instruction, info); in ClassifyTrivial()
393 void HInductionVarAnalysis::ClassifyNonTrivial(HLoopInformation* loop) { in ClassifyNonTrivial() argument
401 RotateEntryPhiFirst(loop, &scc_, &other); in ClassifyNonTrivial()
411 InductionInfo* initial = LookupInfo(loop, phi->InputAt(0)); in ClassifyNonTrivial()
425 InductionInfo* update = TransferPhi(loop, phi, /*input_index*/ 1, /*adjust_input_size*/ 0); in ClassifyNonTrivial()
427 AssignInfo(loop, phi, CreateInduction(kWrapAround, in ClassifyNonTrivial()
443 update = SolvePhiAllInputs(loop, phi, instruction); in ClassifyNonTrivial()
446 loop, phi, instruction, instruction->InputAt(0), instruction->InputAt(1), kAdd, true); in ClassifyNonTrivial()
449 loop, phi, instruction, instruction->InputAt(0), instruction->InputAt(1), kSub, true); in ClassifyNonTrivial()
452 loop, phi, instruction, instruction->InputAt(0), instruction->InputAt(1), kMul); in ClassifyNonTrivial()
455 loop, phi, instruction, instruction->InputAt(0), instruction->InputAt(1), kDiv); in ClassifyNonTrivial()
458 loop, phi, instruction, instruction->InputAt(0), instruction->InputAt(1), kRem); in ClassifyNonTrivial()
460 HInstruction* mulc = GetShiftConstant(loop, instruction, /*initial*/ nullptr); in ClassifyNonTrivial()
462 update = SolveOp(loop, phi, instruction, instruction->InputAt(0), mulc, kMul); in ClassifyNonTrivial()
465 HInstruction* divc = GetShiftConstant(loop, instruction, initial); in ClassifyNonTrivial()
467 update = SolveOp(loop, phi, instruction, instruction->InputAt(0), divc, kDiv); in ClassifyNonTrivial()
471 loop, phi, instruction, instruction->InputAt(0), instruction->InputAt(1), kXor); in ClassifyNonTrivial()
473 update = SolveTest(loop, phi, instruction, 0); in ClassifyNonTrivial()
475 update = SolveTest(loop, phi, instruction, 1); in ClassifyNonTrivial()
479 update = SolveConversion(loop, phi, instruction->AsTypeConversion()); in ClassifyNonTrivial()
500 AssignInfo(loop, phi, induction); in ClassifyNonTrivial()
502 ClassifyTrivial(loop, scc_[i]); in ClassifyNonTrivial()
510 AssignInfo(loop, scc_[i], induction); in ClassifyNonTrivial()
513 AssignInfo(loop, phi, induction); in ClassifyNonTrivial()
545 HInductionVarAnalysis::InductionInfo* HInductionVarAnalysis::TransferPhi(HLoopInformation* loop, in TransferPhi() argument
552 InductionInfo* a = LookupInfo(loop, inputs[input_index]); in TransferPhi()
554 InductionInfo* b = LookupInfo(loop, inputs[i]); in TransferPhi()
696 HLoopInformation* loop, in SolvePhiAllInputs() argument
709 InductionInfo* a = LookupInfo(loop, phi->InputAt(0)); in SolvePhiAllInputs()
712 InductionInfo* initial = LookupInfo(loop, entry_phi->InputAt(0)); in SolvePhiAllInputs()
724 HInductionVarAnalysis::InductionInfo* HInductionVarAnalysis::SolveAddSub(HLoopInformation* loop, in SolveAddSub() argument
732 InductionInfo* b = LookupInfo(loop, y); in SolveAddSub()
751 InductionInfo* initial = LookupInfo(loop, entry_phi->InputAt(0)); in SolveAddSub()
764 return SolveAddSub(loop, entry_phi, instruction, y, x, op, false); in SolveAddSub()
770 InductionInfo* a = LookupInfo(loop, x); in SolveAddSub()
772 InductionInfo* initial = LookupInfo(loop, entry_phi->InputAt(0)); in SolveAddSub()
785 HInductionVarAnalysis::InductionInfo* HInductionVarAnalysis::SolveOp(HLoopInformation* loop, in SolveOp() argument
794 InductionInfo* b = LookupInfo(loop, y); in SolveOp()
798 InductionInfo* a = LookupInfo(loop, x); in SolveOp()
805 InductionInfo* initial = LookupInfo(loop, entry_phi->InputAt(0)); in SolveOp()
844 HInductionVarAnalysis::InductionInfo* HInductionVarAnalysis::SolveTest(HLoopInformation* loop, in SolveTest() argument
852 if (IsExact(LookupInfo(loop, x), &value) && value == opposite_value) { in SolveTest()
853 return SolveOp(loop, entry_phi, instruction, graph_->GetIntConstant(1), y, kXor); in SolveTest()
854 } else if (IsExact(LookupInfo(loop, y), &value) && value == opposite_value) { in SolveTest()
855 return SolveOp(loop, entry_phi, instruction, x, graph_->GetIntConstant(1), kXor); in SolveTest()
861 HLoopInformation* loop, in SolveConversion() argument
874 InductionInfo* initial = LookupInfo(loop, entry_phi->InputAt(0)); in SolveConversion()
892 void HInductionVarAnalysis::VisitControl(HLoopInformation* loop) { in VisitControl() argument
893 HInstruction* control = loop->GetHeader()->GetLastInstruction(); in VisitControl()
904 InductionInfo* a = LookupInfo(loop, condition->InputAt(0)); in VisitControl()
905 InductionInfo* b = LookupInfo(loop, condition->InputAt(1)); in VisitControl()
911 } else if (if_true->GetLoopInformation() != loop && if_false->GetLoopInformation() == loop) { in VisitControl()
912 VisitCondition(loop, if_false, a, b, type, condition->GetOppositeCondition()); in VisitControl()
913 } else if (if_true->GetLoopInformation() == loop && if_false->GetLoopInformation() != loop) { in VisitControl()
914 VisitCondition(loop, if_true, a, b, type, condition->GetCondition()); in VisitControl()
920 void HInductionVarAnalysis::VisitCondition(HLoopInformation* loop, in VisitCondition() argument
929 case kCondLT: VisitCondition(loop, body, b, a, type, kCondGT); break; in VisitCondition()
930 case kCondLE: VisitCondition(loop, body, b, a, type, kCondGE); break; in VisitCondition()
931 case kCondGT: VisitCondition(loop, body, b, a, type, kCondLT); break; in VisitCondition()
932 case kCondGE: VisitCondition(loop, body, b, a, type, kCondLE); break; in VisitCondition()
933 case kCondNE: VisitCondition(loop, body, b, a, type, kCondNE); break; in VisitCondition()
951 if (cmp == kCondNE && RewriteBreakLoop(loop, body, stride_value, type)) { in VisitCondition()
972 VisitTripCount(loop, lower_expr, upper_expr, stride_expr, stride_value, type, cmp); in VisitCondition()
977 void HInductionVarAnalysis::VisitTripCount(HLoopInformation* loop, in VisitTripCount() argument
1047 HInstruction* control = loop->GetHeader()->GetLastInstruction(); in VisitTripCount()
1050 AssignInfo(loop, control, CreateTripCount(tcKind, trip_count, taken_test, type)); in VisitTripCount()
1129 bool HInductionVarAnalysis::RewriteBreakLoop(HLoopInformation* loop, in RewriteBreakLoop() argument
1138 HIf* ifs = loop->GetHeader()->GetLastInstruction()->AsIf(); in RewriteBreakLoop()
1143 int c = LookupInfo(loop, cond->InputAt(0))->induction_class == kLinear ? 0 : 1; in RewriteBreakLoop()
1148 if (!index->IsPhi() || !IsFinite(LookupInfo(loop, upper), stride_value, type, cmp)) { in RewriteBreakLoop()
1153 body->GetSingleSuccessor() != loop->GetHeader() || in RewriteBreakLoop()
1162 if (!IsTaken(LookupInfo(loop, index)->op_b, LookupInfo(loop, upper), cmp) && in RewriteBreakLoop()
1163 !IsGuardedBy(loop, cmp, index->InputAt(0), upper)) { in RewriteBreakLoop()
1167 if (RewriteBreakLoopBody(loop, body, cond, index, upper, /*rewrite*/ false)) { in RewriteBreakLoop()
1168 RewriteBreakLoopBody(loop, body, cond, index, upper, /*rewrite*/ true); in RewriteBreakLoop()
1184 loop->GetHeader()->ReplaceAndRemoveInstructionWith(cond, rep); in RewriteBreakLoop()
1192 void HInductionVarAnalysis::AssignInfo(HLoopInformation* loop, in AssignInfo() argument
1195 auto it = induction_.find(loop); in AssignInfo()
1197 it = induction_.Put(loop, in AssignInfo()
1205 HInductionVarAnalysis::InductionInfo* HInductionVarAnalysis::LookupInfo(HLoopInformation* loop, in LookupInfo() argument
1207 auto it = induction_.find(loop); in LookupInfo()
1214 if (loop->IsDefinedOutOfTheLoop(instruction)) { in LookupInfo()
1216 AssignInfo(loop, instruction, info); in LookupInfo()
1295 HInstruction* HInductionVarAnalysis::GetShiftConstant(HLoopInformation* loop, in GetShiftConstant() argument
1312 InductionInfo* b = LookupInfo(loop, instruction->InputAt(1)); in GetShiftConstant()