[LoongArch] Optimize multiplication with immediates
authorBen Shi <powerman1st@163.com>
Sun, 2 Apr 2023 08:47:37 +0000 (16:47 +0800)
committerBen Shi <powerman1st@163.com>
Mon, 3 Apr 2023 03:26:25 +0000 (11:26 +0800)
commitd88ffb0dc5af42b15864e770600f1e812b9545c1
tree6ecca1c027bcd50c2fe5d3cdc21924bc9c6e67bf
parent6e19f5b04f5836bdda523ac2f88795e8a1dc3b0e
[LoongArch] Optimize multiplication with immediates

Optimize 'x * c' to (ALSL x, (SLLI x, i0), i1) in which
c = (1 << i0) | (1 << i1).

Reviewed By: xen0n, SixWeining

Differential Revision: https://reviews.llvm.org/D147406
llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
llvm/test/CodeGen/LoongArch/alsl.ll
llvm/test/CodeGen/LoongArch/ir-instruction/mul.ll