summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--polly/lib/Analysis/TempScopInfo.cpp15
-rw-r--r--polly/lib/IndVarSimplify.cpp44
-rw-r--r--polly/lib/IndependentBlocks.cpp27
3 files changed, 38 insertions, 48 deletions
diff --git a/polly/lib/Analysis/TempScopInfo.cpp b/polly/lib/Analysis/TempScopInfo.cpp
index c0f19f136c2..897ed261800 100644
--- a/polly/lib/Analysis/TempScopInfo.cpp
+++ b/polly/lib/Analysis/TempScopInfo.cpp
@@ -105,15 +105,14 @@ bool TempScopInfo::buildScalarDependences(Instruction *Inst, Region *R) {
bool AnyCrossStmtUse = false;
BasicBlock *ParentBB = Inst->getParent();
- for (Instruction::use_iterator UI = Inst->use_begin(), UE = Inst->use_end();
- UI != UE; ++UI) {
- Instruction *U = dyn_cast<Instruction>(*UI);
+ for (User *U : Inst->users()) {
+ Instruction *UI = dyn_cast<Instruction>(U);
// Ignore the strange user
- if (U == 0)
+ if (UI == 0)
continue;
- BasicBlock *UseParent = U->getParent();
+ BasicBlock *UseParent = UI->getParent();
// Ignore the users in the same BB (statement)
if (UseParent == ParentBB)
@@ -121,7 +120,7 @@ bool TempScopInfo::buildScalarDependences(Instruction *Inst, Region *R) {
// No need to translate these scalar dependences into polyhedral form,
// because synthesizable scalars can be generated by the code generator.
- if (canSynthesize(U, LI, SE, R))
+ if (canSynthesize(UI, LI, SE, R))
continue;
// Now U is used in another statement.
@@ -131,12 +130,12 @@ bool TempScopInfo::buildScalarDependences(Instruction *Inst, Region *R) {
if (!R->contains(UseParent))
continue;
- assert(!isa<PHINode>(U) && "Non synthesizable PHINode found in a SCoP!");
+ assert(!isa<PHINode>(UI) && "Non synthesizable PHINode found in a SCoP!");
// Use the def instruction as base address of the IRAccess, so that it will
// become the name of the scalar access in the polyhedral form.
IRAccess ScalarAccess(IRAccess::SCALARREAD, Inst, ZeroOffset, 1, true);
- AccFuncMap[UseParent].push_back(std::make_pair(ScalarAccess, U));
+ AccFuncMap[UseParent].push_back(std::make_pair(ScalarAccess, UI));
}
return AnyCrossStmtUse;
diff --git a/polly/lib/IndVarSimplify.cpp b/polly/lib/IndVarSimplify.cpp
index 286cdcdbc65..e0e52f37818 100644
--- a/polly/lib/IndVarSimplify.cpp
+++ b/polly/lib/IndVarSimplify.cpp
@@ -262,12 +262,12 @@ void PollyIndVarSimplify::HandleFloatingPointIV(Loop *L, PHINode *PN) {
// Check Incr uses. One user is PN and the other user is an exit condition
// used by the conditional terminator.
- Value::use_iterator IncrUse = Incr->use_begin();
+ Value::user_iterator IncrUse = Incr->user_begin();
Instruction *U1 = cast<Instruction>(*IncrUse++);
- if (IncrUse == Incr->use_end())
+ if (IncrUse == Incr->user_end())
return;
Instruction *U2 = cast<Instruction>(*IncrUse++);
- if (IncrUse != Incr->use_end())
+ if (IncrUse != Incr->user_end())
return;
// Find exit condition, which is an fcmp. If it doesn't exist, or if it isn't
@@ -276,10 +276,10 @@ void PollyIndVarSimplify::HandleFloatingPointIV(Loop *L, PHINode *PN) {
if (!Compare)
Compare = dyn_cast<FCmpInst>(U2);
if (Compare == 0 || !Compare->hasOneUse() ||
- !isa<BranchInst>(Compare->use_back()))
+ !isa<BranchInst>(Compare->user_back()))
return;
- BranchInst *TheBr = cast<BranchInst>(Compare->use_back());
+ BranchInst *TheBr = cast<BranchInst>(Compare->user_back());
// We need to verify that the branch actually controls the iteration count
// of the loop. If not, the new IV can overflow and no one will notice.
@@ -1084,16 +1084,14 @@ Instruction *WidenIV::WidenIVUse(NarrowIVDefUse DU, SCEVExpander &Rewriter) {
/// pushNarrowIVUsers - Add eligible users of NarrowDef to NarrowIVUsers.
///
void WidenIV::pushNarrowIVUsers(Instruction *NarrowDef, Instruction *WideDef) {
- for (Value::use_iterator UI = NarrowDef->use_begin(),
- UE = NarrowDef->use_end();
- UI != UE; ++UI) {
- Instruction *NarrowUse = cast<Instruction>(*UI);
+ for (User *U : NarrowDef->users()) {
+ Instruction *NarrowUser = cast<Instruction>(U);
// Handle data flow merges and bizarre phi cycles.
- if (!Widened.insert(NarrowUse))
+ if (!Widened.insert(NarrowUser))
continue;
- NarrowIVUsers.push_back(NarrowIVDefUse(NarrowDef, NarrowUse, WideDef));
+ NarrowIVUsers.push_back(NarrowIVDefUse(NarrowDef, NarrowUser, WideDef));
}
}
@@ -1436,17 +1434,14 @@ static bool AlmostDeadIV(PHINode *Phi, BasicBlock *LatchBlock, Value *Cond) {
int LatchIdx = Phi->getBasicBlockIndex(LatchBlock);
Value *IncV = Phi->getIncomingValue(LatchIdx);
- for (Value::use_iterator UI = Phi->use_begin(), UE = Phi->use_end(); UI != UE;
- ++UI) {
- if (*UI != Cond && *UI != IncV)
+ for (User *U : Phi->users())
+ if (U != Cond && U != IncV)
return false;
- }
- for (Value::use_iterator UI = IncV->use_begin(), UE = IncV->use_end();
- UI != UE; ++UI) {
- if (*UI != Cond && *UI != Phi)
+ for (User *U : IncV->users())
+ if (U != Cond && U != Phi)
return false;
- }
+
return true;
}
@@ -1747,12 +1742,11 @@ void PollyIndVarSimplify::SinkUnusedInvariants(Loop *L) {
// Determine if there is a use in or before the loop (direct or
// otherwise).
bool UsedInLoop = false;
- for (Value::use_iterator UI = I->use_begin(), UE = I->use_end(); UI != UE;
- ++UI) {
- User *U = *UI;
- BasicBlock *UseBB = cast<Instruction>(U)->getParent();
- if (PHINode *P = dyn_cast<PHINode>(U)) {
- unsigned i = PHINode::getIncomingValueNumForOperand(UI.getOperandNo());
+ for (Use &U : I->uses()) {
+ Instruction *UI = cast<Instruction>(U.getUser());
+ BasicBlock *UseBB = UI->getParent();
+ if (PHINode *P = dyn_cast<PHINode>(UI)) {
+ unsigned i = PHINode::getIncomingValueNumForOperand(U.getOperandNo());
UseBB = P->getIncomingBlock(i);
}
if (UseBB == Preheader || L->contains(UseBB)) {
diff --git a/polly/lib/IndependentBlocks.cpp b/polly/lib/IndependentBlocks.cpp
index fb54c28edd5..d86c3bde5c8 100644
--- a/polly/lib/IndependentBlocks.cpp
+++ b/polly/lib/IndependentBlocks.cpp
@@ -359,10 +359,9 @@ bool IndependentBlocks::translateScalarToArray(const Region *R) {
// Returns true when Inst is only used inside region R.
bool IndependentBlocks::onlyUsedInRegion(Instruction *Inst, const Region *R) {
- for (Instruction::use_iterator UI = Inst->use_begin(), UE = Inst->use_end();
- UI != UE; ++UI)
- if (Instruction *U = dyn_cast<Instruction>(*UI))
- if (isEscapeUse(U, R))
+ for (User *U : Inst->users())
+ if (Instruction *UI = dyn_cast<Instruction>(U))
+ if (isEscapeUse(UI, R))
return false;
return true;
@@ -374,22 +373,21 @@ bool IndependentBlocks::translateScalarToArray(Instruction *Inst,
return false;
SmallVector<Instruction *, 4> LoadInside, LoadOutside;
- for (Instruction::use_iterator UI = Inst->use_begin(), UE = Inst->use_end();
- UI != UE; ++UI)
+ for (User *U : Inst->users())
// Inst is referenced outside or referenced as an escaped operand.
- if (Instruction *U = dyn_cast<Instruction>(*UI)) {
- if (isEscapeUse(U, R))
- LoadOutside.push_back(U);
+ if (Instruction *UI = dyn_cast<Instruction>(U)) {
+ if (isEscapeUse(UI, R))
+ LoadOutside.push_back(UI);
if (DisableIntraScopScalarToArray)
continue;
- if (canSynthesize(U, LI, SE, R))
+ if (canSynthesize(UI, LI, SE, R))
continue;
- BasicBlock *UParent = U->getParent();
+ BasicBlock *UParent = UI->getParent();
if (R->contains(UParent) && isEscapeOperand(Inst, UParent, R))
- LoadInside.push_back(U);
+ LoadInside.push_back(UI);
}
if (LoadOutside.empty() && LoadInside.empty())
@@ -458,9 +456,8 @@ bool IndependentBlocks::isIndependentBlock(const Region *R,
continue;
// A value inside the Scop is referenced outside.
- for (Instruction::use_iterator UI = Inst->use_begin(), UE = Inst->use_end();
- UI != UE; ++UI) {
- if (isEscapeUse(*UI, R)) {
+ for (User *U : Inst->users()) {
+ if (isEscapeUse(U, R)) {
DEBUG(dbgs() << "Instruction not independent:\n");
DEBUG(dbgs() << "Instruction used outside the Scop!\n");
DEBUG(Inst->print(dbgs()));
OpenPOWER on IntegriCloud