From 686c4a18f1e9f1decdb2d95a2d0f6bf925d55d93 Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Wed, 2 Aug 2006 09:18:33 +0000 Subject: [PATCH] Use of vector causes some horrendous compile time regression (2x)! Looks like libstdc++ implementation does not scale very well. Switch back to using directly managed arrays. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29469 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86ISelDAGToDAG.cpp | 39 ++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/lib/Target/X86/X86ISelDAGToDAG.cpp b/lib/Target/X86/X86ISelDAGToDAG.cpp index 6123e4c6293..3896797724e 100644 --- a/lib/Target/X86/X86ISelDAGToDAG.cpp +++ b/lib/Target/X86/X86ISelDAGToDAG.cpp @@ -99,7 +99,7 @@ namespace { : SelectionDAGISel(X86Lowering), X86Lowering(*TM.getTargetLowering()), Subtarget(&TM.getSubtarget()), - DAGSize(0) {} + DAGSize(0), ReachabilityMatrix(NULL), ReachMatrixRange(NULL) {} virtual bool runOnFunction(Function &Fn) { // Make sure we re-emit a set of the global base reg if necessary @@ -189,33 +189,35 @@ namespace { /// ReachabilityMatrix - A N x N matrix representing all pairs reachability /// information. One bit per potential edge. - std::vector ReachabilityMatrix; + unsigned char *ReachabilityMatrix; - /// RMRange - The range of reachability information available for the - /// particular source node. - std::vector ReachMatrixRange; + /// ReachMatrixRange - The range of reachability information available for + /// the particular source node. + unsigned *ReachMatrixRange; inline void setReachable(SDNode *f, SDNode *t) { unsigned Idx = f->getNodeId() * DAGSize + t->getNodeId(); - ReachabilityMatrix[Idx] = true; + ReachabilityMatrix[Idx / 8] |= 1 << (Idx % 8); } inline bool isReachable(SDNode *f, SDNode *t) { unsigned Idx = f->getNodeId() * DAGSize + t->getNodeId(); - return ReachabilityMatrix[Idx]; + return ReachabilityMatrix[Idx / 8] & (1 << (Idx % 8)); } /// UnfoldableSet - An boolean array representing nodes which have been /// folded into addressing modes and therefore should not be folded in /// another operation. - std::vector UnfoldableSet; + unsigned char *UnfoldableSet; inline void setUnfoldable(SDNode *N) { - UnfoldableSet[N->getNodeId()] = true; + unsigned Id = N->getNodeId(); + UnfoldableSet[Id / 8] |= 1 << (Id % 8); } inline bool isUnfoldable(SDNode *N) { - return UnfoldableSet[N->getNodeId()]; + unsigned Id = N->getNodeId(); + return UnfoldableSet[Id / 8] & (1 << (Id % 8)); } #ifndef NDEBUG @@ -291,9 +293,14 @@ void X86DAGToDAGISel::InstructionSelectBasicBlock(SelectionDAG &DAG) { TopOrder = DAG.AssignTopologicalOrder(); DAGSize = TopOrder.size(); - ReachabilityMatrix.assign(DAGSize*DAGSize, false); - ReachMatrixRange.assign(DAGSize, 0); - UnfoldableSet.assign(DAGSize, false); + unsigned RMSize = (DAGSize * DAGSize + 7) / 8; + ReachabilityMatrix = new unsigned char[RMSize]; + memset(ReachabilityMatrix, 0, RMSize); + ReachMatrixRange = new unsigned[DAGSize]; + memset(ReachMatrixRange, 0, DAGSize * sizeof(unsigned)); + unsigned NumBytes = (DAGSize + 7) / 8; + UnfoldableSet = new unsigned char[NumBytes]; + memset(UnfoldableSet, 0, NumBytes); // Codegen the basic block. #ifndef NDEBUG @@ -305,6 +312,12 @@ void X86DAGToDAGISel::InstructionSelectBasicBlock(SelectionDAG &DAG) { DEBUG(std::cerr << "===== Instruction selection ends:\n"); #endif + delete[] ReachabilityMatrix; + delete[] ReachMatrixRange; + delete[] UnfoldableSet; + ReachabilityMatrix = NULL; + ReachMatrixRange = NULL; + UnfoldableSet = NULL; CodeGenMap.clear(); HandleMap.clear(); ReplaceMap.clear();