diff options
author | Jay Foad <jay.foad@gmail.com> | 2011-02-01 09:22:34 +0000 |
---|---|---|
committer | Jay Foad <jay.foad@gmail.com> | 2011-02-01 09:22:34 +0000 |
commit | 0faa60938a66a09820ca21d55e7b5926bc58d59d (patch) | |
tree | c4b5f8b562a2285ad657aeb7c7f104112242d46c /lib/VMCore/Instructions.cpp | |
parent | f9e4a986c03fe3af7dbc9de0b0a9251280fbdf41 (diff) |
Make SwitchInst::removeCase() more efficient.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124659 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Instructions.cpp')
-rw-r--r-- | lib/VMCore/Instructions.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index db38a1568f..6b561f34af 100644 --- a/lib/VMCore/Instructions.cpp +++ b/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. |