[AArch64][SelectionDAG] Lower multiplication by a constant to shl+add+shl+add
authorzhongyunde <zhongyunde@huawei.com>
Thu, 20 Oct 2022 16:33:28 +0000 (00:33 +0800)
committerzhongyunde <zhongyunde@huawei.com>
Thu, 20 Oct 2022 16:33:49 +0000 (00:33 +0800)
commit74c2d4f6024c8f160871a2baa928d0b42415f183
tree3c2b4b16905b5b5e74324717a5e8da2f4fac8985
parent7e04c0ad632527df0a4c4d34a6ac6ec6a3888dfe
[AArch64][SelectionDAG] Lower multiplication by a constant to shl+add+shl+add

Change the costmodel to lower a = b * C where C = (1 + 2^m) * (1 + 2^n) to
      add   w8, w0, w0, lsl #m
      add   w0, w8, w8, lsl #n
Note: The latency can vary depending on the shirt amount

Reviewed By: efriedma, dmgreen
Differential Revision: https://reviews.llvm.org/D135441
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/test/CodeGen/AArch64/mul_pow2.ll