<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 - RegisterCoalescer fails to track lanes properly when speculating ErasableImplicitDef"
   href="https://bugs.llvm.org/show_bug.cgi?id=39602">39602</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>RegisterCoalescer fails to track lanes properly when speculating ErasableImplicitDef
          </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>Register Allocator
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>Matthew.Arsenault@amd.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, quentin.colombet@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=21105" name="attach_21105" title="Reduced testcase">attachment 21105</a> <a href="attachment.cgi?id=21105&action=edit" title="Reduced testcase">[details]</a></span>
Reduced testcase

The attached testcase fails with "Couldn't join subrange!" due to the special
handling of implicit_defs. If you replace the IMPLICIT_DEF with a meaningful
value (e.g. S_MOV_B32 -1), it works.

When it assumes it's erasable, it clears out the valid lane set by the
IMPLICIT_DEF in another block
(<a href="https://github.com/llvm-mirror/llvm/blob/master/lib/CodeGen/RegisterCoalescer.cpp#L2505">https://github.com/llvm-mirror/llvm/blob/master/lib/CodeGen/RegisterCoalescer.cpp#L2505</a>
). This isn't restored when later it's decided the implicit_def isn't really
erasable, resulting in an inconsistent ConflictResolution result. Removing this
clearing entirely works, but breaks testcases where the implicit_def really
should be removed. The cleared lanes are needed to do the rest of the checks in
analyzeValue.


I'm not sure the correct way to fix this. I've tried inserting side tracking of
the original valid lanes, but it doesn't really work. It seems like most of the
work done in analyzeValue should really be done in resolveConflicts when
everything should be known, and I'm not sure why these are split the way they
are currently. I'm also unconvinced this special handling of implicit_def is
worth the complexity. It seems pretty fragile (<a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Could not join subrange in testcase with no meaningful values"
   href="show_bug.cgi?id=39542">bug 39542</a> was derived from the
same testcase), so maybe either implicit_def should always be left, or the
cross block restriction removed?</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>