Skip to content

Commit 4703195

Browse files
authored
[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.
1 parent 139f726 commit 4703195

File tree

2 files changed

+10
-20
lines changed

2 files changed

+10
-20
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,6 @@ static std::optional<unsigned> getExtractIndex(const Instruction *E) {
886886
return *EI->idx_begin();
887887
}
888888

889-
namespace llvm {
890889
/// Checks if the provided value does not require scheduling. It does not
891890
/// require scheduling if this is not an instruction or it is an instruction
892891
/// that does not read/write memory and all operands are either not instructions
@@ -901,18 +900,18 @@ static bool isUsedOutsideBlock(Value *V);
901900
/// require scheduling if all operands and all users do not need to be scheduled
902901
/// in the current basic block.
903902
static bool doesNotNeedToBeScheduled(Value *V);
904-
} // namespace llvm
905903

906-
namespace {
907904
/// \returns true if \p Opcode is allowed as part of the main/alternate
908905
/// instruction for SLP vectorization.
909906
///
910907
/// Example of unsupported opcode is SDIV that can potentially cause UB if the
911908
/// "shuffled out" lane would result in division by zero.
912-
bool isValidForAlternation(unsigned Opcode) {
909+
static bool isValidForAlternation(unsigned Opcode) {
913910
return !Instruction::isIntDivRem(Opcode);
914911
}
915912

913+
namespace {
914+
916915
/// Helper class that determines VL can use the same opcode.
917916
/// Alternate instruction is supported. In addition, it supports interchangeable
918917
/// instruction. An interchangeable instruction is an instruction that can be
@@ -1816,8 +1815,6 @@ static SmallVector<Constant *> replicateMask(ArrayRef<Constant *> Val,
18161815
return NewVal;
18171816
}
18181817

1819-
namespace llvm {
1820-
18211818
static void inversePermutation(ArrayRef<unsigned> Indices,
18221819
SmallVectorImpl<int> &Mask) {
18231820
Mask.clear();
@@ -1922,10 +1919,8 @@ getNumberOfParts(const TargetTransformInfo &TTI, VectorType *VecTy,
19221919
return NumParts;
19231920
}
19241921

1925-
namespace slpvectorizer {
1926-
19271922
/// Bottom Up SLP Vectorizer.
1928-
class BoUpSLP {
1923+
class slpvectorizer::BoUpSLP {
19291924
class TreeEntry;
19301925
class ScheduleEntity;
19311926
class ScheduleData;
@@ -6084,9 +6079,7 @@ class BoUpSLP {
60846079
DenseSet<unsigned> ExtraBitWidthNodes;
60856080
};
60866081

6087-
} // end namespace slpvectorizer
6088-
6089-
template <> struct DenseMapInfo<BoUpSLP::EdgeInfo> {
6082+
template <> struct llvm::DenseMapInfo<BoUpSLP::EdgeInfo> {
60906083
using FirstInfo = DenseMapInfo<BoUpSLP::TreeEntry *>;
60916084
using SecondInfo = DenseMapInfo<unsigned>;
60926085
static BoUpSLP::EdgeInfo getEmptyKey() {
@@ -6110,7 +6103,7 @@ template <> struct DenseMapInfo<BoUpSLP::EdgeInfo> {
61106103
}
61116104
};
61126105

6113-
template <> struct GraphTraits<BoUpSLP *> {
6106+
template <> struct llvm::GraphTraits<BoUpSLP *> {
61146107
using TreeEntry = BoUpSLP::TreeEntry;
61156108

61166109
/// NodeRef has to be a pointer per the GraphWriter.
@@ -6171,7 +6164,8 @@ template <> struct GraphTraits<BoUpSLP *> {
61716164
static unsigned size(BoUpSLP *R) { return R->VectorizableTree.size(); }
61726165
};
61736166

6174-
template <> struct DOTGraphTraits<BoUpSLP *> : public DefaultDOTGraphTraits {
6167+
template <>
6168+
struct llvm::DOTGraphTraits<BoUpSLP *> : public DefaultDOTGraphTraits {
61756169
using TreeEntry = BoUpSLP::TreeEntry;
61766170

61776171
DOTGraphTraits(bool IsSimple = false) : DefaultDOTGraphTraits(IsSimple) {}
@@ -6205,8 +6199,6 @@ template <> struct DOTGraphTraits<BoUpSLP *> : public DefaultDOTGraphTraits {
62056199
}
62066200
};
62076201

6208-
} // end namespace llvm
6209-
62106202
BoUpSLP::~BoUpSLP() {
62116203
SmallVector<WeakTrackingVH> DeadInsts;
62126204
for (auto *I : DeletedInstructions) {

llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717

1818
#include "VPlan.h"
1919

20-
namespace llvm {
21-
namespace VPlanPatternMatch {
20+
namespace llvm::VPlanPatternMatch {
2221

2322
template <typename Val, typename Pattern> bool match(Val *V, const Pattern &P) {
2423
return P.match(V);
@@ -878,7 +877,6 @@ template <typename T> inline OneUse_match<T> m_OneUse(const T &SubPattern) {
878877
return SubPattern;
879878
}
880879

881-
} // namespace VPlanPatternMatch
882-
} // namespace llvm
880+
} // namespace llvm::VPlanPatternMatch
883881

884882
#endif

0 commit comments

Comments
 (0)