[llvm] Adding the support for vectorization of loops with load based tripcount (PR #209390)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 15 04:20:00 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- llvm/include/llvm/Analysis/LoopAccessAnalysis.h llvm/include/llvm/Analysis/ScalarEvolution.h llvm/lib/Analysis/LoopAccessAnalysis.cpp llvm/lib/Analysis/ScalarEvolution.cpp llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp llvm/lib/Transforms/Vectorize/LoopVectorize.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
index d84fd0e03..fd5bf6eea 100644
--- a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
+++ b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
@@ -697,7 +697,8 @@ public:
                           const TargetLibraryInfo *TLI, AAResults *AA,
                           DominatorTree *DT, LoopInfo *LI, AssumptionCache *AC,
                           bool AllowPartial = false,
-                          ArrayRef<const SCEVTripCountInvariantPredicate *> TripCountInvariantPreds = {});
+                          ArrayRef<const SCEVTripCountInvariantPredicate *>
+                              TripCountInvariantPreds = {});
 
   /// Return true we can analyze the memory accesses in the loop and there are
   /// no memory dependence cycles. Note that for dependences between loads &
@@ -717,7 +718,8 @@ public:
   /// could be analyzed.
   bool hasAllowPartial() const { return AllowPartial; }
 
-  ArrayRef<const SCEVTripCountInvariantPredicate *> getTripCountInvariantPreds() const {
+  ArrayRef<const SCEVTripCountInvariantPredicate *>
+  getTripCountInvariantPreds() const {
     return TripCountInvariantPreds;
   }
 
@@ -845,9 +847,10 @@ private:
   /// memory accesses could be analyzed.
   bool AllowPartial;
 
-  /// Predicates for the loops inside the loop which are used to compute the tripcount and
-  /// which this analysis assumes to be invariant.
-  SmallVector<const SCEVTripCountInvariantPredicate *, 2> TripCountInvariantPreds;
+  /// Predicates for the loops inside the loop which are used to compute the
+  /// tripcount and which this analysis assumes to be invariant.
+  SmallVector<const SCEVTripCountInvariantPredicate *, 2>
+      TripCountInvariantPreds;
 
   unsigned NumLoads = 0;
   unsigned NumStores = 0;
@@ -990,14 +993,15 @@ LLVM_ABI std::pair<const SCEV *, const SCEV *> getStartAndEndForAccess(
     DominatorTree *DT, AssumptionCache *AC,
     std::optional<ScalarEvolution::LoopGuards> &LoopGuards);
 
-/// This function will detect whether the loop is uncountabel because the tripcount
-/// is based on a load.
-/// If yes, then it will build a dependency chain of instructions, and a list of loads
-/// which are used to compute the tripcount.
-LLVM_ABI bool collectInvariantLoadsBoundChain(
-    Loop *L, ScalarEvolution *SE, DominatorTree *DT, AssumptionCache *AC,
-    SmallVectorImpl<Instruction *> &HoistedDeps,
-    SmallVectorImpl<LoadInst *> &BoundLoads);
+/// This function will detect whether the loop is uncountabel because the
+/// tripcount is based on a load. If yes, then it will build a dependency chain
+/// of instructions, and a list of loads which are used to compute the
+/// tripcount.
+LLVM_ABI bool
+collectInvariantLoadsBoundChain(Loop *L, ScalarEvolution *SE, DominatorTree *DT,
+                                AssumptionCache *AC,
+                                SmallVectorImpl<Instruction *> &HoistedDeps,
+                                SmallVectorImpl<LoadInst *> &BoundLoads);
 
 class LoopAccessInfoManager {
   /// The cache.
@@ -1020,8 +1024,10 @@ public:
 
   LLVM_ABI const LoopAccessInfo &getInfo(Loop &L, bool AllowPartial = false);
 
-  LLVM_ABI const LoopAccessInfo &getInfo(Loop &L, bool AllowPartial,
-        ArrayRef<const SCEVTripCountInvariantPredicate *> TripCountInvariantPreds);
+  LLVM_ABI const LoopAccessInfo &
+  getInfo(Loop &L, bool AllowPartial,
+          ArrayRef<const SCEVTripCountInvariantPredicate *>
+              TripCountInvariantPreds);
 
   LLVM_ABI void clear();
 
diff --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h
index f39553d30..15ea107d0 100644
--- a/llvm/include/llvm/Analysis/ScalarEvolution.h
+++ b/llvm/include/llvm/Analysis/ScalarEvolution.h
@@ -464,18 +464,19 @@ public:
   }
 };
 
