diff options
author | Hans Wennborg <hans@hanshq.net> | 2015-03-20 00:41:03 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2015-03-20 00:41:03 +0000 |
commit | 077845eb819e68d022d61bcaf11ae437c9d940d2 (patch) | |
tree | 8ff1b0574da9b9b05d52071f9b9d878c8d255efc /llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h | |
parent | 7ffc3fbb2f448e5c23da7ebe2af71fe29f92fa04 (diff) | |
download | bcm5719-llvm-077845eb819e68d022d61bcaf11ae437c9d940d2.tar.gz bcm5719-llvm-077845eb819e68d022d61bcaf11ae437c9d940d2.zip |
Rewrite SelectionDAGBuilder::Clusterify to run in linear time. NFC.
It was previously repeatedly erasing elements from the middle of a vector,
causing O(n^2) worst-case run-time.
llvm-svn: 232789
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h index 109d83d8a74..30240d8d864 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h @@ -190,21 +190,15 @@ private: typedef std::vector<CaseRec> CaseRecVector; - /// The comparison function for sorting the switch case values in the vector. - /// WARNING: Case ranges should be disjoint! - struct CaseCmp { - bool operator()(const Case &C1, const Case &C2) { - return C1.Low->getValue().slt(C2.High->getValue()); - } - }; - struct CaseBitsCmp { bool operator()(const CaseBits &C1, const CaseBits &C2) { return C1.Bits > C2.Bits; } }; - void Clusterify(CaseVector &Cases, const SwitchInst &SI); + /// Populate Cases with the cases in SI, clustering adjacent cases with the + /// same destination together. + void Clusterify(CaseVector &Cases, const SwitchInst *SI); /// CaseBlock - This structure is used to communicate between /// SelectionDAGBuilder and SDISel for the code generation of additional basic |