[llvm-commits] [llvm] r133797 - /llvm/trunk/lib/CodeGen/TailDuplication.cpp
Rafael Espindola
rafael.espindola at gmail.com
Fri Jun 24 08:47:41 PDT 2011
Author: rafael
Date: Fri Jun 24 10:47:41 2011
New Revision: 133797
URL: http://llvm.org/viewvc/llvm-project?rev=133797&view=rev
Log:
Now that bb with phis are not considered simple, duplicate them even if
we cannot duplicate to every predecessor.
Modified:
llvm/trunk/lib/CodeGen/TailDuplication.cpp
Modified: llvm/trunk/lib/CodeGen/TailDuplication.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TailDuplication.cpp?rev=133797&r1=133796&r2=133797&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TailDuplication.cpp (original)
+++ llvm/trunk/lib/CodeGen/TailDuplication.cpp Fri Jun 24 10:47:41 2011
@@ -98,7 +98,7 @@
bool IsSimple, MachineBasicBlock &TailBB);
bool isSimpleBB(MachineBasicBlock *TailBB);
bool canCompletelyDuplicateBB(MachineBasicBlock &BB, bool IsSimple);
- void duplicateSimpleBB(MachineBasicBlock *TailBB,
+ bool duplicateSimpleBB(MachineBasicBlock *TailBB,
SmallVector<MachineBasicBlock*, 8> &TDBBs,
const DenseSet<unsigned> &RegsUsedByPhi,
SmallVector<MachineInstr*, 16> &Copies);
@@ -568,7 +568,7 @@
return true;
if (IsSimple)
- return canCompletelyDuplicateBB(TailBB, IsSimple);
+ return true;
if (!PreRegAlloc)
return true;
@@ -635,24 +635,32 @@
return true;
}
-void
+bool
TailDuplicatePass::duplicateSimpleBB(MachineBasicBlock *TailBB,
SmallVector<MachineBasicBlock*, 8> &TDBBs,
const DenseSet<unsigned> &UsedByPhi,
SmallVector<MachineInstr*, 16> &Copies) {
+ SmallPtrSet<MachineBasicBlock*, 8> Succs(TailBB->succ_begin(),
+ TailBB->succ_end());
SmallVector<MachineBasicBlock*, 8> Preds(TailBB->pred_begin(),
TailBB->pred_end());
+ bool Changed = false;
for (SmallSetVector<MachineBasicBlock *, 8>::iterator PI = Preds.begin(),
PE = Preds.end(); PI != PE; ++PI) {
MachineBasicBlock *PredBB = *PI;
+ if (PredBB->getLandingPadSuccessor())
+ continue;
+
+ if (bothUsedInPHI(*PredBB, Succs))
+ continue;
+
MachineBasicBlock *PredTBB = NULL, *PredFBB = NULL;
SmallVector<MachineOperand, 4> PredCond;
- bool NotAnalyzable =
- TII->AnalyzeBranch(*PredBB, PredTBB, PredFBB, PredCond, true);
- (void)NotAnalyzable;
- assert(!NotAnalyzable && "Cannot duplicate this!");
+ if (TII->AnalyzeBranch(*PredBB, PredTBB, PredFBB, PredCond, true))
+ continue;
+ Changed = true;
DEBUG(dbgs() << "\nTail-duplicating into PredBB: " << *PredBB
<< "From simple Succ: " << *TailBB);
@@ -700,6 +708,7 @@
TDBBs.push_back(PredBB);
}
+ return Changed;
}
/// TailDuplicate - If it is profitable, duplicate TailBB's contents in each
@@ -718,11 +727,8 @@
DenseSet<unsigned> UsedByPhi;
getRegsUsedByPHIs(*TailBB, &UsedByPhi);
- if (IsSimple) {
- duplicateSimpleBB(TailBB, TDBBs, UsedByPhi, Copies);
- return true;
- }
-
+ if (IsSimple)
+ return duplicateSimpleBB(TailBB, TDBBs, UsedByPhi, Copies);
// Iterate through all the unique predecessors and tail-duplicate this
// block into them, if possible. Copying the list ahead of time also
More information about the llvm-commits
mailing list