[llvm] r362415 - [LoopPred] Convert a second member function to a static helper [NFC]
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 3 09:23:20 PDT 2019
Author: reames
Date: Mon Jun 3 09:23:20 2019
New Revision: 362415
URL: http://llvm.org/viewvc/llvm-project?rev=362415&view=rev
Log:
[LoopPred] Convert a second member function to a static helper [NFC]
(And remember to actually mark the first one static.)
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=362415&r1=362414&r2=362415&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopPredication.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopPredication.cpp Mon Jun 3 09:23:20 2019
@@ -300,10 +300,6 @@ class LoopPredication {
// within the loop. We identify such unprofitable loops through BPI.
bool isLoopProfitableToPredicate();
- // Return the loopLatchCheck corresponding to the RangeCheckType if safe to do
- // so.
- Optional<LoopICmp> generateLoopLatchCheck(Type *RangeCheckType);
-
public:
LoopPredication(AliasAnalysis *AA, ScalarEvolution *SE,
BranchProbabilityInfo *BPI)
@@ -426,9 +422,10 @@ Value *LoopPredication::expandCheck(SCEV
// sext(x + y) is same as sext(x) + sext(y).
// This function returns true if we can safely represent the IV type in
// the RangeCheckType without loss of information.
-bool isSafeToTruncateWideIVType(const DataLayout &DL, ScalarEvolution &SE,
- const LoopICmp LatchCheck,
- Type *RangeCheckType) {
+static bool isSafeToTruncateWideIVType(const DataLayout &DL,
+ ScalarEvolution &SE,
+ const LoopICmp LatchCheck,
+ Type *RangeCheckType) {
if (!EnableIVTruncation)
return false;
assert(DL.getTypeSizeInBits(LatchCheck.IV->getType()) >
@@ -458,26 +455,30 @@ bool isSafeToTruncateWideIVType(const Da
}
-Optional<LoopICmp>
-LoopPredication::generateLoopLatchCheck(Type *RangeCheckType) {
+// Return an LoopICmp describing a latch check equivlent to LatchCheck but with
+// the requested type if safe to do so. May involve the use of a new IV.
+static Optional<LoopICmp> generateLoopLatchCheck(const DataLayout &DL,
+ ScalarEvolution &SE,
+ const LoopICmp LatchCheck,
+ Type *RangeCheckType) {
auto *LatchType = LatchCheck.IV->getType();
if (RangeCheckType == LatchType)
return LatchCheck;
// For now, bail out if latch type is narrower than range type.
- if (DL->getTypeSizeInBits(LatchType) < DL->getTypeSizeInBits(RangeCheckType))
+ if (DL.getTypeSizeInBits(LatchType) < DL.getTypeSizeInBits(RangeCheckType))
return None;
- if (!isSafeToTruncateWideIVType(*DL, *SE, LatchCheck, RangeCheckType))
+ if (!isSafeToTruncateWideIVType(DL, SE, LatchCheck, RangeCheckType))
return None;
// We can now safely identify the truncated version of the IV and limit for
// RangeCheckType.
LoopICmp NewLatchCheck;
NewLatchCheck.Pred = LatchCheck.Pred;
NewLatchCheck.IV = dyn_cast<SCEVAddRecExpr>(
- SE->getTruncateExpr(LatchCheck.IV, RangeCheckType));
+ SE.getTruncateExpr(LatchCheck.IV, RangeCheckType));
if (!NewLatchCheck.IV)
return None;
- NewLatchCheck.Limit = SE->getTruncateExpr(LatchCheck.Limit, RangeCheckType);
+ NewLatchCheck.Limit = SE.getTruncateExpr(LatchCheck.Limit, RangeCheckType);
LLVM_DEBUG(dbgs() << "IV of type: " << *LatchType
<< "can be represented as range check type:"
<< *RangeCheckType << "\n");
@@ -693,7 +694,7 @@ Optional<Value *> LoopPredication::widen
return None;
}
auto *Ty = RangeCheckIV->getType();
- auto CurrLatchCheckOpt = generateLoopLatchCheck(Ty);
+ auto CurrLatchCheckOpt = generateLoopLatchCheck(*DL, *SE, LatchCheck, Ty);
if (!CurrLatchCheckOpt) {
LLVM_DEBUG(dbgs() << "Failed to generate a loop latch check "
"corresponding to range type: "
More information about the llvm-commits
mailing list