diff options
author | Chris Lattner <sabre@nondot.org> | 2010-03-03 06:28:15 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-03-03 06:28:15 +0000 |
commit | cfe2eab7446dedc471592fe702fefef783383171 (patch) | |
tree | e9456a5376a26b03b053df780da66c7a3905f63f /lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | |
parent | 30174be37a97b8fbc395e92b5895fb8a89cc8c4e (diff) |
introduce a new SwitchTypeMatcher node (which is analogous to
SwitchOpcodeMatcher) and have DAGISelMatcherOpt form it. This
speeds up selection, particularly for X86 which has lots of
variants of instructions with only type differences.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97645 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 8e88f16d69..bdf4cb6bc5 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -2065,9 +2065,7 @@ SelectCodeCommon(SDNode *NodeToMatch, const unsigned char *MatcherTable, case OPC_SwitchOpcode: { unsigned CurNodeOpcode = N.getOpcode(); - unsigned SwitchStart = MatcherIndex-1; (void)SwitchStart; - unsigned CaseSize; while (1) { // Get the size of this case. @@ -2084,7 +2082,7 @@ SelectCodeCommon(SDNode *NodeToMatch, const unsigned char *MatcherTable, MatcherIndex += CaseSize; } - // If we failed to match, bail out. + // If no cases matched, bail out. if (CaseSize == 0) break; // Otherwise, execute the case we found. @@ -2103,6 +2101,39 @@ SelectCodeCommon(SDNode *NodeToMatch, const unsigned char *MatcherTable, } continue; } + + case OPC_SwitchType: { + MVT::SimpleValueType CurNodeVT = N.getValueType().getSimpleVT().SimpleTy; + unsigned SwitchStart = MatcherIndex-1; (void)SwitchStart; + unsigned CaseSize; + while (1) { + // Get the size of this case. + CaseSize = MatcherTable[MatcherIndex++]; + if (CaseSize & 128) + CaseSize = GetVBR(CaseSize, MatcherTable, MatcherIndex); + if (CaseSize == 0) break; + + MVT::SimpleValueType CaseVT = + (MVT::SimpleValueType)MatcherTable[MatcherIndex++]; + if (CaseVT == MVT::iPTR) + CaseVT = TLI.getPointerTy().SimpleTy; + + // If the VT matches, then we will execute this case. + if (CurNodeVT == CaseVT) + break; + + // Otherwise, skip over this case. + MatcherIndex += CaseSize; + } + + // If no cases matched, bail out. + if (CaseSize == 0) break; + + // Otherwise, execute the case we found. + DEBUG(errs() << " TypeSwitch[" << EVT(CurNodeVT).getEVTString() + << "] from " << SwitchStart << " to " << MatcherIndex<<'\n'); + continue; + } case OPC_CheckChild0Type: case OPC_CheckChild1Type: case OPC_CheckChild2Type: case OPC_CheckChild3Type: case OPC_CheckChild4Type: case OPC_CheckChild5Type: |