[PATCH] D123290: [LoongArch] Add support for selecting constant materializations.

Ray Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 7 01:43:09 PDT 2022


wangleiat created this revision.
wangleiat added reviewers: SixWeining, MaskRay, xen0n.
Herald added subscribers: StephenFan, hiraditya, mgorny.
Herald added a project: All.
wangleiat requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Integer materializing can generate LU12I_W, ORI, LU32I_D, LU52I_D and
ADDI_W instructions.

According to the sign-extended behavior of these instructions
(except ORI), the generated instruction sequence can be improved.

For example, load -1 into general register:
The ADDI_W instruction performs the operation that the [31:0] bit data
in the general register `rj` plus the 12-bit immediate `simm12` sign
extension 32-bit data; the resultant [31:0] bit is sign extension, then
written into the general register `rd`.

Normal sequence:

  lu12i.w $a0, -1
  ori $a0, $a0, 2048

Improved with sign-extended instruction:

  addi.w $a0, $zero,  -1

Change-Id: Ifd72aa1cc21f4032243d7c2ba0171767b58910eb


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D123290

Files:
  llvm/lib/Target/LoongArch/LoongArchISelDAGToDAG.cpp
  llvm/lib/Target/LoongArch/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMatInt.cpp
  llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchMatInt.h
  llvm/test/CodeGen/LoongArch/imm.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123290.421128.patch
Type: text/x-patch
Size: 145125 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220407/36735fac/attachment.bin>


More information about the llvm-commits mailing list