diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h index bd3e887e36bce..fb9ec9abf111b 100644 --- a/llvm/include/llvm/ADT/SmallVector.h +++ b/llvm/include/llvm/ADT/SmallVector.h @@ -14,6 +14,7 @@ #ifndef LLVM_ADT_SMALLVECTOR_H #define LLVM_ADT_SMALLVECTOR_H +#include "llvm/ADT/DenseMapInfo.h" #include "llvm/Support/Compiler.h" #include #include @@ -1319,6 +1320,26 @@ extern template class llvm::SmallVectorBase; extern template class llvm::SmallVectorBase; #endif +// Provide DenseMapInfo for SmallVector of a type which has info. +template struct DenseMapInfo> { + static SmallVector getEmptyKey() { + return {DenseMapInfo::getEmptyKey()}; + } + + static SmallVector getTombstoneKey() { + return {DenseMapInfo::getTombstoneKey()}; + } + + static unsigned getHashValue(const SmallVector &V) { + return static_cast(hash_combine_range(V)); + } + + static bool isEqual(const SmallVector &LHS, + const SmallVector &RHS) { + return LHS == RHS; + } +}; + } // end namespace llvm namespace std { diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 464e6e3b2ab97..33d6c77f61cfd 100644 --- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -1275,38 +1275,13 @@ struct LSRFixup { void dump() const; }; -/// A DenseMapInfo implementation for holding DenseMaps and DenseSets of sorted -/// SmallVectors of const SCEV*. -struct UniquifierDenseMapInfo { - static SmallVector getEmptyKey() { - SmallVector V; - V.push_back(reinterpret_cast(-1)); - return V; - } - - static SmallVector getTombstoneKey() { - SmallVector V; - V.push_back(reinterpret_cast(-2)); - return V; - } - - static unsigned getHashValue(const SmallVector &V) { - return static_cast(hash_combine_range(V)); - } - - static bool isEqual(const SmallVector &LHS, - const SmallVector &RHS) { - return LHS == RHS; - } -}; - /// This class holds the state that LSR keeps for each use in IVUsers, as well /// as uses invented by LSR itself. It includes information about what kinds of /// things can be folded into the user, information about the user itself, and /// information about how the use may be satisfied. TODO: Represent multiple /// users of the same expression in common? class LSRUse { - DenseSet, UniquifierDenseMapInfo> Uniquifier; + DenseSet> Uniquifier; public: /// An enum for a kind of use, indicating what types of scaled and immediate @@ -4754,8 +4729,7 @@ void LSRInstance::FilterOutUndesirableDedicatedRegisters() { // Collect the best formula for each unique set of shared registers. This // is reset for each use. - using BestFormulaeTy = - DenseMap, size_t, UniquifierDenseMapInfo>; + using BestFormulaeTy = DenseMap, size_t>; BestFormulaeTy BestFormulae; diff --git a/llvm/lib/Transforms/Vectorize/VPlanSLP.h b/llvm/lib/Transforms/Vectorize/VPlanSLP.h index 2b927b93e24cf..157e78363e55f 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanSLP.h +++ b/llvm/lib/Transforms/Vectorize/VPlanSLP.h @@ -73,30 +73,8 @@ class VPInterleavedAccessInfo { class VPlanSlp { enum class OpMode { Failed, Load, Opcode }; - /// A DenseMapInfo implementation for using SmallVector as - /// DenseMap keys. - struct BundleDenseMapInfo { - static SmallVector getEmptyKey() { - return {reinterpret_cast(-1)}; - } - - static SmallVector getTombstoneKey() { - return {reinterpret_cast(-2)}; - } - - static unsigned getHashValue(const SmallVector &V) { - return static_cast(hash_combine_range(V)); - } - - static bool isEqual(const SmallVector &LHS, - const SmallVector &RHS) { - return LHS == RHS; - } - }; - /// Mapping of values in the original VPlan to a combined VPInstruction. - DenseMap, VPInstruction *, BundleDenseMapInfo> - BundleToCombined; + DenseMap, VPInstruction *> BundleToCombined; VPInterleavedAccessInfo &IAI;