Lines Matching full:guard
1 //===-- LoopPredication.cpp - Guard based loop predication pass -----------===//
14 // guard(i < len);
21 // guard(n - 1 < len);
25 // After this transformation the condition of the guard is loop invariant, so
39 // assumes that the guard doesn't fail. Using these facts to optimize the
40 // guard results in a circular logic where the guard is optimized under the
44 // basing on the guard. Basing on nuw the guard predicate will be considered
50 // guard(i u< len)
59 // guard(G(I));
71 // guard(G(0) && M);
79 // By the definition of guards we can rewrite the guard condition to:
105 // * The guard condition is of the form
158 // * The guard condition is of the form
295 Value *expandCheck(SCEVExpander &Expander, Instruction *Guard,
301 Instruction *Guard);
305 Instruction *Guard);
309 Instruction *Guard);
312 SCEVExpander &Expander, Instruction *Guard);
314 bool widenWidenableBranchGuardConditions(BranchInst *Guard, SCEVExpander &Expander);
376 Instruction *Guard,
383 IRBuilder<> Builder(Guard);
392 Expander.expandCodeFor(LHS, Ty, findInsertPt(Expander, Guard, {LHS}));
394 Expander.expandCodeFor(RHS, Ty, findInsertPt(Expander, Guard, {RHS}));
395 IRBuilder<> Builder(findInsertPt(Guard, {LHSV, RHSV}));
542 Instruction *Guard) {
556 // already guaranteed to dominate the guard.
564 if (!Expander.isSafeToExpandAt(LatchStart, Guard) ||
565 !Expander.isSafeToExpandAt(LatchLimit, Guard)) {
582 expandCheck(Expander, Guard, LimitCheckPred, LatchLimit, RHS);
583 auto *FirstIterationCheck = expandCheck(Expander, Guard, RangeCheck.Pred,
585 IRBuilder<> Builder(findInsertPt(Guard, {FirstIterationCheck, LimitCheck}));
592 Instruction *Guard) {
600 // already guaranteed to dominate the guard.
608 if (!Expander.isSafeToExpandAt(LatchStart, Guard) ||
609 !Expander.isSafeToExpandAt(LatchLimit, Guard)) {
629 auto *FirstIterationCheck = expandCheck(Expander, Guard,
632 auto *LimitCheck = expandCheck(Expander, Guard, LimitCheckPred, LatchLimit,
634 IRBuilder<> Builder(findInsertPt(Guard, {FirstIterationCheck, LimitCheck}));
655 Instruction *Guard) {
668 LLVM_DEBUG(dbgs() << "Guard check:\n");
709 Expander, Guard);
713 Expander, Guard);
719 SCEVExpander &Expander, Instruction *Guard) {
722 if (auto NewRangeCheck = widenICmpRangeCheck(ICI, Expander, Guard)) {
728 bool LoopPredication::widenGuardConditions(IntrinsicInst *Guard,
730 LLVM_DEBUG(dbgs() << "Processing guard:\n");
731 LLVM_DEBUG(Guard->dump());
736 parseWidenableGuard(Guard, Checks);
737 widenChecks(Checks, WidenedChecks, Expander, Guard);
743 // Emit the new guard condition
744 IRBuilder<> Builder(findInsertPt(Guard, Checks));
746 auto *OldCond = Guard->getOperand(0);
747 Guard->setOperand(0, AllChecks);
749 Builder.SetInsertPoint(&*++BasicBlock::iterator(Guard));
761 LLVM_DEBUG(dbgs() << "Processing guard:\n");
778 // Emit the new guard condition
788 // from guard block is Cond.
802 "Stopped being a guard after transform?");
1239 for (auto *Guard : Guards)
1240 Changed |= widenGuardConditions(Guard, Expander);
1241 for (auto *Guard : GuardsAsWidenableBranches)
1242 Changed |= widenWidenableBranchGuardConditions(Guard, Expander);