[LoongArch] Make use of addu16i.d for adds with suitable immediates
authorWANG Xuerui <git@xen0n.name>
Tue, 14 Feb 2023 00:39:19 +0000 (08:39 +0800)
committerWeining Lu <luweining@loongson.cn>
Wed, 15 Feb 2023 01:16:14 +0000 (09:16 +0800)
commit2b8cb7d87fcb7c93ea4e60bed6185f05308c98f1
tree00005dba085e8750dcd64522dd819334b2834c03
parentdcf9c60a538c03628656e5b13fac9a913bcd922f
[LoongArch] Make use of addu16i.d for adds with suitable immediates

Ideally `addu16i.d` could be paired with `{ld,st}ptr` for faster memory
accesses with 32-bit-aligned offsets (it was designed for this purpose),
but it would require more work and the original use case (GP-relative
accesses) does not exist any more with the current LoongArch psABI.

It could still be used for accelerating additions of certain constants
though, which is what this patch intends to do.

Reviewed By: SixWeining, gonglingqin

Differential Revision: https://reviews.llvm.org/D143710
llvm/lib/Target/LoongArch/LoongArchInstrInfo.td
llvm/test/CodeGen/LoongArch/ir-instruction/add.ll