[PATCH] D105764: [InstCombine] Fold ashr(or(neg(x),x),bw-1) --> sext(icmp_ne(x,0)) (PR50816)

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 10 13:54:34 PDT 2021


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

Handle the missing fold reported in PR50816, which is a variant of the existing ashr(sub_nsw(X,Y),bw-1) --> sext(icmp_sgt(X,Y)) fold.

At the moment we allow other uses of the neg(x) (as this is likely to let us further simplify other uses of the neg), but not multi uses of the or() which would increase instruction count.

I've added the test cases in the review, but I'll pre-commit if accepted.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105764

Files:
  llvm/lib/Transforms/InstCombine/InstCombineShifts.cpp
  llvm/test/Transforms/InstCombine/sub-ashr-or-to-icmp-select.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105764.357750.patch
Type: text/x-patch
Size: 4631 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210710/908ddb32/attachment.bin>


More information about the llvm-commits mailing list