[PATCH] D119532: [RISCV] Extend sext.w removal pass to remove unused sign-extensions

Mohammed Nurul Hoque via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 11 02:30:07 PST 2022


mohammed-nurulhoque created this revision.
mohammed-nurulhoque added reviewers: craig.topper, asb, kito-cheng.
Herald added subscribers: VincentWu, luke957, achieveartificialintelligence, vkmr, frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya.
mohammed-nurulhoque requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead, eopXD, MaskRay.
Herald added a project: LLVM.

Current pass recursively searches **definitions** backwards to determine if a sext.w is redundant because the value is already in sign-extended form. An instruction propagates a sign-extended definition if giving it a sign-extended input yields a sign-extended output.

This patch adds recursively searching **uses** forwards to determine if bits 63:32 of sext.w result are not used, so it can be removed. An isntruction propagates sign-extended use if the lower word of its output is only dependent on the lower word of its input.

I have a pending patch dependent on this one that "fixes" other instructions (e.g. ADD -> ADDW) to make a sext.w redundant.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119532

Files:
  llvm/lib/Target/RISCV/RISCVSExtWRemoval.cpp
  llvm/test/CodeGen/RISCV/sextw-removal.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119532.407812.patch
Type: text/x-patch
Size: 7558 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220211/5c4f5bd4/attachment.bin>


More information about the llvm-commits mailing list