-/// This class extends the SCEVPredicate class to represent the assumption that the trip count of a loop is invariant.
-/// This predicate doesn't lower any numeric run-time check but solely depends on the memory alias checks generated
-/// for the loop by LoopVectorizer.
-/// NOTE: Users of this predicate make sure to verify that the memory alias checks are generated for the loop.
+/// This class extends the SCEVPredicate class to represent the assumption that
+/// the trip count of a loop is invariant. This predicate doesn't lower any
+/// numeric run-time check but solely depends on the memory alias checks
+/// generated for the loop by LoopVectorizer. NOTE: Users of this predicate make
+/// sure to verify that the memory alias checks are generated for the loop.
 class LLVM_ABI SCEVTripCountInvariantPredicate final : public SCEVPredicate {
   const SCEV *TripCountLoad;
   const SCEV *TripCountInvariantLoad;
 
 public:
   SCEVTripCountInvariantPredicate(const FoldingSetNodeIDRef ID,
-                                 const SCEV *TripCountLoad,
-                                 const SCEV *TripCountInvariantLoad);
+                                  const SCEV *TripCountLoad,
+                                  const SCEV *TripCountInvariantLoad);
 
   /// Implementation of the SCEVPredicate interface
   bool implies(const SCEVPredicate *N, ScalarEvolution &SE) const override;
@@ -483,12 +484,14 @@ public:
   bool isAlwaysTrue() const override;
 
   /// This predicate doesn't generate any runtime checks, and solely depends
-  /// upon the memory alias checks for the runtime check generation, so contributes
-  /// nothing to the check complexity
+  /// upon the memory alias checks for the runtime check generation, so
+  /// contributes nothing to the check complexity
   unsigned getComplexity() const override { return 0; }
 
   const SCEV *getTripCountLoad() const { return TripCountLoad; }
