[PATCH] D104581: Add DAG combine to detect opportunities to replace (i64 (any_extend (i32 X)) with sign_extend.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 18 16:53:49 PDT 2021


craig.topper created this revision.
craig.topper added reviewers: luismarques, frasercrmck, evandro, asb, khchen, HsiangKai, arcbbb.
Herald added subscribers: StephenFan, apazos, sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya.
craig.topper requested review of this revision.
Herald added a subscriber: MaskRay.
Herald added a project: LLVM.

If type legalization is going to insert a sign_extend for other users
of X and we can fold the sign_extend into ADDW/MULW/SUBW, it is
better to replace the ANY_EXTEND so we don't end up with a separate
ADD/MUL/SUB instruction for the users of the ANY_EXTEND.

I'm only handling setcc uses right now, but there are other
instructions that force sign_extends like ashr.

There are probably other *W instructions we could use in addition
to ADDW/SUBW/MULW.

My motivating case was a loop terminating compare and a phi use
as seen in the new test file.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104581

Files:
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/test/CodeGen/RISCV/aext-to-sext.ll
  llvm/test/CodeGen/RISCV/rv64zbb.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104581.353129.patch
Type: text/x-patch
Size: 6051 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210618/e27cbc99/attachment.bin>


More information about the llvm-commits mailing list