[RISCV] Teach RISCVMergeBaseOffset about cases where we use SHXADD to add some immedi...
authorCraig Topper <craig.topper@sifive.com>
Thu, 9 Jun 2022 22:48:21 +0000 (15:48 -0700)
committerCraig Topper <craig.topper@sifive.com>
Thu, 9 Jun 2022 23:07:35 +0000 (16:07 -0700)
commit8bbcb988481c4b072e5f545ef222078ff2a8df3b
tree8ee3f5440d12a37b8f1ea9f882964e32ce3a52f7
parentf1182bd6d538847acac58316e794f5b60bc3c89a
[RISCV] Teach RISCVMergeBaseOffset about cases where we use SHXADD to add some immediates.

For an addition with simm14 and simm15 immediates with 2 or 3 trailing bits,
we can use a shXadd instruction and an addi to do the addition.

This patch teaches RISCVMergeBaseOffset to see through this pattern.
I don't think the sh1add case occurs because we use two addis for that,
but I implemented it for completeness.

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D127376
llvm/lib/Target/RISCV/RISCVMergeBaseOffset.cpp
llvm/test/CodeGen/RISCV/hoist-global-addr-base.ll