aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorStepan Dyatkovskiy <stpworld@narod.ru>2012-06-22 14:53:30 +0000
committerStepan Dyatkovskiy <stpworld@narod.ru>2012-06-22 14:53:30 +0000
commit43c3a4a7e76920c5646e473b72620acc7eb4ca5a (patch)
tree3ca0fdb5a975b0ac166e14958abe62877d4a4f1c /lib/VMCore
parent84f64f317f5211dd8b8446e9933778350b254163 (diff)
downloadexternal_llvm-43c3a4a7e76920c5646e473b72620acc7eb4ca5a.zip
external_llvm-43c3a4a7e76920c5646e473b72620acc7eb4ca5a.tar.gz
external_llvm-43c3a4a7e76920c5646e473b72620acc7eb4ca5a.tar.bz2
Fixed r158979.
Original message: Performance optimizations: - SwitchInst: case values stored separately from Operands List. It allows to make faster access to individual case value numbers or ranges. - Optimized IntItem, added APInt value caching. - Optimized IntegersSubsetGeneric: added optimizations for cases when subset is single number or when subset consists from single numbers only. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158997 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/Instructions.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp
index 26cc632..3839945 100644
--- a/lib/VMCore/Instructions.cpp
+++ b/lib/VMCore/Instructions.cpp
@@ -3158,6 +3158,7 @@ SwitchInst::SwitchInst(const SwitchInst &SI)
OL[i] = InOL[i];
OL[i+1] = InOL[i+1];
}
+ TheSubsets = SI.TheSubsets;
SubclassOptionalData = SI.SubclassOptionalData;
}
@@ -3186,14 +3187,17 @@ void SwitchInst::addCase(IntegersSubset& OnVal, BasicBlock *Dest) {
// Initialize some new operands.
assert(OpNo+1 < ReservedSpace && "Growing didn't work!");
NumOperands = OpNo+2;
- CaseIt Case(this, NewCaseIdx);
- Case.setValueEx(OnVal);
+
+ SubsetsIt TheSubsetsIt = TheSubsets.insert(TheSubsets.end(), OnVal);
+
+ CaseIt Case(this, NewCaseIdx, TheSubsetsIt);
+ Case.updateCaseValueOperand(OnVal);
Case.setSuccessor(Dest);
}
/// removeCase - This method removes the specified case and its successor
/// from the switch instruction.
-void SwitchInst::removeCase(CaseIt i) {
+void SwitchInst::removeCase(CaseIt& i) {
unsigned idx = i.getCaseIndex();
assert(2 + idx*2 < getNumOperands() && "Case index out of range!!!");
@@ -3210,6 +3214,16 @@ void SwitchInst::removeCase(CaseIt i) {
// Nuke the last value.
OL[NumOps-2].set(0);
OL[NumOps-2+1].set(0);
+
+ // Do the same with TheCases collection:
+ if (i.SubsetIt != --TheSubsets.end()) {
+ *i.SubsetIt = TheSubsets.back();
+ TheSubsets.pop_back();
+ } else {
+ TheSubsets.pop_back();
+ i.SubsetIt = TheSubsets.end();
+ }
+
NumOperands = NumOps-2;
}