[llvm] 4703195 - [NFC][LLVM] Namespace cleanup in SLPVectorizer (#168623)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 19 07:34:13 PST 2025
Author: Rahul Joshi
Date: 2025-11-19T07:34:09-08:00
New Revision: 4703195c8de047f102214495e39ae80aad152e15
URL: https://github.com/llvm/llvm-project/commit/4703195c8de047f102214495e39ae80aad152e15
DIFF: https://github.com/llvm/llvm-project/commit/4703195c8de047f102214495e39ae80aad152e15.diff
LOG: [NFC][LLVM] Namespace cleanup in SLPVectorizer (#168623)
- Remove file local functions out of `llvm` or anonymous namespace and
make them static.
- Use namespace qualifier to define `BoUpSLP` class and several template
specializations.
Added:
Modified:
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index e33ff724ccdd5..b1598e8ccf5c6 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -886,7 +886,6 @@ static std::optional<unsigned> getExtractIndex(const Instruction *E) {
return *EI->idx_begin();
}
-namespace llvm {
/// Checks if the provided value does not require scheduling. It does not
/// require scheduling if this is not an instruction or it is an instruction
/// that does not read/write memory and all operands are either not instructions
@@ -901,18 +900,18 @@ static bool isUsedOutsideBlock(Value *V);
/// require scheduling if all operands and all users do not need to be scheduled
/// in the current basic block.
static bool doesNotNeedToBeScheduled(Value *V);
-} // namespace llvm
-namespace {
/// \returns true if \p Opcode is allowed as part of the main/alternate
/// instruction for SLP vectorization.
///
/// Example of unsupported opcode is SDIV that can potentially cause UB if the
/// "shuffled out" lane would result in division by zero.
-bool isValidForAlternation(unsigned Opcode) {
+static bool isValidForAlternation(unsigned Opcode) {
return !Instruction::isIntDivRem(Opcode);
}
+namespace {
+
/// Helper class that determines VL can use the same opcode.
/// Alternate instruction is supported. In addition, it supports interchangeable
/// instruction. An interchangeable instruction is an instruction that can be
@@ -1816,8 +1815,6 @@ static SmallVector<Constant *> replicateMask(ArrayRef<Constant *> Val,
return NewVal;
}
-namespace llvm {
-
static void inversePermutation(ArrayRef<unsigned> Indices,
SmallVectorImpl<int> &Mask) {
Mask.clear();
@@ -1922,10 +1919,8 @@ getNumberOfParts(const TargetTransformInfo &TTI, VectorType *VecTy,
return NumParts;
}
-namespace slpvectorizer {
-
/// Bottom Up SLP Vectorizer.
-class BoUpSLP {
+class slpvectorizer::BoUpSLP {
class TreeEntry;
class ScheduleEntity;
class ScheduleData;
@@ -6084,9 +6079,7 @@ class BoUpSLP {
DenseSet<unsigned> ExtraBitWidthNodes;
};
-} // end namespace slpvectorizer
-
-template <> struct DenseMapInfo<BoUpSLP::EdgeInfo> {
+template <> struct llvm::DenseMapInfo<BoUpSLP::EdgeInfo> {
using FirstInfo = DenseMapInfo<BoUpSLP::TreeEntry *>;
using SecondInfo = DenseMapInfo<unsigned>;
static BoUpSLP::EdgeInfo getEmptyKey() {
@@ -6110,7 +6103,7 @@ template <> struct DenseMapInfo<BoUpSLP::EdgeInfo> {
}
};
-template <> struct GraphTraits<BoUpSLP *> {
+template <> struct llvm::GraphTraits<BoUpSLP *> {
using TreeEntry = BoUpSLP::TreeEntry;
/// NodeRef has to be a pointer per the GraphWriter.
@@ -6171,7 +6164,8 @@ template <> struct GraphTraits<BoUpSLP *> {
static unsigned size(BoUpSLP *R) { return R->VectorizableTree.size(); }
};
-template <> struct DOTGraphTraits<BoUpSLP *> : public DefaultDOTGraphTraits {
+template <>
+struct llvm::DOTGraphTraits<BoUpSLP *> : public DefaultDOTGraphTraits {
using TreeEntry = BoUpSLP::TreeEntry;
DOTGraphTraits(bool IsSimple = false) : DefaultDOTGraphTraits(IsSimple) {}
@@ -6205,8 +6199,6 @@ template <> struct DOTGraphTraits<BoUpSLP *> : public DefaultDOTGraphTraits {
}
};
-} // end namespace llvm
-
BoUpSLP::~BoUpSLP() {
SmallVector<WeakTrackingVH> DeadInsts;
for (auto *I : DeletedInstructions) {
diff --git a/llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h b/llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h
index 447e2d70d941f..5d65d9bf34bcc 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h
+++ b/llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h
@@ -17,8 +17,7 @@
#include "VPlan.h"
-namespace llvm {
-namespace VPlanPatternMatch {
+namespace llvm::VPlanPatternMatch {
template <typename Val, typename Pattern> bool match(Val *V, const Pattern &P) {
return P.match(V);
@@ -878,7 +877,6 @@ template <typename T> inline OneUse_match<T> m_OneUse(const T &SubPattern) {
return SubPattern;
}
-} // namespace VPlanPatternMatch
-} // namespace llvm
+} // namespace llvm::VPlanPatternMatch
#endif
More information about the llvm-commits
mailing list