-  const SCEV *getTripCountInvariantLoad() const { return TripCountInvariantLoad; }
+  const SCEV *getTripCountInvariantLoad() const {
+    return TripCountInvariantLoad;
+  }
 
   static bool classof(const SCEVPredicate *P) {
     return P->getKind() == P_TripCountInvariant;
@@ -1153,7 +1156,8 @@ public:
   LLVM_ABI const SCEV *getPredicatedSymbolicMaxBackedgeTakenCount(
       const Loop *L, SmallVectorImpl<const SCEVPredicate *> &Predicates);
 
-  /// To compute the backedge-taken count under the assumption of TripCountInvariant predicate.
+  /// To compute the backedge-taken count under the assumption of
+  /// TripCountInvariant predicate.
   LLVM_ABI const SCEV *computeBackedgeTakenCountWithTripCountInvariants(
       const Loop *L, ArrayRef<const SCEVTripCountInvariantPredicate *> Preds,
       bool SymbolicMax = false);
@@ -1558,8 +1562,8 @@ public:
   getWrapPredicate(const SCEVAddRecExpr *AR,
                    SCEVWrapPredicate::IncrementWrapFlags AddedFlags);
 
-  LLVM_ABI const SCEVPredicate *getTripCountInvariantPredicate(const SCEV *Load,
-                                                               const SCEV *InvariantLoad);
+  LLVM_ABI const SCEVPredicate *
+  getTripCountInvariantPredicate(const SCEV *Load, const SCEV *InvariantLoad);
 
   /// Re-writes the SCEV according to the Predicates in \p A.
   LLVM_ABI const SCEV *rewriteUsingPredicate(const SCEV *S, const Loop *L,
@@ -1929,7 +1933,8 @@ private:
   /// function as they are computed.
   DenseMap<const Loop *, BackedgeTakenInfo> PredicatedBackedgeTakenCounts;
 
-  DenseMap<const Value *, const SCEV *> *ActiveTripCountInvariantSubst = nullptr;
+  DenseMap<const Value *, const SCEV *> *ActiveTripCountInvariantSubst =
+      nullptr;
 
   /// Loops whose backedge taken counts directly use this non-constant SCEV.
   DenseMap<const SCEV *, SmallPtrSet<PointerIntPair<const Loop *, 1, bool>, 4>>
@@ -2703,7 +2708,8 @@ public:
     return !TripCountInvariantPreds.empty();
   }
 
-  LLVM_ABI ArrayRef<const SCEVTripCountInvariantPredicate *> getTripCountInvariantPredicates() const {
+  LLVM_ABI ArrayRef<const SCEVTripCountInvariantPredicate *>
+  getTripCountInvariantPredicates() const {
     return TripCountInvariantPreds;
   }
 
@@ -2778,7 +2784,8 @@ private:
   /// The symbolic backedge taken count.
   const SCEV *SymbolicMaxBackedgeCount = nullptr;
 
-  SmallVector<const SCEVTripCountInvariantPredicate *, 2> TripCountInvariantPreds;
+  SmallVector<const SCEVTripCountInvariantPredicate *, 2>
+      TripCountInvariantPreds;
 
   DenseMap<const Value *, const SCEV *> TripCountInvariantMap;
 
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index aecb316fd..77a7a1e02 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -25,9 +25,9 @@
 #include "llvm/Analysis/AliasSetTracker.h"
 #include "llvm/Analysis/AssumeBundleQueries.h"
 #include "llvm/Analysis/AssumptionCache.h"
+#include "llvm/Analysis/Loads.h"
 #include "llvm/Analysis/LoopAnalysisManager.h"
 #include "llvm/Analysis/LoopInfo.h"
-#include "llvm/Analysis/Loads.h"
 #include "llvm/Analysis/LoopIterator.h"
 #include "llvm/Analysis/MemoryLocation.h"
 #include "llvm/Analysis/OptimizationRemarkEmitter.h"
@@ -3204,15 +3204,17 @@ static bool isSafeToHoistBoundLoad(Instruction *I,
     if (ModifiedPtrs.count(Ptr)) {
       return false;
     }
-    if (!isBoundLoadSafeToLoadAtCtx(Ptr, LI->getType(), LI->getAlign(), CtxI, DT,
-                                   AC)) {
+    if (!isBoundLoadSafeToLoadAtCtx(Ptr, LI->getType(), LI->getAlign(), CtxI,
+                                    DT, AC)) {
       return false;
     }
     return true;
   }
 
-  // Limiting down the kind of instructions we can hoist to avoid any unforeseen side effects.
-  if (I->isBinaryOp() || I->isUnaryOp() || I->isCast() || isa<GetElementPtrInst>(I)) {
+  // Limiting down the kind of instructions we can hoist to avoid any unforeseen
+  // side effects.
+  if (I->isBinaryOp() || I->isUnaryOp() || I->isCast() ||
+      isa<GetElementPtrInst>(I)) {
     return isSafeToSpeculativelyExecute(I, CtxI, AC, DT);
   }
   return false;
@@ -3255,7 +3257,8 @@ LLVM_ABI bool llvm::collectInvariantLoadsBoundChain(
 
   /// Anything written inside the loop is a "not-invariant" pointer; the bound
   /// load cannot share a pointer with such writes.
-  /// This is to prune out cases like for (i = 0; i < *Len; ++i) { Len[i] = ..*.. }
+  /// This is to prune out cases like for (i = 0; i < *Len; ++i) { Len[i] =
+  /// ..*.. }
   SmallPtrSet<Value *, 16> ModifiedPtrs;
   for (BasicBlock *BB : L->getBlocks()) {
     for (Instruction &I : *BB) {
@@ -3324,18 +3327,18 @@ LLVM_ABI bool llvm::collectInvariantLoadsBoundChain(
   return !BoundLoads.empty() && !HoistedDeps.empty();
 }
 
-LoopAccessInfo::LoopAccessInfo(Loop *L, ScalarEvolution *SE,
-                               const TargetTransformInfo *TTI,
-                               const TargetLibraryInfo *TLI, AAResults *AA,
-                               DominatorTree *DT, LoopInfo *LI,
-                               AssumptionCache *AC, bool AllowPartial,
-                               ArrayRef<const SCEVTripCountInvariantPredicate *> TripCountInvariantPreds)
+LoopAccessInfo::LoopAccessInfo(
+    Loop *L, ScalarEvolution *SE, const TargetTransformInfo *TTI,
+    const TargetLibraryInfo *TLI, AAResults *AA, DominatorTree *DT,
+    LoopInfo *LI, AssumptionCache *AC, bool AllowPartial,
+    ArrayRef<const SCEVTripCountInvariantPredicate *> TripCountInvariantPreds)
     : PSE(std::make_unique<PredicatedScalarEvolution>(*SE, *L)),
       PtrRtChecking(nullptr), TheLoop(L), AllowPartial(AllowPartial),
       TripCountInvariantPreds(TripCountInvariantPreds) {
 
   for (const SCEVTripCountInvariantPredicate *P : TripCountInvariantPreds) {
-    PSE->addTripCountInvariantPredicate(P->getTripCountLoad(), P->getTripCountInvariantLoad());
+    PSE->addTripCountInvariantPredicate(P->getTripCountLoad(),
+                                        P->getTripCountInvariantLoad());
   }
 
   unsigned MaxTargetVectorWidthInBits = std::numeric_limits<unsigned>::max();
@@ -3413,9 +3416,9 @@ const LoopAccessInfo &LoopAccessInfoManager::getInfo(Loop &L,
   return getInfo(L, AllowPartial, {});
 }
 
-const LoopAccessInfo &LoopAccessInfoManager::getInfo(Loop &L,
-                                                     bool AllowPartial,
-                                                     ArrayRef<const SCEVTripCountInvariantPredicate *> TripCountInvariantPreds) {
+const LoopAccessInfo &LoopAccessInfoManager::getInfo(
+    Loop &L, bool AllowPartial,
+    ArrayRef<const SCEVTripCountInvariantPredicate *> TripCountInvariantPreds) {
   const auto &[It, Inserted] = LoopAccessInfoMap.try_emplace(&L);
 
   auto SamePreds = [&]() {
@@ -3423,14 +3426,16 @@ const LoopAccessInfo &LoopAccessInfoManager::getInfo(Loop &L,
         It->second->getTripCountInvariantPreds();
     if (Cached.size() != TripCountInvariantPreds.size())
       return false;
-    return std::equal(Cached.begin(), Cached.end(), TripCountInvariantPreds.begin());
+    return std::equal(Cached.begin(), Cached.end(),
+                      TripCountInvariantPreds.begin());
   };
 
   // We need to create the LoopAccessInfo if either we don't already have one,
   // or if it was created with a different value of AllowPartial.
   if (Inserted || It->second->hasAllowPartial() != AllowPartial || !SamePreds())
-    It->second = std::make_unique<LoopAccessInfo>(&L, &SE, TTI, TLI, &AA, &DT,
-                                                  &LI, AC, AllowPartial, TripCountInvariantPreds);
+    It->second =
+        std::make_unique<LoopAccessInfo>(&L, &SE, TTI, TLI, &AA, &DT, &LI, AC,
+                                         AllowPartial, TripCountInvariantPreds);
 
   return *It->second;
 }
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index a204c4694..029268653 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -8695,7 +8695,8 @@ const SCEV *ScalarEvolution::computeBackedgeTakenCountWithTripCountInvariants(
 
   SaveAndRestore<DenseMap<const Value *, const SCEV *> *> Active(
       ActiveTripCountInvariantSubst, &Subst);
-  BackedgeTakenInfo BTI = computeBackedgeTakenCount(L, /*AllowPredicates=*/false);
+  BackedgeTakenInfo BTI =
+      computeBackedgeTakenCount(L, /*AllowPredicates=*/false);
   return SymbolicMax ? BTI.getSymbolicMax(L, this) : BTI.getExact(L, this);
 }
 
@@ -9487,10 +9488,12 @@ ScalarEvolution::ExitLimit ScalarEvolution::computeExitLimitFromICmp(
   const SCEV *LHS = getSCEV(ExitCond->getOperand(0));
   const SCEV *RHS = getSCEV(ExitCond->getOperand(1));
 
-  // If the TripCountInvariant predicate is active, then replace the LHS and RHS to their proper
-  // substition values as per the substitution map.
-  if (ActiveTripCountInvariantSubst && !ActiveTripCountInvariantSubst->empty()) {
-    auto &Subst = const_cast<ValueToSCEVMapTy &>(*ActiveTripCountInvariantSubst);
+  // If the TripCountInvariant predicate is active, then replace the LHS and RHS
+  // to their proper substition values as per the substitution map.
+  if (ActiveTripCountInvariantSubst &&
+      !ActiveTripCountInvariantSubst->empty()) {
+    auto &Subst =
+        const_cast<ValueToSCEVMapTy &>(*ActiveTripCountInvariantSubst);
 
     LHS = SCEVParameterRewriter::rewrite(LHS, *this, Subst);
     RHS = SCEVParameterRewriter::rewrite(RHS, *this, Subst);
@@ -15295,8 +15298,9 @@ const SCEVPredicate *ScalarEvolution::getWrapPredicate(
   return OF;
 }
 
-const SCEVPredicate *ScalarEvolution::getTripCountInvariantPredicate(const SCEV *Load,
-                                                                     const SCEV *InvariantLoad) {
+const SCEVPredicate *
+ScalarEvolution::getTripCountInvariantPredicate(const SCEV *Load,
+                                                const SCEV *InvariantLoad) {
   FoldingSetNodeID ID;
   ID.AddInteger(SCEVPredicate::P_TripCountInvariant);
   ID.AddPointer(Load);
@@ -15304,8 +15308,8 @@ const SCEVPredicate *ScalarEvolution::getTripCountInvariantPredicate(const SCEV
   void *IP = nullptr;
   if (const auto *S = UniquePreds.FindNodeOrInsertPos(ID, IP))
     return S;
-  auto *TCI = new (SCEVAllocator)
-      SCEVTripCountInvariantPredicate(ID.Intern(SCEVAllocator), Load, InvariantLoad);
+  auto *TCI = new (SCEVAllocator) SCEVTripCountInvariantPredicate(
+      ID.Intern(SCEVAllocator), Load, InvariantLoad);
   UniquePreds.InsertNode(TCI, IP);
   return TCI;
 }
@@ -15517,27 +15521,30 @@ void SCEVComparePredicate::print(raw_ostream &OS, unsigned Depth) const {
 
 }
 
-SCEVTripCountInvariantPredicate::SCEVTripCountInvariantPredicate(const FoldingSetNodeIDRef ID,
-                                                                   const SCEV *TripCountLoad,
-                                                                   const SCEV *TripCountInvariantLoad)
-  : SCEVPredicate(ID, P_TripCountInvariant), TripCountLoad(TripCountLoad), TripCountInvariantLoad(TripCountInvariantLoad) {}
+SCEVTripCountInvariantPredicate::SCEVTripCountInvariantPredicate(
+    const FoldingSetNodeIDRef ID, const SCEV *TripCountLoad,
+    const SCEV *TripCountInvariantLoad)
+    : SCEVPredicate(ID, P_TripCountInvariant), TripCountLoad(TripCountLoad),
+      TripCountInvariantLoad(TripCountInvariantLoad) {}
 
 bool SCEVTripCountInvariantPredicate::implies(const SCEVPredicate *N,
                                               ScalarEvolution &SE) const {
   const auto *Op = dyn_cast<SCEVTripCountInvariantPredicate>(N);
   if (!Op)
     return false;
-  return Op->TripCountLoad == TripCountLoad && Op->TripCountInvariantLoad == TripCountInvariantLoad;
+  return Op->TripCountLoad == TripCountLoad &&
+         Op->TripCountInvariantLoad == TripCountInvariantLoad;
 }
 
 bool SCEVTripCountInvariantPredicate::isAlwaysTrue() const {
   return TripCountLoad == TripCountInvariantLoad;
 }
 
-void SCEVTripCountInvariantPredicate::print(raw_ostream &OS, unsigned Depth) const {
-  OS.indent(Depth) << "Trip count invariant predicate: " << *TripCountLoad 
-                              << " is invariant (== " << *TripCountInvariantLoad << ")\n"
-                              << "\n";
+void SCEVTripCountInvariantPredicate::print(raw_ostream &OS,
+                                            unsigned Depth) const {
+  OS.indent(Depth) << "Trip count invariant predicate: " << *TripCountLoad
+                   << " is invariant (== " << *TripCountInvariantLoad << ")\n"
+                   << "\n";
 }
 
 SCEVWrapPredicate::SCEVWrapPredicate(const FoldingSetNodeIDRef ID,
@@ -15756,7 +15763,8 @@ const SCEV *PredicatedScalarEvolution::getPredicatedSCEV(const SCEV *Expr) {
   const SCEV *NewSCEV = SE.rewriteUsingPredicate(Expr, &L, *Preds);
 
   if (!TripCountInvariantMap.empty()) {
-    NewSCEV = SCEVParameterRewriter::rewrite(NewSCEV, SE, TripCountInvariantMap);
+    NewSCEV =
+        SCEVParameterRewriter::rewrite(NewSCEV, SE, TripCountInvariantMap);
   }
 
   Entry = {Generation, NewSCEV};
@@ -15767,10 +15775,9 @@ const SCEV *PredicatedScalarEvolution::getPredicatedSCEV(const SCEV *Expr) {
 const SCEV *PredicatedScalarEvolution::getBackedgeTakenCount() {
   if (!BackedgeCount) {
     if (!TripCountInvariantPreds.empty()) {
-      BackedgeCount = SE.computeBackedgeTakenCountWithTripCountInvariants(&L, 
-        TripCountInvariantPreds, /*SymbolicMax=*/false);
-    }
-    else {
+      BackedgeCount = SE.computeBackedgeTakenCountWithTripCountInvariants(
+          &L, TripCountInvariantPreds, /*SymbolicMax=*/false);
+    } else {
       SmallVector<const SCEVPredicate *, 4> Preds;
       BackedgeCount = SE.getPredicatedBackedgeTakenCount(&L, Preds);
       for (const auto *P : Preds)
@@ -15783,10 +15790,10 @@ const SCEV *PredicatedScalarEvolution::getBackedgeTakenCount() {
 const SCEV *PredicatedScalarEvolution::getSymbolicMaxBackedgeTakenCount() {
   if (!SymbolicMaxBackedgeCount) {
     if (!TripCountInvariantPreds.empty()) {
-      SymbolicMaxBackedgeCount = SE.computeBackedgeTakenCountWithTripCountInvariants(&L, 
-        TripCountInvariantPreds, /*SymbolicMax=*/true);
-    }
-    else {
+      SymbolicMaxBackedgeCount =
+          SE.computeBackedgeTakenCountWithTripCountInvariants(
+              &L, TripCountInvariantPreds, /*SymbolicMax=*/true);
+    } else {
       SmallVector<const SCEVPredicate *, 4> Preds;
       SymbolicMaxBackedgeCount =
           SE.getPredicatedSymbolicMaxBackedgeTakenCount(&L, Preds);
@@ -15817,7 +15824,8 @@ void PredicatedScalarEvolution::addPredicate(const SCEVPredicate &Pred) {
   updateGeneration();
 }
 
-void PredicatedScalarEvolution::addTripCountInvariantPredicate(const SCEV *Load, const SCEV *InvariantLoad) {
+void PredicatedScalarEvolution::addTripCountInvariantPredicate(
+    const SCEV *Load, const SCEV *InvariantLoad) {
   const auto *V = dyn_cast<SCEVUnknown>(Load);
   assert(V && "mem-invariant Load must be a SCEVUnknown");
 
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
index 94e101297..ddae25fc1 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
@@ -1158,8 +1158,7 @@ bool LoopVectorizationLegality::canVectorizeIndirectUnsafeDependences() {
 }
 
 bool LoopVectorizationLegality::canVectorizeMemory() {
-  LAI = &LAIs.getInfo(*TheLoop, false,
-      PSE.getTripCountInvariantPredicates());
+  LAI = &LAIs.getInfo(*TheLoop, false, PSE.getTripCountInvariantPredicates());
   const OptimizationRemarkAnalysis *LAR = LAI->getReport();
   if (LAR) {
     ORE->emit([&]() {
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 7dbd53a83..95a0cd21a 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -1643,8 +1643,7 @@ public:
           SCEVPredsVec.push_back(P);
         }
       }
-    }
-    else if (!isa<SCEVTripCountInvariantPredicate>(&UnionPred)) {
+    } else if (!isa<SCEVTripCountInvariantPredicate>(&UnionPred)) {
       SCEVPredsVec.push_back(&UnionPred);
     }
     SCEVUnionPredicate FilteredPred(SCEVPredsVec, *PSE.getSE());
@@ -7882,7 +7881,7 @@ bool EnableLoadBoundVectorization(Loop *L, PredicatedScalarEvolution &PSE,
                                   ScalarEvolution *SE, DominatorTree *DT,
                                   AssumptionCache *AC) {
   if (!L->isInnermost() || !L->isLoopSimplifyForm() ||
-    L->getNumBackEdges() != 1 || !L->getUniqueExitBlock()) {
+      L->getNumBackEdges() != 1 || !L->getUniqueExitBlock()) {
     return false;
   }
 
@@ -7892,7 +7891,8 @@ bool EnableLoadBoundVectorization(Loop *L, PredicatedScalarEvolution &PSE,
 
   SmallVector<Instruction *, 16> HoistedDeps;
   SmallVector<LoadInst *, 4> BoundLoads;
-  if (!collectInvariantLoadsBoundChain(L, SE, DT, AC, HoistedDeps, BoundLoads)) {
+  if (!collectInvariantLoadsBoundChain(L, SE, DT, AC, HoistedDeps,
+                                       BoundLoads)) {
     return false;
   }
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/209390


More information about the llvm-commits mailing list