[X86FixupLEAs] Try again to transform the sequence LEA/SUB to SUB/SUB
authorGuozhi Wei <carrot@google.com>
Fri, 16 Jul 2021 17:16:03 +0000 (10:16 -0700)
committerGuozhi Wei <carrot@google.com>
Fri, 16 Jul 2021 17:16:03 +0000 (10:16 -0700)
commit5609c8b60730519eeb7bc95b61d2c09879dff44b
tree74d7e8a876a2b94ab437104e3db046ab3207843d
parent6dad7a51f8b60a6691ec75fcb753bb51bd145068
[X86FixupLEAs] Try again to 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/D104684
llvm/include/llvm/CodeGen/TargetInstrInfo.h
llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
llvm/lib/Target/X86/X86FixupLEAs.cpp
llvm/lib/Target/X86/X86InstrInfo.cpp
llvm/lib/Target/X86/X86InstrInfo.h
llvm/test/CodeGen/X86/2009-03-23-MultiUseSched.ll
llvm/test/CodeGen/X86/lea-opt2.ll
llvm/test/CodeGen/X86/vp2intersect_multiple_pairs.ll