[llvm-bugs] [Bug 50615] New: Miscompile with "[X86FixupLEAs] Transform the sequence LEA/SUB to SUB/SUB"

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jun 8 01:40:31 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50615

            Bug ID: 50615
           Summary: Miscompile with "[X86FixupLEAs] Transform the sequence
                    LEA/SUB to SUB/SUB"
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: max.kazantsev at azul.com
                CC: htmldeveloper at gmail.com, llvm-bugs at lists.llvm.org

Created attachment 24925
  --> https://bugs.llvm.org/attachment.cgi?id=24925&action=edit
Resulting assembly (good and bad)

The miscompile is caused by the following patch:

commit 1b748faf2bae246e2fc77d88420df13c2e60f4df
Author: Guozhi Wei <carrot at google.com>
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: https://reviews.llvm.org/D101970


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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210608/0b256753/attachment-0001.html>


More information about the llvm-bugs mailing list