<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - LegacyDivergenceAnalysis: sync dependence misses some divergent uses outside a loop"
   href="https://bugs.llvm.org/show_bug.cgi?id=42741">42741</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>LegacyDivergenceAnalysis: sync dependence misses some divergent uses outside a loop
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

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

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

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Global Analyses
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>jay.foad@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=22281" name="attach_22281" title="test case">attachment 22281</a> <a href="attachment.cgi?id=22281&action=edit" title="test case">[details]</a></span>
test case

See the attached test case,
test/Analysis/LegacyDivergenceAnalysis/AMDGPU/syncbug.ll.

%tmp7 is divergent because it's sync-dependent on the divergent loop exit
condition %tmp5, but LegacyDivergenceAnalysis does not mark it as divergent.

Quoting from LegacyDivergenceAnalysis.cpp:

  // Propagation rule 2: if a value defined in a loop is used outside, the user
  // is sync dependent on the condition of the loop exits that dominate the
  // user. For example,

OK.

  // The algorithm used here handles both natural and unstructured loops. 
Given
  // a branch TI, we first compute its influence region, the union of all
simple
  // paths from TI to its immediate post dominator (IPostDom). Then, we search
  // for all the values defined in the influence region but used outside. All
  // these users are sync dependent on TI.

This algorithm doesn't appear to work. The influence region includes all blocks
from bb2 to bb8, so %tmp7 is never marked divergent by this algorithm because
it is not outside the influence region.

This might be related to 37185.</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>