Index: include/llvm/ADT/DenseMapInfo.h =================================================================== --- include/llvm/ADT/DenseMapInfo.h +++ include/llvm/ADT/DenseMapInfo.h @@ -17,6 +17,7 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Hashing.h" #include "llvm/ADT/StringRef.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/Support/PointerLikeTypeTraits.h" #include #include @@ -269,6 +270,24 @@ static bool isEqual(hash_code LHS, hash_code RHS) { return LHS == RHS; } }; +template struct DenseMapInfo> { + 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.begin(), V.end())); + } + + static bool isEqual(const SmallVector &LHS, + const SmallVector &RHS) { + return LHS == RHS; + } + }; } // end namespace llvm #endif // LLVM_ADT_DENSEMAPINFO_H Index: lib/Transforms/Scalar/LoopStrengthReduce.cpp =================================================================== --- lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -1089,38 +1089,13 @@ 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.begin(), V.end())); - } - - 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 @@ -4193,7 +4168,7 @@ // Collect the best formula for each unique set of shared registers. This // is reset for each use. using BestFormulaeTy = - DenseMap, size_t, UniquifierDenseMapInfo>; + DenseMap, size_t>; BestFormulaeTy BestFormulae;