[PATCH] D14688: [Polly] Introduce origin/kind for exit PHI node accesses

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 15 22:10:31 PST 2015


If this is not too pressing I'd like till Wednesday to formulate a real
response.

On 11/15, Michael Kruse wrote:
> Meinersbur created this revision.
> Meinersbur added reviewers: grosser, jdoerfert.
> Meinersbur added subscribers: llvm-commits, pollydev.
> Meinersbur added a project: Polly.
> 
> Previously, accesses that originate from PHI nodes in the exit block were registered as SCALAR. In some context they are treated as such scalars, but it makes a difference in others. We used to check whether the AccessInstruction is a terminator to differentiate the cases.
> 
> This patch introduces an MemoryAccess origin EXIT_PHI and a ScopArrayInfo kind KIND_EXIT_PHI to make this case more explicit.
> 
> http://reviews.llvm.org/D14688
> 
> Files:
>   include/polly/ScopInfo.h
>   lib/Analysis/ScopInfo.cpp
>   lib/CodeGen/BlockGenerators.cpp
> 
> Index: lib/CodeGen/BlockGenerators.cpp
> ===================================================================
> --- lib/CodeGen/BlockGenerators.cpp
> +++ lib/CodeGen/BlockGenerators.cpp
> @@ -1201,7 +1201,7 @@
>      ValueMapT *LocalBBMap = &BBMap;
>  
>      // Implicit writes induced by PHIs must be written in the incoming blocks.
> -    if (isa<TerminatorInst>(ScalarInst)) {
> +    if (MA->isPHI() || MA->isExitPHI()) {
>        BasicBlock *ExitingBB = ScalarInst->getParent();
>        BasicBlock *ExitingBBCopy = BlockMap[ExitingBB];
>        Builder.SetInsertPoint(ExitingBBCopy->getTerminator());
> @@ -1217,7 +1217,7 @@
>      Builder.CreateStore(Val, Address);
>  
>      // Restore the insertion point if necessary.
> -    if (isa<TerminatorInst>(ScalarInst))
> +    if (MA->isPHI() || MA->isExitPHI())
>        Builder.SetInsertPoint(SavedInsertBB, SavedInsertionPoint);
>    }
>  }
> Index: lib/Analysis/ScopInfo.cpp
> ===================================================================
> --- lib/Analysis/ScopInfo.cpp
> +++ lib/Analysis/ScopInfo.cpp
> @@ -876,6 +876,8 @@
>      ScopArrayInfo::ARRAYKIND Ty;
>      if (Access->isPHI())
>        Ty = ScopArrayInfo::KIND_PHI;
> +    else if (Access->isExitPHI())
> +      Ty = ScopArrayInfo::KIND_EXIT_PHI;
>      else if (Access->isImplicit())
>        Ty = ScopArrayInfo::KIND_SCALAR;
>      else
> @@ -3855,7 +3857,7 @@
>    addMemoryAccess(IncomingBlock, IncomingBlock->getTerminator(),
>                    MemoryAccess::MUST_WRITE, PHI, 1, true, IncomingValue,
>                    ArrayRef<const SCEV *>(), ArrayRef<const SCEV *>(),
> -                  IsExitBlock ? MemoryAccess::SCALAR : MemoryAccess::PHI);
> +                  IsExitBlock ? MemoryAccess::EXIT_PHI : MemoryAccess::PHI);
>  }
>  void ScopInfo::addPHIReadAccess(PHINode *PHI) {
>    addMemoryAccess(PHI->getParent(), PHI, MemoryAccess::READ, PHI, 1, true, PHI,
> Index: include/polly/ScopInfo.h
> ===================================================================
> --- include/polly/ScopInfo.h
> +++ include/polly/ScopInfo.h
> @@ -105,6 +105,10 @@
>      // Scalar references used to model PHI nodes
>      KIND_PHI,
>  
> +    // Like KIND_PHI, but for PHIs in the exit node. Depending on context, these
> +    // are handled like KIND_SCALAR.
> +    KIND_EXIT_PHI,
> +
>      // References to (multi-dimensional) arrays
>      KIND_ARRAY,
>    };
> @@ -324,7 +328,7 @@
>    /// #AccessValue is also the llvm::Value itself.
>    ///
>    ///
> -  /// * Accesses to emulate PHI nodes
> +  /// * Accesses to emulate PHI nodes within the SCoP
>    ///
>    /// PHIInst instructions such as
>    ///
> @@ -359,7 +363,14 @@
>    /// Note that there can also be a scalar write access for %PHI if used in a
>    /// different BasicBlock, i.e. there can be a %PHI.phiops as well as a
>    /// %PHI.s2a.
> -  enum AccessOrigin { EXPLICIT, SCALAR, PHI };
> +  ///
> +  /// * Accesses to emulate PHI node that are in the SCoP's exit block
> +  ///
> +  /// Like the previous, but the PHI itself is not located in the SCoP itself.
> +  /// There will be no READ type MemoryAccess for such values. The PHINode's
> +  /// llvm::Value is treated as a value escaping the SCoP. The WRITE access
> +  /// write directly to the escaping value's ".s2a" alloca.
> +  enum AccessOrigin { EXPLICIT, SCALAR, PHI, EXIT_PHI };
>  
>    /// @brief The access type of a memory access
>    ///
> @@ -671,6 +682,10 @@
>    /// @brief Is this MemoryAccess modeling special PHI node accesses?
>    bool isPHI() const { return Origin == PHI; }
>  
> +  /// @brief Is this MemoryAccess modeling the accesses of a PHI node in the
> +  /// SCoP's exit block?
> +  bool isExitPHI() const { return Origin == EXIT_PHI; }
> +
>    /// @brief Get the statement that contains this memory access.
>    ScopStmt *getStatement() const { return Statement; }
>  
> 
> 

> Index: lib/CodeGen/BlockGenerators.cpp
> ===================================================================
> --- lib/CodeGen/BlockGenerators.cpp
> +++ lib/CodeGen/BlockGenerators.cpp
> @@ -1201,7 +1201,7 @@
>      ValueMapT *LocalBBMap = &BBMap;
>  
>      // Implicit writes induced by PHIs must be written in the incoming blocks.
> -    if (isa<TerminatorInst>(ScalarInst)) {
> +    if (MA->isPHI() || MA->isExitPHI()) {
>        BasicBlock *ExitingBB = ScalarInst->getParent();
>        BasicBlock *ExitingBBCopy = BlockMap[ExitingBB];
>        Builder.SetInsertPoint(ExitingBBCopy->getTerminator());
> @@ -1217,7 +1217,7 @@
>      Builder.CreateStore(Val, Address);
>  
>      // Restore the insertion point if necessary.
> -    if (isa<TerminatorInst>(ScalarInst))
> +    if (MA->isPHI() || MA->isExitPHI())
>        Builder.SetInsertPoint(SavedInsertBB, SavedInsertionPoint);
>    }
>  }
> Index: lib/Analysis/ScopInfo.cpp
> ===================================================================
> --- lib/Analysis/ScopInfo.cpp
> +++ lib/Analysis/ScopInfo.cpp
> @@ -876,6 +876,8 @@
>      ScopArrayInfo::ARRAYKIND Ty;
>      if (Access->isPHI())
>        Ty = ScopArrayInfo::KIND_PHI;
> +    else if (Access->isExitPHI())
> +      Ty = ScopArrayInfo::KIND_EXIT_PHI;
>      else if (Access->isImplicit())
>        Ty = ScopArrayInfo::KIND_SCALAR;
>      else
> @@ -3855,7 +3857,7 @@
>    addMemoryAccess(IncomingBlock, IncomingBlock->getTerminator(),
>                    MemoryAccess::MUST_WRITE, PHI, 1, true, IncomingValue,
>                    ArrayRef<const SCEV *>(), ArrayRef<const SCEV *>(),
> -                  IsExitBlock ? MemoryAccess::SCALAR : MemoryAccess::PHI);
> +                  IsExitBlock ? MemoryAccess::EXIT_PHI : MemoryAccess::PHI);
>  }
>  void ScopInfo::addPHIReadAccess(PHINode *PHI) {
>    addMemoryAccess(PHI->getParent(), PHI, MemoryAccess::READ, PHI, 1, true, PHI,
> Index: include/polly/ScopInfo.h
> ===================================================================
> --- include/polly/ScopInfo.h
> +++ include/polly/ScopInfo.h
> @@ -105,6 +105,10 @@
>      // Scalar references used to model PHI nodes
>      KIND_PHI,
>  
> +    // Like KIND_PHI, but for PHIs in the exit node. Depending on context, these
> +    // are handled like KIND_SCALAR.
> +    KIND_EXIT_PHI,
> +
>      // References to (multi-dimensional) arrays
>      KIND_ARRAY,
>    };
> @@ -324,7 +328,7 @@
>    /// #AccessValue is also the llvm::Value itself.
>    ///
>    ///
> -  /// * Accesses to emulate PHI nodes
> +  /// * Accesses to emulate PHI nodes within the SCoP
>    ///
>    /// PHIInst instructions such as
>    ///
> @@ -359,7 +363,14 @@
>    /// Note that there can also be a scalar write access for %PHI if used in a
>    /// different BasicBlock, i.e. there can be a %PHI.phiops as well as a
>    /// %PHI.s2a.
> -  enum AccessOrigin { EXPLICIT, SCALAR, PHI };
> +  ///
> +  /// * Accesses to emulate PHI node that are in the SCoP's exit block
> +  ///
> +  /// Like the previous, but the PHI itself is not located in the SCoP itself.
> +  /// There will be no READ type MemoryAccess for such values. The PHINode's
> +  /// llvm::Value is treated as a value escaping the SCoP. The WRITE access
> +  /// write directly to the escaping value's ".s2a" alloca.
> +  enum AccessOrigin { EXPLICIT, SCALAR, PHI, EXIT_PHI };
>  
>    /// @brief The access type of a memory access
>    ///
> @@ -671,6 +682,10 @@
>    /// @brief Is this MemoryAccess modeling special PHI node accesses?
>    bool isPHI() const { return Origin == PHI; }
>  
> +  /// @brief Is this MemoryAccess modeling the accesses of a PHI node in the
> +  /// SCoP's exit block?
> +  bool isExitPHI() const { return Origin == EXIT_PHI; }
> +
>    /// @brief Get the statement that contains this memory access.
>    ScopStmt *getStatement() const { return Statement; }
>  


-- 

Johannes Doerfert
Researcher / PhD Student

Compiler Design Lab (Prof. Hack)
Saarland University, Computer Science
Building E1.3, Room 4.31

Tel. +49 (0)681 302-57521 : doerfert at cs.uni-saarland.de
Fax. +49 (0)681 302-3065  : http://www.cdl.uni-saarland.de/people/doerfert
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 213 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151116/6aa74d54/attachment.sig>


More information about the llvm-commits mailing list