From c3e9c1442da3f1e68b9b894c50d219747991330a Mon Sep 17 00:00:00 2001 From: Michael Kruse Date: Thu, 23 Mar 2017 16:12:21 +0000 Subject: [PATCH] [ScopInfo] Introduce ScopStmt::contains(BB*). NFC. Provide an common way for testing if a statement contains something for region and block statements. First user is RegionGenerator::addOperandToPHI. Suggested-by: Tobias Grosser llvm-svn: 298617 --- polly/include/polly/ScopInfo.h | 9 +++++++++ polly/lib/CodeGen/BlockGenerators.cpp | 6 ++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/polly/include/polly/ScopInfo.h b/polly/include/polly/ScopInfo.h index 66759d4..664c112 100644 --- a/polly/include/polly/ScopInfo.h +++ b/polly/include/polly/ScopInfo.h @@ -1324,6 +1324,15 @@ public: return getRegion()->contains(L); } + /// Return whether this statement contains @p BB. + bool contains(BasicBlock *BB) const { + if (isCopyStmt()) + return false; + if (isBlockStmt()) + return BB == getBasicBlock(); + return getRegion()->contains(BB); + } + /// Return the closest innermost loop that contains this statement, but is not /// contained in it. /// diff --git a/polly/lib/CodeGen/BlockGenerators.cpp b/polly/lib/CodeGen/BlockGenerators.cpp index a6f5c7c..8f9e057 100644 --- a/polly/lib/CodeGen/BlockGenerators.cpp +++ b/polly/lib/CodeGen/BlockGenerators.cpp @@ -1411,13 +1411,11 @@ void RegionGenerator::generateScalarStores( void RegionGenerator::addOperandToPHI(ScopStmt &Stmt, PHINode *PHI, PHINode *PHICopy, BasicBlock *IncomingBB, LoopToScevMapT <S) { - Region *StmtR = Stmt.getRegion(); - // If the incoming block was not yet copied mark this PHI as incomplete. // Once the block will be copied the incoming value will be added. BasicBlock *BBCopy = BlockMap[IncomingBB]; if (!BBCopy) { - assert(StmtR->contains(IncomingBB) && + assert(Stmt.contains(IncomingBB) && "Bad incoming block for PHI in non-affine region"); IncompletePHINodeMap[IncomingBB].push_back(std::make_pair(PHI, PHICopy)); return; @@ -1428,7 +1426,7 @@ void RegionGenerator::addOperandToPHI(ScopStmt &Stmt, PHINode *PHI, Value *OpCopy = nullptr; - if (StmtR->contains(IncomingBB)) { + if (Stmt.contains(IncomingBB)) { Value *Op = PHI->getIncomingValueForBlock(IncomingBB); // If the current insert block is different from the PHIs incoming block -- 2.7.4