[PATCH] D104684: [X86FixupLEAs] Try again to transform the sequence LEA/SUB to SUB/SUB

Guozhi Wei via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 21 20:52:34 PDT 2021


Carrot created this revision.
Carrot added reviewers: craig.topper, spatel, RKSimon, lebedev.ri, nikic, fhahn.
Herald added subscribers: mstorsjo, pengfei, hiraditya.
Carrot requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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).

Now it handles the killed operands between LEA/SUB instructions, so it can fix the verification failure when compiling @fhahn's code (test10).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104684

Files:
  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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104684.353543.patch
Type: text/x-patch
Size: 29206 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210622/91049eb0/attachment.bin>


More information about the llvm-commits mailing list