[PATCH] D63304: Ignore Singletons in statement domains

Sameer AbuAsal via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 13 16:02:33 PDT 2019


sabuasal created this revision.
sabuasal added reviewers: grosser, Meinersbur.
sabuasal added a project: Polly.
Herald added a reviewer: bollu.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Code generation in Polly doesn't do a good job with disjunctions in Polly,
 one statement will get materialized more than once which will increase code
 size.

    
  For example, for a do-while loop would be modeled like so:
    
    :: isl ast :: foo :: %do.body---%do.end
     [p_0] -> {  : -2147483648 <= p_0 <= 2147483647 }
      { domain: "[p_0] -> { Stmt0[i0] : 0 <= i0 < p_0; Stmt0[0] : p_0 <= 0 }",
           child: { schedule: "[p_0] -> [{ Stmt0[i0] -> [(i0)] }]" } }
      if (1 && 0 == (p_0 >= 268435457 || p_0 <= -1))
            {
              #pragma simd
              #pragma known-parallel
              for (int c0 = 0; c0 < p_0; c0 += 1)
                Stmt0(c0);
              if (p_0 <= 0)
                Stmt0(0);    <---- will be rematerialized.
            }
    
        else
              {  /* original code */ }
  In the resulting AST There is a separate instance for the 0 case (of p_0) and
  different one for the non zero case.
    
  By pruning the domain set to ignore singletons we can generate a contiguous set,
  we can do that by injecting the assumption that the loop trip count
  is always > 0 to generate a domain (and corresponding AST) that looks like so:
    
          :: isl ast :: foo :: %do.body---%do.end
          [p_0] -> {  : -2147483648 <= p_0 <= 2147483647 }
          { domain: "[p_0] -> { Stmt0[i0] : 0 <= i0 < p_0 }",
              child: { schedule: "[p_0] -> [{ Stmt0[i0] -> [(i0)] }]" } }
          if (p_0 >= 1 && 0 == (p_0 >= 268435457 || p_0 <= -1))  --> added a condition for P_0 > 1
    
              #pragma simd
              #pragma known-parallel
              for (int c0 = 0; c0 < p_0; c0 += 1)
                Stmt0(c0);
    
          else
              {  /* original code */ }


Repository:
  rPLO Polly

https://reviews.llvm.org/D63304

Files:
  include/polly/ScopInfo.h
  lib/Analysis/ScopBuilder.cpp
  lib/Analysis/ScopInfo.cpp
  test/ScopDetect/model-dowhile.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63304.204652.patch
Type: text/x-patch
Size: 12305 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190613/988fa8f3/attachment.bin>


More information about the llvm-commits mailing list