mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
[Transforms/Scalar] Use range-based for loops (NFC)
This commit is contained in:
parent
f9bdd6d212
commit
9912faec1f
@ -776,16 +776,16 @@ memoryIsNotModifiedBetween(Instruction *FirstI, Instruction *SecondI, AATy &AA,
|
|||||||
if (B != FirstBB) {
|
if (B != FirstBB) {
|
||||||
assert(B != &FirstBB->getParent()->getEntryBlock() &&
|
assert(B != &FirstBB->getParent()->getEntryBlock() &&
|
||||||
"Should not hit the entry block because SI must be dominated by LI");
|
"Should not hit the entry block because SI must be dominated by LI");
|
||||||
for (auto PredI = pred_begin(B), PE = pred_end(B); PredI != PE; ++PredI) {
|
for (BasicBlock *Pred : predecessors(B)) {
|
||||||
PHITransAddr PredAddr = Addr;
|
PHITransAddr PredAddr = Addr;
|
||||||
if (PredAddr.NeedsPHITranslationFromBlock(B)) {
|
if (PredAddr.NeedsPHITranslationFromBlock(B)) {
|
||||||
if (!PredAddr.IsPotentiallyPHITranslatable())
|
if (!PredAddr.IsPotentiallyPHITranslatable())
|
||||||
return false;
|
return false;
|
||||||
if (PredAddr.PHITranslateValue(B, *PredI, DT, false))
|
if (PredAddr.PHITranslateValue(B, Pred, DT, false))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Value *TranslatedPtr = PredAddr.getAddr();
|
Value *TranslatedPtr = PredAddr.getAddr();
|
||||||
auto Inserted = Visited.insert(std::make_pair(*PredI, TranslatedPtr));
|
auto Inserted = Visited.insert(std::make_pair(Pred, TranslatedPtr));
|
||||||
if (!Inserted.second) {
|
if (!Inserted.second) {
|
||||||
// We already visited this block before. If it was with a different
|
// We already visited this block before. If it was with a different
|
||||||
// address - bail out!
|
// address - bail out!
|
||||||
@ -794,7 +794,7 @@ memoryIsNotModifiedBetween(Instruction *FirstI, Instruction *SecondI, AATy &AA,
|
|||||||
// ... otherwise just skip it.
|
// ... otherwise just skip it.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
WorkList.push_back(std::make_pair(*PredI, PredAddr));
|
WorkList.push_back(std::make_pair(Pred, PredAddr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -805,8 +805,7 @@ memoryIsNotModifiedBetween(Instruction *FirstI, Instruction *SecondI, AATy &AA,
|
|||||||
/// them to F.
|
/// them to F.
|
||||||
static void findUnconditionalPreds(SmallVectorImpl<BasicBlock *> &Blocks,
|
static void findUnconditionalPreds(SmallVectorImpl<BasicBlock *> &Blocks,
|
||||||
BasicBlock *BB, DominatorTree *DT) {
|
BasicBlock *BB, DominatorTree *DT) {
|
||||||
for (pred_iterator I = pred_begin(BB), E = pred_end(BB); I != E; ++I) {
|
for (BasicBlock *Pred : predecessors(BB)) {
|
||||||
BasicBlock *Pred = *I;
|
|
||||||
if (Pred == BB) continue;
|
if (Pred == BB) continue;
|
||||||
Instruction *PredTI = Pred->getTerminator();
|
Instruction *PredTI = Pred->getTerminator();
|
||||||
if (PredTI->getNumSuccessors() != 1)
|
if (PredTI->getNumSuccessors() != 1)
|
||||||
|
@ -2795,9 +2795,7 @@ void GVN::addDeadBlock(BasicBlock *BB) {
|
|||||||
|
|
||||||
// For the dead blocks' live successors, update their phi nodes by replacing
|
// For the dead blocks' live successors, update their phi nodes by replacing
|
||||||
// the operands corresponding to dead blocks with UndefVal.
|
// the operands corresponding to dead blocks with UndefVal.
|
||||||
for(SmallSetVector<BasicBlock *, 4>::iterator I = DF.begin(), E = DF.end();
|
for (BasicBlock *B : DF) {
|
||||||
I != E; I++) {
|
|
||||||
BasicBlock *B = *I;
|
|
||||||
if (DeadBlocks.count(B))
|
if (DeadBlocks.count(B))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -310,9 +310,8 @@ bool LUAnalysisCache::countLoop(const Loop *L, const TargetTransformInfo &TTI,
|
|||||||
// consideration code simplification opportunities and code that can
|
// consideration code simplification opportunities and code that can
|
||||||
// be shared by the resultant unswitched loops.
|
// be shared by the resultant unswitched loops.
|
||||||
CodeMetrics Metrics;
|
CodeMetrics Metrics;
|
||||||
for (Loop::block_iterator I = L->block_begin(), E = L->block_end(); I != E;
|
for (BasicBlock *BB : L->blocks())
|
||||||
++I)
|
Metrics.analyzeBasicBlock(BB, TTI, EphValues);
|
||||||
Metrics.analyzeBasicBlock(*I, TTI, EphValues);
|
|
||||||
|
|
||||||
Props.SizeEstimation = Metrics.NumInsts;
|
Props.SizeEstimation = Metrics.NumInsts;
|
||||||
Props.CanBeUnswitchedCount = MaxSize / (Props.SizeEstimation);
|
Props.CanBeUnswitchedCount = MaxSize / (Props.SizeEstimation);
|
||||||
@ -1132,9 +1131,9 @@ static bool isTrivialLoopExitBlockHelper(Loop *L, BasicBlock *BB,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, this is an unvisited intra-loop node. Check all successors.
|
// Otherwise, this is an unvisited intra-loop node. Check all successors.
|
||||||
for (succ_iterator SI = succ_begin(BB), E = succ_end(BB); SI != E; ++SI) {
|
for (BasicBlock *Succ : successors(BB)) {
|
||||||
// Check to see if the successor is a trivial loop exit.
|
// Check to see if the successor is a trivial loop exit.
|
||||||
if (!isTrivialLoopExitBlockHelper(L, *SI, ExitBB, Visited))
|
if (!isTrivialLoopExitBlockHelper(L, Succ, ExitBB, Visited))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1628,9 +1627,7 @@ void LoopUnswitch::unswitchNontrivialCondition(
|
|||||||
PHINode *PN = PHINode::Create(LPad->getType(), 0, "",
|
PHINode *PN = PHINode::Create(LPad->getType(), 0, "",
|
||||||
&*ExitSucc->getFirstInsertionPt());
|
&*ExitSucc->getFirstInsertionPt());
|
||||||
|
|
||||||
for (pred_iterator I = pred_begin(ExitSucc), E = pred_end(ExitSucc);
|
for (BasicBlock *BB : predecessors(ExitSucc)) {
|
||||||
I != E; ++I) {
|
|
||||||
BasicBlock *BB = *I;
|
|
||||||
LandingPadInst *LPI = BB->getLandingPadInst();
|
LandingPadInst *LPI = BB->getLandingPadInst();
|
||||||
LPI->replaceAllUsesWith(PN);
|
LPI->replaceAllUsesWith(PN);
|
||||||
PN->addIncoming(LPI, BB);
|
PN->addIncoming(LPI, BB);
|
||||||
|
@ -440,8 +440,7 @@ BCECmpChain::BCECmpChain(const std::vector<BasicBlock *> &Blocks, PHINode &Phi,
|
|||||||
// Now look inside blocks to check for BCE comparisons.
|
// Now look inside blocks to check for BCE comparisons.
|
||||||
std::vector<BCECmpBlock> Comparisons;
|
std::vector<BCECmpBlock> Comparisons;
|
||||||
BaseIdentifier BaseId;
|
BaseIdentifier BaseId;
|
||||||
for (size_t BlockIdx = 0; BlockIdx < Blocks.size(); ++BlockIdx) {
|
for (BasicBlock *const Block : Blocks) {
|
||||||
BasicBlock *const Block = Blocks[BlockIdx];
|
|
||||||
assert(Block && "invalid block");
|
assert(Block && "invalid block");
|
||||||
BCECmpBlock Comparison = visitCmpBlock(Phi.getIncomingValueForBlock(Block),
|
BCECmpBlock Comparison = visitCmpBlock(Phi.getIncomingValueForBlock(Block),
|
||||||
Block, Phi.getParent(), BaseId);
|
Block, Phi.getParent(), BaseId);
|
||||||
|
@ -364,8 +364,8 @@ NaryReassociatePass::tryReassociateGEPAtIndex(GetElementPtrInst *GEP,
|
|||||||
// Look for GEP's closest dominator that has the same SCEV as GEP except that
|
// Look for GEP's closest dominator that has the same SCEV as GEP except that
|
||||||
// the I-th index is replaced with LHS.
|
// the I-th index is replaced with LHS.
|
||||||
SmallVector<const SCEV *, 4> IndexExprs;
|
SmallVector<const SCEV *, 4> IndexExprs;
|
||||||
for (auto Index = GEP->idx_begin(); Index != GEP->idx_end(); ++Index)
|
for (Use &Index : GEP->indices())
|
||||||
IndexExprs.push_back(SE->getSCEV(*Index));
|
IndexExprs.push_back(SE->getSCEV(Index));
|
||||||
// Replace the I-th index with LHS.
|
// Replace the I-th index with LHS.
|
||||||
IndexExprs[I] = SE->getSCEV(LHS);
|
IndexExprs[I] = SE->getSCEV(LHS);
|
||||||
if (isKnownNonNegative(LHS, *DL, 0, AC, GEP, DT) &&
|
if (isKnownNonNegative(LHS, *DL, 0, AC, GEP, DT) &&
|
||||||
|
@ -312,8 +312,8 @@ bool StraightLineStrengthReduce::isFoldable(const Candidate &C,
|
|||||||
// Returns true if GEP has zero or one non-zero index.
|
// Returns true if GEP has zero or one non-zero index.
|
||||||
static bool hasOnlyOneNonZeroIndex(GetElementPtrInst *GEP) {
|
static bool hasOnlyOneNonZeroIndex(GetElementPtrInst *GEP) {
|
||||||
unsigned NumNonZeroIndices = 0;
|
unsigned NumNonZeroIndices = 0;
|
||||||
for (auto I = GEP->idx_begin(); I != GEP->idx_end(); ++I) {
|
for (Use &Idx : GEP->indices()) {
|
||||||
ConstantInt *ConstIdx = dyn_cast<ConstantInt>(*I);
|
ConstantInt *ConstIdx = dyn_cast<ConstantInt>(Idx);
|
||||||
if (ConstIdx == nullptr || !ConstIdx->isZero())
|
if (ConstIdx == nullptr || !ConstIdx->isZero())
|
||||||
++NumNonZeroIndices;
|
++NumNonZeroIndices;
|
||||||
}
|
}
|
||||||
@ -533,8 +533,8 @@ void StraightLineStrengthReduce::allocateCandidatesAndFindBasisForGEP(
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
SmallVector<const SCEV *, 4> IndexExprs;
|
SmallVector<const SCEV *, 4> IndexExprs;
|
||||||
for (auto I = GEP->idx_begin(); I != GEP->idx_end(); ++I)
|
for (Use &Idx : GEP->indices())
|
||||||
IndexExprs.push_back(SE->getSCEV(*I));
|
IndexExprs.push_back(SE->getSCEV(Idx));
|
||||||
|
|
||||||
gep_type_iterator GTI = gep_type_begin(GEP);
|
gep_type_iterator GTI = gep_type_begin(GEP);
|
||||||
for (unsigned I = 1, E = GEP->getNumOperands(); I != E; ++I, ++GTI) {
|
for (unsigned I = 1, E = GEP->getNumOperands(); I != E; ++I, ++GTI) {
|
||||||
|
@ -677,9 +677,8 @@ void StructurizeCFG::killTerminator(BasicBlock *BB) {
|
|||||||
if (!Term)
|
if (!Term)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (succ_iterator SI = succ_begin(BB), SE = succ_end(BB);
|
for (BasicBlock *Succ : successors(BB))
|
||||||
SI != SE; ++SI)
|
delPhiValues(BB, Succ);
|
||||||
delPhiValues(BB, *SI);
|
|
||||||
|
|
||||||
if (DA)
|
if (DA)
|
||||||
DA->removeValue(Term);
|
DA->removeValue(Term);
|
||||||
|
Loading…
Reference in New Issue
Block a user