From 718071c476014cb0aaff9c7d018120d5a8930217 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 4 Feb 2007 00:50:02 +0000 Subject: [PATCH] switch LegalizedNodes from std::map to a DenseMap. This speeds up isel time as a whole on kc++ by 11%. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33857 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/LegalizeDAG.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp index e87dfa615c5..a411d108f28 100644 --- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp +++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp @@ -39,6 +39,18 @@ ViewLegalizeDAGs("view-legalize-dags", cl::Hidden, static const bool ViewLegalizeDAGs = 0; #endif +namespace llvm { +template<> +struct DenseMapKeyInfo { + static inline SDOperand getEmptyKey() { return SDOperand((SDNode*)-1, -1U); } + static inline SDOperand getTombstoneKey() { return SDOperand((SDNode*)-1, 0);} + static unsigned getHashValue(const SDOperand &Val) { + return DenseMapKeyInfo::getHashValue(Val.Val) + Val.ResNo; + } + static bool isPod() { return true; } +}; +} + //===----------------------------------------------------------------------===// /// SelectionDAGLegalize - This takes an arbitrary SelectionDAG as input and /// hacks on it until the target machine can handle it. This involves @@ -82,7 +94,7 @@ class VISIBILITY_HIDDEN SelectionDAGLegalize { /// LegalizedNodes - For nodes that are of legal width, and that have more /// than one use, this map indicates what regularized operand to use. This /// allows us to avoid legalizing the same thing more than once. - std::map LegalizedNodes; + DenseMap LegalizedNodes; /// PromotedNodes - For nodes that are below legal width, and that have more /// than one use, this map indicates what promoted value to use. This allows @@ -592,7 +604,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { // Note that LegalizeOp may be reentered even from single-use nodes, which // means that we always must cache transformed nodes. - std::map::iterator I = LegalizedNodes.find(Op); + DenseMap::iterator I = LegalizedNodes.find(Op); if (I != LegalizedNodes.end()) return I->second; SDOperand Tmp1, Tmp2, Tmp3, Tmp4; @@ -1169,7 +1181,7 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) { // will cause this node to be legalized as well as handling libcalls right. if (LastCALLSEQ_END.Val != Node) { LegalizeOp(SDOperand(FindCallStartFromCallEnd(Node), 0)); - std::map::iterator I = LegalizedNodes.find(Op); + DenseMap::iterator I = LegalizedNodes.find(Op); assert(I != LegalizedNodes.end() && "Legalizing the call start should have legalized this node!"); return I->second; -- 2.11.0