[PATCH] D82262: [RISCV] Optimize addition with an immediate

Ben Shi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 20 10:02:28 PDT 2020


benshi001 created this revision.
benshi001 added reviewers: asb, MaskRay.
Herald added subscribers: llvm-commits, evandro, luismarques, apazos, sameer.abuasal, pzheng, s.egerton, lenary, Jim, benna, psnobl, jocewei, PkmX, rkruppe, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya.
Herald added a project: LLVM.
benshi001 added a comment.

for (add i32 %a, 4094), it can be simplfied to
addi a0, a0, 2047
addi a0, a0, 2047.

The original assembly is
lui a1, 1
addi a1, a1, -2
add a0, a0, a1

However, this optimization can only be performed if the value generated by lui-addi has no other use.


benshi001 added a comment.

My information,

name = Ben Shi
email = powerman1st at 163.com


For some additions with an immediate in specific ranges, a pair of
addi-addi can be generated instead of the ordinary lui-addi-add serial.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82262

Files:
  llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
  llvm/test/CodeGen/RISCV/add-imm.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82262.272262.patch
Type: text/x-patch
Size: 4932 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200620/d5e28dd2/attachment-0001.bin>


More information about the llvm-commits mailing list