mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
LoopSimplify::FindPHIToPartitionLoops()
Use ETForest instead of DominatorSet. llvm-svn: 35221
This commit is contained in:
parent
632ac0e289
commit
18146cf2a2
@ -66,6 +66,7 @@ namespace {
|
||||
AU.addRequired<LoopInfo>();
|
||||
AU.addRequired<DominatorSet>();
|
||||
AU.addRequired<DominatorTree>();
|
||||
AU.addRequired<ETForest>();
|
||||
|
||||
AU.addPreserved<LoopInfo>();
|
||||
AU.addPreserved<DominatorSet>();
|
||||
@ -417,13 +418,13 @@ static void AddBlockAndPredsToSet(BasicBlock *BB, BasicBlock *StopBlock,
|
||||
|
||||
/// FindPHIToPartitionLoops - The first part of loop-nestification is to find a
|
||||
/// PHI node that tells us how to partition the loops.
|
||||
static PHINode *FindPHIToPartitionLoops(Loop *L, DominatorSet &DS,
|
||||
AliasAnalysis *AA) {
|
||||
static PHINode *FindPHIToPartitionLoops(Loop *L, ETForest *EF,
|
||||
AliasAnalysis *AA) {
|
||||
for (BasicBlock::iterator I = L->getHeader()->begin(); isa<PHINode>(I); ) {
|
||||
PHINode *PN = cast<PHINode>(I);
|
||||
++I;
|
||||
if (Value *V = PN->hasConstantValue())
|
||||
if (!isa<Instruction>(V) || DS.dominates(cast<Instruction>(V), PN)) {
|
||||
if (!isa<Instruction>(V) || EF->dominates(cast<Instruction>(V), PN)) {
|
||||
// This is a degenerate PHI already, don't modify it!
|
||||
PN->replaceAllUsesWith(V);
|
||||
if (AA) AA->deleteValue(PN);
|
||||
@ -497,7 +498,8 @@ void LoopSimplify::PlaceSplitBlockCarefully(BasicBlock *NewBB,
|
||||
/// created.
|
||||
///
|
||||
Loop *LoopSimplify::SeparateNestedLoop(Loop *L) {
|
||||
PHINode *PN = FindPHIToPartitionLoops(L, getAnalysis<DominatorSet>(), AA);
|
||||
ETForest *EF = getAnalysisToUpdate<ETForest>();
|
||||
PHINode *PN = FindPHIToPartitionLoops(L, EF, AA);
|
||||
if (PN == 0) return 0; // No known way to partition.
|
||||
|
||||
// Pull out all predecessors that have varying values in the loop. This
|
||||
|
@ -883,6 +883,25 @@ void ETForestBase::updateDFSNumbers()
|
||||
DFSInfoValid = true;
|
||||
}
|
||||
|
||||
// dominates - Return true if A dominates B. THis performs the
|
||||
// special checks necessary if A and B are in the same basic block.
|
||||
bool ETForestBase::dominates(Instruction *A, Instruction *B) {
|
||||
BasicBlock *BBA = A->getParent(), *BBB = B->getParent();
|
||||
if (BBA != BBB) return dominates(BBA, BBB);
|
||||
|
||||
// Loop through the basic block until we find A or B.
|
||||
BasicBlock::iterator I = BBA->begin();
|
||||
for (; &*I != A && &*I != B; ++I) /*empty*/;
|
||||
|
||||
if(!IsPostDominators) {
|
||||
// A dominates B if it is found first in the basic block.
|
||||
return &*I == A;
|
||||
} else {
|
||||
// A post-dominates B if B is found first in the basic block.
|
||||
return &*I == B;
|
||||
}
|
||||
}
|
||||
|
||||
ETNode *ETForest::getNodeForBlock(BasicBlock *BB) {
|
||||
ETNode *&BBNode = Nodes[BB];
|
||||
if (BBNode) return BBNode;
|
||||
|
Loading…
x
Reference in New Issue
Block a user