[PATCH] D15680: [Polly] Do not check JSON alignment of scalar accesses

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 20 12:41:21 PST 2015


Small comment

On 12/20, Michael Kruse wrote:
> Meinersbur created this revision.
> Meinersbur added reviewers: grosser, jdoerfert.
> Meinersbur added subscribers: llvm-commits, pollydev.
> Meinersbur added a project: Polly.
> 
> When importing a schedule, do not verify the load/store alignment of scalar accesses. Scalar loads/store are always created newly in code generation with no alignment restrictions. Previously, scalar alignment was checked if the access instruction happened to be a LoadInst or StoreInst, but only its array (MK_Array) access is relevant.
> 
> This will be implicitly unit-tested when the access instruction of a value read can be nullptr.
> 
> 
> http://reviews.llvm.org/D15680
> 
> Files:
>   lib/Exchange/JSONExporter.cpp
> 
> Index: lib/Exchange/JSONExporter.cpp
> ===================================================================
> --- lib/Exchange/JSONExporter.cpp
> +++ lib/Exchange/JSONExporter.cpp
> @@ -304,33 +304,36 @@
>        isl_id *OutId = isl_map_get_tuple_id(currentAccessMap, isl_dim_out);
>        newAccessMap = isl_map_set_tuple_id(newAccessMap, isl_dim_out, OutId);
>  
> -      // We keep the old alignment, thus we cannot allow accesses to memory
> -      // locations that were not accessed before if the alignment of the access
> -      // is not the default alignment.
> -      bool SpecialAlignment = true;
> -      if (LoadInst *LoadI = dyn_cast<LoadInst>(MA->getAccessInstruction())) {
> -        SpecialAlignment =
> -            DL.getABITypeAlignment(LoadI->getType()) != LoadI->getAlignment();
> -      } else if (StoreInst *StoreI =
> -                     dyn_cast<StoreInst>(MA->getAccessInstruction())) {
> -        SpecialAlignment =
> -            DL.getABITypeAlignment(StoreI->getValueOperand()->getType()) !=
> -            StoreI->getAlignment();
> -      }
> +      if (MA->isArrayKind()) {
> +        // We keep the old alignment, thus we cannot allow accesses to memory
> +        // locations that were not accessed before if the alignment of the
> +        // access
> +        // is not the default alignment.
Formating.

> +        bool SpecialAlignment = true;
> +        if (LoadInst *LoadI = dyn_cast<LoadInst>(MA->getAccessInstruction())) {
> +          SpecialAlignment =
> +              DL.getABITypeAlignment(LoadI->getType()) != LoadI->getAlignment();
> +        } else if (StoreInst *StoreI =
> +                       dyn_cast<StoreInst>(MA->getAccessInstruction())) {
> +          SpecialAlignment =
> +              DL.getABITypeAlignment(StoreI->getValueOperand()->getType()) !=
> +              StoreI->getAlignment();
> +        }
>  
> -      if (SpecialAlignment) {
> -        isl_set *newAccessSet = isl_map_range(isl_map_copy(newAccessMap));
> -        isl_set *currentAccessSet =
> -            isl_map_range(isl_map_copy(currentAccessMap));
> -        bool isSubset = isl_set_is_subset(newAccessSet, currentAccessSet);
> -        isl_set_free(newAccessSet);
> -        isl_set_free(currentAccessSet);
> -
> -        if (!isSubset) {
> -          errs() << "JScop file changes the accessed memory\n";
> -          isl_map_free(currentAccessMap);
> -          isl_map_free(newAccessMap);
> -          return false;
> +        if (SpecialAlignment) {
> +          isl_set *newAccessSet = isl_map_range(isl_map_copy(newAccessMap));
> +          isl_set *currentAccessSet =
> +              isl_map_range(isl_map_copy(currentAccessMap));
> +          bool isSubset = isl_set_is_subset(newAccessSet, currentAccessSet);
> +          isl_set_free(newAccessSet);
> +          isl_set_free(currentAccessSet);
> +
> +          if (!isSubset) {
> +            errs() << "JScop file changes the accessed memory\n";
> +            isl_map_free(currentAccessMap);
> +            isl_map_free(newAccessMap);
> +            return false;
> +          }
>          }
>        }
>  
> 
> 

> Index: lib/Exchange/JSONExporter.cpp
> ===================================================================
> --- lib/Exchange/JSONExporter.cpp
> +++ lib/Exchange/JSONExporter.cpp
> @@ -304,33 +304,36 @@
>        isl_id *OutId = isl_map_get_tuple_id(currentAccessMap, isl_dim_out);
>        newAccessMap = isl_map_set_tuple_id(newAccessMap, isl_dim_out, OutId);
>  
> -      // We keep the old alignment, thus we cannot allow accesses to memory
> -      // locations that were not accessed before if the alignment of the access
> -      // is not the default alignment.
> -      bool SpecialAlignment = true;
> -      if (LoadInst *LoadI = dyn_cast<LoadInst>(MA->getAccessInstruction())) {
> -        SpecialAlignment =
> -            DL.getABITypeAlignment(LoadI->getType()) != LoadI->getAlignment();
> -      } else if (StoreInst *StoreI =
> -                     dyn_cast<StoreInst>(MA->getAccessInstruction())) {
> -        SpecialAlignment =
> -            DL.getABITypeAlignment(StoreI->getValueOperand()->getType()) !=
> -            StoreI->getAlignment();
> -      }
> +      if (MA->isArrayKind()) {
> +        // We keep the old alignment, thus we cannot allow accesses to memory
> +        // locations that were not accessed before if the alignment of the
> +        // access
> +        // is not the default alignment.
> +        bool SpecialAlignment = true;
> +        if (LoadInst *LoadI = dyn_cast<LoadInst>(MA->getAccessInstruction())) {
> +          SpecialAlignment =
> +              DL.getABITypeAlignment(LoadI->getType()) != LoadI->getAlignment();
> +        } else if (StoreInst *StoreI =
> +                       dyn_cast<StoreInst>(MA->getAccessInstruction())) {
> +          SpecialAlignment =
> +              DL.getABITypeAlignment(StoreI->getValueOperand()->getType()) !=
> +              StoreI->getAlignment();
> +        }
>  
> -      if (SpecialAlignment) {
> -        isl_set *newAccessSet = isl_map_range(isl_map_copy(newAccessMap));
> -        isl_set *currentAccessSet =
> -            isl_map_range(isl_map_copy(currentAccessMap));
> -        bool isSubset = isl_set_is_subset(newAccessSet, currentAccessSet);
> -        isl_set_free(newAccessSet);
> -        isl_set_free(currentAccessSet);
> -
> -        if (!isSubset) {
> -          errs() << "JScop file changes the accessed memory\n";
> -          isl_map_free(currentAccessMap);
> -          isl_map_free(newAccessMap);
> -          return false;
> +        if (SpecialAlignment) {
> +          isl_set *newAccessSet = isl_map_range(isl_map_copy(newAccessMap));
> +          isl_set *currentAccessSet =
> +              isl_map_range(isl_map_copy(currentAccessMap));
> +          bool isSubset = isl_set_is_subset(newAccessSet, currentAccessSet);
> +          isl_set_free(newAccessSet);
> +          isl_set_free(currentAccessSet);
> +
> +          if (!isSubset) {
> +            errs() << "JScop file changes the accessed memory\n";
> +            isl_map_free(currentAccessMap);
> +            isl_map_free(newAccessMap);
> +            return false;
> +          }
>          }
>        }
>  


-- 

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/20151220/ae4e0aff/attachment.sig>


More information about the llvm-commits mailing list