[PATCH] D140509: [DAGCombiner] Pre-promote (zext (abs X)) to (abs (sext X)) when X has an illegal type.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 21 15:18:52 PST 2022


craig.topper created this revision.
craig.topper added reviewers: spatel, RKSimon, efriedma.
Herald added subscribers: StephenFan, frasercrmck, ecnelises, luismarques, apazos, sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added subscribers: pcwang-thead, MaskRay.
Herald added a project: LLVM.

Type legalization will insert a sign extend anyway. By doing it
early we can remove the zext. ComputeNumSignBits can't spot it
after type legalization because type legalization may expand
the abs to sra+xor+sub.

If the zext result type is larger than the type to be promoted to
we'll promote to a legal type and then zext the rest of the way.
If the legal type is larger than the destination type we can promote
and then truncate.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140509

Files:
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/test/CodeGen/RISCV/iabs.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140509.484700.patch
Type: text/x-patch
Size: 7537 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221221/d3d57e10/attachment.bin>


More information about the llvm-commits mailing list