<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 --- - [AArch64] r226200 can emit illegal thumb2 instruction: &quot;sub sp, r12, #80&quot;" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_bugs_show-5Fbug.cgi-3Fid-3D23772&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=zcyh0vJRfD4XaDEoTq8YHIIUthWcZQ_94FLN1bsUTfk&s=WaDi5oQLERTxmhJ0tbxG1P1tEbm9AqopoaolI7rbXek&e=">23772</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[AArch64] r226200 can emit illegal thumb2 instruction: "sub sp, r12, #80"
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

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

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

        <tr>
          <th>CC</th>
          <td>apazos@codeaurora.org, hfinkel@anl.gov, llvmbugs@cs.uiuc.edu, mcrosier@codeaurora.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>r226200 allows coalescing into SP but missed a corner case:

  %vreg907<def> = COPY %SP; GPRnopc:%vreg907
  %vreg908<def> = t2SUBri %vreg907, 80, pred:14, pred:%noreg, opt:%noreg;
GPRnopc:%vreg908,%vreg907
  %SP<def> = COPY %vreg908; GPRnopc:%vreg908

When %vreg908 is coalesced into SP but %vreg907 is not, it's likely to emit an
illegal instruction:

        sub sp, r12, #80

In Thumb2, we can only use SP as Rd if and only if Rn is also SP. This patch,
when trying remove "%SP<def> = COPY %vreg908", checks if %vreg907 is SP
already. If not, be conservative and do not coalesce %vreg908 into SP.

<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D10287&d=AwMBaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=pF93YEPyB-J_PERP4DUZOJDzFVX5ZQ57vQk33wu0vio&m=zcyh0vJRfD4XaDEoTq8YHIIUthWcZQ_94FLN1bsUTfk&s=9YTGUt9IB7ZmBwKhRP7jnYMsCGOosLvW53SUYnm23pw&e=">http://reviews.llvm.org/D10287</a></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>