[llvm] [LV] Remove unused functions (NFC) (PR #226048)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 24 00:36:21 PDT 2026


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/226048

isInductionVariable:
The last caller was removed on December 19, 2025 in commit
1f78f6a2d629b0dd410a3d20429f76377ac5d6c3, leaving
isCastedInductionVariable without any callers and
InductionCastsToIgnore without any readers.

getNumStores, getNumLoads:
The last callers were removed on August 5, 2025 in commit
c9dd14d1d4c357ad29e0e5c446f1bb8f596ab9c0.

hasVector:
The last caller was removed on June 24, 2024 in commit
abf5969f76c6b4196b08fe5ea9c2890e97a61357.

getInLoopReductionImmediateChain:
The last caller was removed on September 4, 2026 in commit
278d9f76594de1ad0fac669468bf083ad6616a0f, leaving
InLoopReductionImmediateChains without any readers.

preferTailFoldedLoop:
The last caller was removed on August 12, 2026 in commit
97773f262edefabce826ed56f438005d34a78f4b.

Assisted-by: Antigravity


>From 8ed60360419a4d8b97341dc4c1aede6c9039a0c8 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Wed, 23 Sep 2026 09:57:24 -0700
Subject: [PATCH] [LV] Remove unused functions (NFC)

isInductionVariable:
The last caller was removed on December 19, 2025 in commit
1f78f6a2d629b0dd410a3d20429f76377ac5d6c3, leaving
isCastedInductionVariable without any callers and
InductionCastsToIgnore without any readers.

getNumStores, getNumLoads:
The last callers were removed on August 5, 2025 in commit
c9dd14d1d4c357ad29e0e5c446f1bb8f596ab9c0.

hasVector:
The last caller was removed on June 24, 2024 in commit
abf5969f76c6b4196b08fe5ea9c2890e97a61357.

getInLoopReductionImmediateChain:
The last caller was removed on September 4, 2026 in commit
278d9f76594de1ad0fac669468bf083ad6616a0f, leaving
InLoopReductionImmediateChains without any readers.

preferTailFoldedLoop:
The last caller was removed on August 12, 2026 in commit
97773f262edefabce826ed56f438005d34a78f4b.

Assisted-by: Antigravity
---
 .../Vectorize/LoopVectorizationLegality.h     | 19 -------------------
 .../Vectorize/LoopVectorizationLegality.cpp   | 18 ------------------
 .../Vectorize/LoopVectorizationPlanner.cpp    |  9 +--------
 .../Vectorize/LoopVectorizationPlanner.h      | 17 -----------------
 .../Transforms/Vectorize/LoopVectorize.cpp    |  6 ------
 5 files changed, 1 insertion(+), 68 deletions(-)

diff --git a/llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h b/llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
index 7b8b27c6541e1..1d35938a8e13f 100644
--- a/llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
+++ b/llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
@@ -347,16 +347,6 @@ class LoopVectorizationLegality {
   /// Returns True if V is a Phi node of an induction variable in this loop.
   LLVM_ABI bool isInductionPhi(const Value *V) const;
 
-  /// Returns True if V is a cast that is part of an induction def-use chain,
-  /// and had been proven to be redundant under a runtime guard (in other
-  /// words, the cast has the same SCEV expression as the induction phi).
-  LLVM_ABI bool isCastedInductionVariable(const Value *V) const;
-
-  /// Returns True if V can be considered as an induction variable in this
-  /// loop. V can be the induction phi, or some redundant cast in the def-use
-  /// chain of the inducion phi.
-  LLVM_ABI bool isInductionVariable(const Value *V) const;
-
   /// Returns True if PN is a reduction variable in this loop.
   bool isReductionVariable(PHINode *PN) const { return Reductions.count(PN); }
 
@@ -458,9 +448,6 @@ class LoopVectorizationLegality {
   /// has a vectorized variant available.
   bool hasVectorCallVariants() const { return VecCallVariantsFound; }
 
-  unsigned getNumStores() const { return LAI->getNumStores(); }
-  unsigned getNumLoads() const { return LAI->getNumLoads(); }
-
   /// Returns a HistogramInfo* for the given instruction if it was determined
   /// to be part of a load -> update -> store sequence where multiple lanes
   /// may be working on the same memory address.
@@ -689,12 +676,6 @@ class LoopVectorizationLegality {
   /// variables can be pointers.
   InductionList Inductions;
 
-  /// Holds all the casts that participate in the update chain of the induction
-  /// variables, and that have been proven to be redundant (possibly under a
-  /// runtime guard). These casts can be ignored when creating the vectorized
-  /// loop body.
-  SmallPtrSet<Instruction *, 4> InductionCastsToIgnore;
-
   /// Holds the phi nodes that are fixed-order recurrences.
   RecurrenceSet FixedOrderRecurrences;
 
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
index 953b1a41e9ee2..862470ce0de6d 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
@@ -707,14 +707,6 @@ void LoopVectorizationLegality::addInductionPhi(PHINode *Phi,
                                                 const InductionDescriptor &ID) {
   Inductions[Phi] = ID;
 
-  // In case this induction also comes with casts that we know we can ignore
-  // in the vectorized loop body, record them here. All casts could be recorded
-  // here for ignoring, but suffices to record only the first (as it is the
-  // only one that may bw used outside the cast sequence).
-  ArrayRef<Instruction *> Casts = ID.getCastInsts();
-  if (!Casts.empty())
-    InductionCastsToIgnore.insert(*Casts.begin());
-
   Type *PhiTy = Phi->getType();
   const DataLayout &DL = Phi->getDataLayout();
 
@@ -1358,16 +1350,6 @@ bool LoopVectorizationLegality::isInductionPhi(const Value *V) const {
   return Inductions.count(PN);
 }
 
-bool LoopVectorizationLegality::isCastedInductionVariable(
-    const Value *V) const {
-  auto *Inst = dyn_cast<Instruction>(V);
-  return (Inst && InductionCastsToIgnore.count(Inst));
-}
-
-bool LoopVectorizationLegality::isInductionVariable(const Value *V) const {
-  return isInductionPhi(V) || isCastedInductionVariable(V);
-}
-
 bool LoopVectorizationLegality::isFixedOrderRecurrence(
     const PHINode *Phi) const {
   return FixedOrderRecurrences.count(Phi);
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.cpp
index 17ea2932ddd50..4b38c5dad753c 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.cpp
@@ -692,15 +692,8 @@ void VFSelectionContext::collectInLoopReductions() {
         RdxDesc.getReductionOpChain(Phi, const_cast<Loop *>(TheLoop));
     bool InLoop = !ReductionOperations.empty();
 
-    if (InLoop) {
+    if (InLoop)
       InLoopReductions.insert(Phi);
-      // Add the elements to InLoopReductionImmediateChains for cost modelling.
-      Instruction *LastChain = Phi;
-      for (auto *I : ReductionOperations) {
-        InLoopReductionImmediateChains[I] = LastChain;
-        LastChain = I;
-      }
-    }
     LLVM_DEBUG(dbgs() << "LV: Using " << (InLoop ? "inloop" : "out of loop")
                       << " reduction for phi: " << *Phi << "\n");
   }
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h b/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
index cb38b0be1808a..bb83ef7dec883 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h
@@ -633,9 +633,6 @@ struct FixedScalableVFPair {
 
   /// \return true if either fixed- or scalable VF is non-zero.
   explicit operator bool() const { return FixedVF || ScalableVF; }
-
-  /// \return true if either fixed- or scalable VF is a valid vector VF.
-  bool hasVector() const { return FixedVF.isVector() || ScalableVF.isVector(); }
 };
 
 /// Holds state needed to make cost decisions before computing costs per-VF,
@@ -700,12 +697,6 @@ class VFSelectionContext {
   /// collectInLoopReductions.
   SmallPtrSet<PHINode *, 4> InLoopReductions;
 
-  /// A Map of inloop reduction operations and their immediate chain operand.
-  /// FIXME: This can be removed once reductions can be costed correctly in
-  /// VPlan. This was added to allow quick lookup of the inloop operations.
-  /// Set by collectInLoopReductions.
-  DenseMap<Instruction *, Instruction *> InLoopReductionImmediateChains;
-
   /// Maximum safe number of elements to be processed per vector iteration,
   /// which do not prevent store-load forwarding and are safe with regard to the
   /// memory dependencies. Required for EVL-based vectorization, where this
@@ -811,8 +802,6 @@ class VFSelectionContext {
 
   /// Split reductions into those that happen in the loop, and those that
   /// happen outside. In-loop reductions are collected into InLoopReductions.
-  /// InLoopReductionImmediateChains is filled with each in-loop reduction
-  /// operation and its immediate chain operand for use during cost modelling.
   void collectInLoopReductions();
 
   /// Returns true if the Phi is part of an inloop reduction.
@@ -825,12 +814,6 @@ class VFSelectionContext {
     return InLoopReductions;
   }
 
-  /// Returns the immediate chain operand of in-loop reduction operation \p I,
-  /// or nullptr if \p I is not an in-loop reduction operation.
-  Instruction *getInLoopReductionImmediateChain(Instruction *I) const {
-    return InLoopReductionImmediateChains.lookup(I);
-  }
-
   /// Check whether vectorization would require runtime checks. When optimizing
   /// for size, returning true here aborts vectorization.
   bool runtimeChecksRequired();
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index d929af8afbd1d..2f1fc4398654a 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -1114,12 +1114,6 @@ class LoopVectorizationCostModel {
     return EpilogueLoweringStatus == CM_EpilogueAllowed;
   }
 
-  /// Returns true if tail-folding is preferred over an epilogue.
-  bool preferTailFoldedLoop() const {
-    return EpilogueLoweringStatus == CM_EpilogueNotNeededFoldTail ||
-           EpilogueLoweringStatus == CM_EpilogueNotAllowedFoldTail;
-  }
-
   /// Returns the TailFoldingStyle that is best for the current loop.
   TailFoldingStyle getTailFoldingStyle() const {
     return ChosenTailFoldingStyle;



More information about the llvm-commits mailing list