<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 - Miscompile with "[X86FixupLEAs] Transform the sequence LEA/SUB to SUB/SUB""
   href="https://bugs.llvm.org/show_bug.cgi?id=50615">50615</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Miscompile with "[X86FixupLEAs] Transform the sequence LEA/SUB to SUB/SUB"
          </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>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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>max.kazantsev@azul.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24925" name="attach_24925" title="Resulting assembly (good and bad)">attachment 24925</a> <a href="attachment.cgi?id=24925&action=edit" title="Resulting assembly (good and bad)">[details]</a></span>
Resulting assembly (good and bad)

The miscompile is caused by the following patch:

commit 1b748faf2bae246e2fc77d88420df13c2e60f4df
Author: Guozhi Wei <<a href="mailto:carrot@google.com">carrot@google.com</a>>
Date:   Tue Jun 1 10:31:30 2021 -0700

    [X86FixupLEAs] Transform the sequence LEA/SUB to SUB/SUB

    This patch transforms the sequence

        lea (reg1, reg2), reg3
        sub reg3, reg4

    to two sub instructions

        sub reg1, reg4
        sub reg2, reg4

    Similar optimization can also be applied to LEA/ADD sequence.
    The modifications to TwoAddressInstructionPass is to ensure the operands of
ADD
    instruction has expected order (the dest register of LEA should be src
register of ADD).

    Differential Revision: <a href="https://reviews.llvm.org/D101970">https://reviews.llvm.org/D101970</a>


The prior revision of this patch was reverted due to a miscompile. We are sill
observing a miscompile, original test is written in Java and I could not easily
make a C++ repro. In attachment - resulting assembly for bad (current trunk)
and good (with the problematic patch reverted) cases, and llc logs with
-print-after-all/print-before-all for each of them</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>