summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorJay Foad <jay.foad@gmail.com>2011-02-01 09:22:34 +0000
committerJay Foad <jay.foad@gmail.com>2011-02-01 09:22:34 +0000
commit142777224c1f97f6361be824d2ddbd10afa7d434 (patch)
tree0f4921ff4b55ce7f13360392b98ce53d04bd8e71 /llvm/lib
parent69c6bc7a9fdbaf73100766446f5d815314e6bb14 (diff)
downloadbcm5719-llvm-142777224c1f97f6361be824d2ddbd10afa7d434.tar.gz
bcm5719-llvm-142777224c1f97f6361be824d2ddbd10afa7d434.zip
Make SwitchInst::removeCase() more efficient.
llvm-svn: 124659
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/VMCore/Instructions.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp
index db38a1568fc..6b561f34af2 100644
--- a/llvm/lib/VMCore/Instructions.cpp
+++ b/llvm/lib/VMCore/Instructions.cpp
@@ -3009,14 +3009,10 @@ void SwitchInst::removeCase(unsigned idx) {
unsigned NumOps = getNumOperands();
Use *OL = OperandList;
- // Move everything after this operand down.
- //
- // FIXME: we could just swap with the end of the list, then erase. However,
- // client might not expect this to happen. The code as it is thrashes the
- // use/def lists, which is kinda lame.
- for (unsigned i = (idx+1)*2; i != NumOps; i += 2) {
- OL[i-2] = OL[i];
- OL[i-2+1] = OL[i+1];
+ // Overwrite this case with the end of the list.
+ if ((idx + 1) * 2 != NumOps) {
+ OL[idx * 2] = OL[NumOps - 2];
+ OL[idx * 2 + 1] = OL[NumOps - 1];
}
// Nuke the last value.
OpenPOWER on IntegriCloud