[llvm] r357330 - [LoopPredication] Use the builder's insertion point everywhere [NFC]
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 29 16:06:57 PDT 2019
Author: reames
Date: Fri Mar 29 16:06:57 2019
New Revision: 357330
URL: http://llvm.org/viewvc/llvm-project?rev=357330&view=rev
Log:
[LoopPredication] Use the builder's insertion point everywhere [NFC]
Modified:
llvm/trunk/lib/Transforms/Scalar/LoopPredication.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/LoopPredication.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopPredication.cpp?rev=357330&r1=357329&r2=357330&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopPredication.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopPredication.cpp Fri Mar 29 16:06:57 2019
@@ -265,8 +265,8 @@ class LoopPredication {
bool CanExpand(const SCEV* S);
Value *expandCheck(SCEVExpander &Expander, IRBuilder<> &Builder,
- ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS,
- Instruction *InsertAt);
+ ICmpInst::Predicate Pred, const SCEV *LHS,
+ const SCEV *RHS);
Optional<Value *> widenICmpRangeCheck(ICmpInst *ICI, SCEVExpander &Expander,
IRBuilder<> &Builder);
@@ -389,7 +389,7 @@ LoopPredication::parseLoopICmp(ICmpInst:
Value *LoopPredication::expandCheck(SCEVExpander &Expander,
IRBuilder<> &Builder,
ICmpInst::Predicate Pred, const SCEV *LHS,
- const SCEV *RHS, Instruction *InsertAt) {
+ const SCEV *RHS) {
// TODO: we can check isLoopEntryGuardedByCond before emitting the check
Type *Ty = LHS->getType();
@@ -398,6 +398,7 @@ Value *LoopPredication::expandCheck(SCEV
if (SE->isLoopEntryGuardedByCond(L, Pred, LHS, RHS))
return Builder.getTrue();
+ Instruction *InsertAt = &*Builder.GetInsertPoint();
Value *LHSV = Expander.expandCodeFor(LHS, Ty, InsertAt);
Value *RHSV = Expander.expandCodeFor(RHS, Ty, InsertAt);
return Builder.CreateICmp(Pred, LHSV, RHSV);
@@ -469,12 +470,11 @@ Optional<Value *> LoopPredication::widen
LLVM_DEBUG(dbgs() << "LHS: " << *LatchLimit << "\n");
LLVM_DEBUG(dbgs() << "RHS: " << *RHS << "\n");
LLVM_DEBUG(dbgs() << "Pred: " << LimitCheckPred << "\n");
-
- Instruction *InsertAt = Preheader->getTerminator();
+
auto *LimitCheck =
- expandCheck(Expander, Builder, LimitCheckPred, LatchLimit, RHS, InsertAt);
+ expandCheck(Expander, Builder, LimitCheckPred, LatchLimit, RHS);
auto *FirstIterationCheck = expandCheck(Expander, Builder, RangeCheck.Pred,
- GuardStart, GuardLimit, InsertAt);
+ GuardStart, GuardLimit);
return Builder.CreateAnd(FirstIterationCheck, LimitCheck);
}
@@ -504,13 +504,12 @@ Optional<Value *> LoopPredication::widen
// guardStart u< guardLimit &&
// latchLimit <pred> 1.
// See the header comment for reasoning of the checks.
- Instruction *InsertAt = Preheader->getTerminator();
auto LimitCheckPred =
ICmpInst::getFlippedStrictnessPredicate(LatchCheck.Pred);
auto *FirstIterationCheck = expandCheck(Expander, Builder, ICmpInst::ICMP_ULT,
- GuardStart, GuardLimit, InsertAt);
+ GuardStart, GuardLimit);
auto *LimitCheck = expandCheck(Expander, Builder, LimitCheckPred, LatchLimit,
- SE->getOne(Ty), InsertAt);
+ SE->getOne(Ty));
return Builder.CreateAnd(FirstIterationCheck, LimitCheck);
}
@@ -607,7 +606,8 @@ unsigned LoopPredication::collectChecks(
}
if (ICmpInst *ICI = dyn_cast<ICmpInst>(Condition)) {
- if (auto NewRangeCheck = widenICmpRangeCheck(ICI, Expander, Builder)) {
+ if (auto NewRangeCheck = widenICmpRangeCheck(ICI, Expander,
+ Builder)) {
Checks.push_back(NewRangeCheck.getValue());
NumWidened++;
continue;
More information about the llvm-commits
mailing list