[llvm-commits] CVS: llvm/lib/CodeGen/PHIElimination.cpp
Chris Lattner
lattner at cs.uiuc.edu
Mon May 10 13:47:03 PDT 2004
Changes in directory llvm/lib/CodeGen:
PHIElimination.cpp updated: 1.22 -> 1.23
---
Log message:
Now that we use an ilist of machine instructions, iterators are more robust
than before. Because this is the case, we can compute the first non-phi
instruction once when de-phi'ing a block. This shaves ~4s off of
phielimination of _Z7yyparsev in kimwitu++ from 109s -> 105s. There are
still much more important gains to come.
---
Diffs of the changes: (+8 -5)
Index: llvm/lib/CodeGen/PHIElimination.cpp
diff -u llvm/lib/CodeGen/PHIElimination.cpp:1.22 llvm/lib/CodeGen/PHIElimination.cpp:1.23
--- llvm/lib/CodeGen/PHIElimination.cpp:1.22 Sat May 1 16:24:39 2004
+++ llvm/lib/CodeGen/PHIElimination.cpp Mon May 10 13:47:18 2004
@@ -68,6 +68,13 @@
const TargetInstrInfo &MII = MF.getTarget().getInstrInfo();
const MRegisterInfo *RegInfo = MF.getTarget().getRegisterInfo();
+ // Get an iterator to the first instruction after the last PHI node (this may
+ // allso be the end of the basic block).
+ MachineBasicBlock::iterator AfterPHIsIt = MBB.begin();
+ while (AfterPHIsIt != MBB.end() &&
+ AfterPHIsIt->getOpcode() == TargetInstrInfo::PHI)
+ ++AfterPHIsIt; // Skip over all of the PHI nodes...
+
while (MBB.front().getOpcode() == TargetInstrInfo::PHI) {
// Unlink the PHI node from the basic block... but don't delete the PHI yet
MachineInstr *MI = MBB.remove(MBB.begin());
@@ -85,15 +92,11 @@
// after any remaining phi nodes) which copies the new incoming register
// into the phi node destination.
//
- MachineBasicBlock::iterator AfterPHIsIt = MBB.begin();
- while (AfterPHIsIt != MBB.end() &&
- AfterPHIsIt->getOpcode() == TargetInstrInfo::PHI)
- ++AfterPHIsIt; // Skip over all of the PHI nodes...
RegInfo->copyRegToReg(MBB, AfterPHIsIt, DestReg, IncomingReg, RC);
// Update live variable information if there is any...
if (LV) {
- MachineInstr *PHICopy = --AfterPHIsIt;
+ MachineInstr *PHICopy = prior(AfterPHIsIt);
// Add information to LiveVariables to know that the incoming value is
// killed. Note that because the value is defined in several places (once
More information about the llvm-commits
mailing list