Transform slow LEA_B_I_D/LEA_SLOWBASE_I -> LEA_IS_D/LEA_IS iff base == index
authorNoah Goldstein <goldstein.w.n@gmail.com>
Wed, 1 Feb 2023 05:23:18 +0000 (23:23 -0600)
committerNoah Goldstein <goldstein.w.n@gmail.com>
Wed, 1 Feb 2023 07:26:06 +0000 (01:26 -0600)
commita2f45348d4ea93434d166ab9c6f73a28dba18595
tree6fec10e9804b658b2df3424f34b29eae84e4d344
parente1af75572d3a0789cf91bf06869cec69a2741b85
Transform slow LEA_B_I_D/LEA_SLOWBASE_I -> LEA_IS_D/LEA_IS iff base == index

The two 3c LEA cases:
    lea D(base, index,1)      -> lea D(,index,2)
    lea D(r13/rbp, index)     -> lea D(,r13/rbp,2) // D maybe zero

Current take 2 instructions to transform. We can do a bit better by
using LEA w.o a base if base == index and scale == 1.

Reviewed By: pengfei

Differential Revision: https://reviews.llvm.org/D141980
llvm/lib/Target/X86/X86FixupLEAs.cpp
llvm/test/CodeGen/X86/leaFixup32.mir
llvm/test/CodeGen/X86/leaFixup64.mir
llvm/test/CodeGen/X86/select-1-or-neg1.ll
llvm/test/DebugInfo/MIR/InstrRef/x86-lea-fixup-2.mir