[AArch64] Lower multiplication by a constant int to madd
authorzhongyunde <zhongyunde@huawei.com>
Fri, 7 Oct 2022 11:31:48 +0000 (19:31 +0800)
committerzhongyunde <zhongyunde@huawei.com>
Fri, 7 Oct 2022 11:33:47 +0000 (19:33 +0800)
commit75358f060c099c9a290cea43eb15f872ab7f2343
treef9d417ef73aab2695468cdffdce876fcc77d0215
parentd85f6e5d57f38f0cbbc756484e3a93ae89b11195
[AArch64] Lower multiplication by a constant int to madd

Lower a = b * C -1 into madd
  a) instcombine change b * C -1 --> b * C + (-1)
  b) machine-combine change b * C + (-1) --> madd

Assembler will transform the neg immedate of sub to add, see https://gcc.godbolt.org/z/cTcxePPf4
Fixes AArch64 part of https://github.com/llvm/llvm-project/issues/57255.

Reviewed By: efriedma
Differential Revision: https://reviews.llvm.org/D134336
llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
llvm/test/CodeGen/AArch64/addimm-mulimm.ll
llvm/test/CodeGen/AArch64/machine-outliner-throw.ll
llvm/test/CodeGen/AArch64/madd-combiner.ll
llvm/test/CodeGen/AArch64/mul_pow2.ll
llvm/test/CodeGen/AArch64/srem-seteq.ll
llvm/test/CodeGen/AArch64/urem-seteq-nonzero.ll