[PATCH] D95235: [InstCombine] narrow abs with sign-extended input

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 22 07:16:43 PST 2021


spatel created this revision.
spatel added reviewers: nikic, xbolva00, lebedev.ri, RKSimon.
Herald added subscribers: hiraditya, mcrosier.
spatel requested review of this revision.
Herald added a project: LLVM.

In the motivating cases from https://llvm.org/PR48816 , we have a trailing `trunc`. But that is not required to reduce the abs width:
https://alive2.llvm.org/ce/z/ECaz-p
...as long as we clear the int-min-is-poison bit (`nsw`).

We have some existing tests that are affected, and I'm not sure what the overall implications are, but in general I think we favor narrowing operations over preserving nsw/nuw. If not, we could restrict this transform based on type (shouldChangeType() and/or vector vs. scalar).


https://reviews.llvm.org/D95235

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/test/Transforms/InstCombine/abs-1.ll
  llvm/test/Transforms/InstCombine/abs-intrinsic.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95235.318515.patch
Type: text/x-patch
Size: 4404 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210122/a2810680/attachment.bin>


More information about the llvm-commits mailing list