<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - [polly] The order of the loop is reversed while not necessary"
   href="https://llvm.org/bugs/show_bug.cgi?id=25793">25793</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[polly] The order of the loop is reversed while not necessary
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>tools
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>opt
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>lawrence@codeaurora.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=15426" name="attach_15426" title="reduced testcase">attachment 15426</a> <a href="attachment.cgi?id=15426&action=edit" title="reduced testcase">[details]</a></span>
reduced testcase

Polly schedule changed the order of the loop unnecessaryly.

Here is the original order of the loop in c:


void foo (int * restrict A, int * restrict B, int * restrict C, int n) {
  for(int i = 0; i < n; i++)
    A[i] += 1;
  for(int i = 0; i < n; i++)
    B[i] += 1;
  for(int i = 0; i < n; i++)
    C[i] += 1;
}


Polly schedule reorder the loops to:

void foo (int * restrict A, int * restrict B, int * restrict C, int n) {
  for(int i = 0; i < n; i++)
    C[i] += 1;
  for(int i = 0; i < n; i++)
    A[i] += 1;
  for(int i = 0; i < n; i++)
    B[i] += 1;
}

Here is the isl ast for attached IR
    { 
      #pragma simd
      #pragma known-parallel
      for (int c0 = 0; c0 < n; c0 += 1)
        Stmt_for_body16(c0);
      #pragma simd 
      #pragma known-parallel
      for (int c0 = 0; c0 < n; c0 += 1)
        Stmt_for_body(c0);
      #pragma simd
      #pragma known-parallel
      for (int c0 = 0; c0 < n; c0 += 1)
        Stmt_for_body5(c0);
    }

Even though it is logically correct, however it is not necessary, and afffect
readability.

Use opt -debug -polly  -polly-detect -polly-opt-isl -polly-codegen
-polly-vectorizer=polly -polly-ignore-aliasing -S <t.ll >log.log 2>&1 to
reproduce it</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>