<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 - Pre-RA Machine LICM illegally hoists div"
   href="https://bugs.llvm.org/show_bug.cgi?id=34807">34807</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Pre-RA Machine LICM illegally hoists div
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>llc
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>Alberto.Magni@microsoft.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, nunoplopes@sapo.pt
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=19216" name="attach_19216" title="Repro files">attachment 19216</a> <a href="attachment.cgi?id=19216&action=edit" title="Repro files">[details]</a></span>
Repro files

The attached .c file shows an issue with Machine LICM that causes the division
in the loop to be hoisted unconditionally outside of the loop for the aarch64
target.

The .mir file in the package has been obtained from the .c file with this
command:

clang -mllvm -stop-before=machinelicm -target aarch64-- -O2 -S licm_udiv.c -o
before_licm.mir

To reproduce the hoisting:

llc -debug -mtriple=aarch64-- -run-pass=machinelicm  before_licm.mir -o -

The debug output shows that the UDIV instruction is hoisted:
Hoist non-reg-pressure: %vreg13<def> = UDIVXr %vreg7, %vreg6;
GPR64:%vreg13,%vreg7,%vreg6

Notice that the same issue does not show up for x86_64.
This is because for x86_64 in IsProfitableToHoist we actually reach the
invocation of IsGuaranteedToExecute, which returns false for the block that
contains the division.</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>