<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 --- - VirtRegRewriter fails to set properties on BUNDLE instructions"
   href="https://llvm.org/bugs/show_bug.cgi?id=30798">30798</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>VirtRegRewriter fails to set properties on BUNDLE instructions
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Register Allocator
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>mattias.v.eriksson@ericsson.com
          </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>In my out-of-tree back-end we run the register allocator after
bundling of instructions. The register allocator handles this mostly
fine, but I think there is a bug related to imp-use on subregister
definitions:

# *** IR Dump Before Virtual Register Rewriter ***:

     BUNDLE %vreg1<imp-def>
      * %vreg1:hiAcc<def> = ...

%vreg1 is a register pair which consists of hiAcc and loAcc. It is
allocated %a32, in which %a3 is hiAcc. After register allocation
imp-use is added on the bundled instruction but not on the BUNDLE
head.

# *** IR Dump After Virtual Register Rewriter ***:

     BUNDLE %a32<imp-def>
      * %a3<def> = ... %a32<imp-use>


I think %a32<imp-use> should be added to the BUNDLE head:

     BUNDLE %a32<imp-def>, %a32<imp-use>
      * %a3<def> = ... %a32<imp-use>


The relevant code is in VirtRegRewriter::rewrite():
      // Add any missing super-register kills after rewriting the whole
      // instruction.
      while (!SuperKills.empty())
        MI->addRegisterKilled(SuperKills.pop_back_val(), TRI, true);

      while (!SuperDeads.empty())
        MI->addRegisterDead(SuperDeads.pop_back_val(), TRI, true);

      while (!SuperDefs.empty())
        MI->addRegisterDefined(SuperDefs.pop_back_val(), TRI);

Should this be updated to also add the relevant flags on the bundle
head?</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>