[llvm-commits] [llvm] r150214 - /llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
Benjamin Kramer
benny.kra at googlemail.com
Thu Feb 9 16:28:31 PST 2012
Author: d0k
Date: Thu Feb 9 18:28:31 2012
New Revision: 150214
URL: http://llvm.org/viewvc/llvm-project?rev=150214&view=rev
Log:
Cache iterators. Some of these are expensive to create.
Modified:
llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp?rev=150214&r1=150213&r2=150214&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Thu Feb 9 18:28:31 2012
@@ -141,8 +141,8 @@
}
MachineBasicBlock::iterator MachineBasicBlock::getFirstNonPHI() {
- instr_iterator I = instr_begin();
- while (I != end() && I->isPHI())
+ instr_iterator I = instr_begin(), E = instr_end();
+ while (I != E && I->isPHI())
++I;
assert(!I->isInsideBundle() && "First non-phi MI cannot be inside a bundle!");
return I;
@@ -150,7 +150,8 @@
MachineBasicBlock::iterator
MachineBasicBlock::SkipPHIsAndLabels(MachineBasicBlock::iterator I) {
- while (I != end() && (I->isPHI() || I->isLabel() || I->isDebugValue()))
+ iterator E = end();
+ while (I != E && (I->isPHI() || I->isLabel() || I->isDebugValue()))
++I;
// FIXME: This needs to change if we wish to bundle labels / dbg_values
// inside the bundle.
@@ -160,29 +161,29 @@
}
MachineBasicBlock::iterator MachineBasicBlock::getFirstTerminator() {
- iterator I = end();
- while (I != begin() && ((--I)->isTerminator() || I->isDebugValue()))
+ iterator B = begin(), E = end(), I = E;
+ while (I != B && ((--I)->isTerminator() || I->isDebugValue()))
; /*noop */
- while (I != end() && !I->isTerminator())
+ while (I != E && !I->isTerminator())
++I;
return I;
}
MachineBasicBlock::const_iterator
MachineBasicBlock::getFirstTerminator() const {
- const_iterator I = end();
- while (I != begin() && ((--I)->isTerminator() || I->isDebugValue()))
+ const_iterator B = begin(), E = end(), I = E;
+ while (I != B && ((--I)->isTerminator() || I->isDebugValue()))
; /*noop */
- while (I != end() && !I->isTerminator())
+ while (I != E && !I->isTerminator())
++I;
return I;
}
MachineBasicBlock::instr_iterator MachineBasicBlock::getFirstInstrTerminator() {
- instr_iterator I = instr_end();
- while (I != instr_begin() && ((--I)->isTerminator() || I->isDebugValue()))
+ instr_iterator B = instr_begin(), E = instr_end(), I = E;
+ while (I != B && ((--I)->isTerminator() || I->isDebugValue()))
; /*noop */
- while (I != instr_end() && !I->isTerminator())
+ while (I != E && !I->isTerminator())
++I;
return I;
}
@@ -726,8 +727,9 @@
MachineInstr *MachineBasicBlock::remove(MachineInstr *I) {
if (I->isBundle()) {
- MachineBasicBlock::instr_iterator MII = I; ++MII;
- while (MII != end() && MII->isInsideBundle()) {
+ instr_iterator MII = llvm::next(I);
+ iterator E = end();
+ while (MII != E && MII->isInsideBundle()) {
MachineInstr *MI = &*MII++;
Insts.remove(MI);
}
More information about the llvm-commits
mailing list