<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 --- - Seeing different schedule for similar program"
   href="https://llvm.org/bugs/show_bug.cgi?id=26960">26960</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Seeing different schedule for similar program
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Polly
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>Optimizer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>polly-dev@googlegroups.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>zinob@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=16044" name="attach_16044" title="testb">attachment 16044</a> <a href="attachment.cgi?id=16044&action=edit" title="testb">[details]</a></span>
testb

I used the command below

opt -polly -polly-opt-isl -O3 -debug -polly-process-unprofitable
-polly-opt-fusion=max -polly-opt-max-coefficient=-1 < testa.ll
opt -polly -polly-opt-isl -O3 -debug -polly-process-unprofitable
-polly-opt-fusion=max -polly-opt-max-coefficient=-1 < testb.ll

testa.ll and testb.ll  should have same schedule. I just swapped the trip count
between the adjacent loop. See below schedule:

Q1: Why loop fusion is not happening although I am using max strategy?

!2: Why in one case preheader of second loop is hoisted and other case is not?



testb:
: isl ast :: foo :: entry.split => for.cond.cleanup4
[m, n] -> {  : -2147483648 <= m <= 2147483647 and -2147483648 <= n <=
2147483647 }
[m, n] -> { Stmt_for_body5[i0] -> [3, i0] : 0 <= i0 < n; Stmt_for_body_lr_ph[]
-> [1, 0] : m > 0; Stmt_for_body5_lr_ph[] -> [0, 0] : n > 0; Stmt_for_body[i0]
-> [2, i0] : 0 <= i0 < m }
if (1)

    {
      if (n >= 1)
        Stmt_for_body5_lr_ph();
      if (m >= 1)
        Stmt_for_body_lr_ph();
      for (int c0 = 0; c0 < m; c0 += 1)
        Stmt_for_body(c0);
      for (int c0 = 0; c0 < n; c0 += 1)
        Stmt_for_body5(c0);
    }


testa
:: isl ast :: foo :: entry.split => for.cond.cleanup4
[n, m] -> {  : -2147483648 <= n <= 2147483647 and -2147483648 <= m <=
2147483647 }
[n, m] -> { Stmt_for_body5[i0] -> [3, i0] : 0 <= i0 < m; Stmt_for_body[i0] ->
[1, i0] : 0 <= i0 < n; Stmt_for_body_lr_ph[] -> [0, 0] : n > 0;
Stmt_for_body5_lr_ph[] -> [2, 0] : m > 0 }
if (1)

    {
      if (n >= 1)
        Stmt_for_body_lr_ph();
      for (int c0 = 0; c0 < n; c0 += 1)
        Stmt_for_body(c0);
      if (m >= 1)
        Stmt_for_body5_lr_ph();
      for (int c0 = 0; c0 < m; c0 += 1)
        Stmt_for_body5(c0);
    }</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>