diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index deb8ee2d88055..cad11b4ff96a4 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -886,7 +886,6 @@ static std::optional 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 replicateMask(ArrayRef Val, return NewVal; } -namespace llvm { - static void inversePermutation(ArrayRef Indices, SmallVectorImpl &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 ExtraBitWidthNodes; }; -} // end namespace slpvectorizer - -template <> struct DenseMapInfo { +template <> struct llvm::DenseMapInfo { using FirstInfo = DenseMapInfo; using SecondInfo = DenseMapInfo; static BoUpSLP::EdgeInfo getEmptyKey() { @@ -6110,7 +6103,7 @@ template <> struct DenseMapInfo { } }; -template <> struct GraphTraits { +template <> struct llvm::GraphTraits { using TreeEntry = BoUpSLP::TreeEntry; /// NodeRef has to be a pointer per the GraphWriter. @@ -6171,7 +6164,8 @@ template <> struct GraphTraits { static unsigned size(BoUpSLP *R) { return R->VectorizableTree.size(); } }; -template <> struct DOTGraphTraits : public DefaultDOTGraphTraits { +template <> +struct llvm::DOTGraphTraits : public DefaultDOTGraphTraits { using TreeEntry = BoUpSLP::TreeEntry; DOTGraphTraits(bool IsSimple = false) : DefaultDOTGraphTraits(IsSimple) {} @@ -6205,8 +6199,6 @@ template <> struct DOTGraphTraits : public DefaultDOTGraphTraits { } }; -} // end namespace llvm - BoUpSLP::~BoUpSLP() { SmallVector 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 bool match(Val *V, const Pattern &P) { return P.match(V); @@ -878,7 +877,6 @@ template inline OneUse_match m_OneUse(const T &SubPattern) { return SubPattern; } -} // namespace VPlanPatternMatch -} // namespace llvm +} // namespace llvm::VPlanPatternMatch #endif