[PATCH] D109155: [InstCombine] Fold BW/2+1 tops bits are same pattern

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 2 06:57:44 PDT 2021


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

Match icmp eq (trunc (lsr A, BW), (ashr (trunc A), BW-1)), which checks the top BW/2 + 1 bits are all the same. Create "A >s INT_MIN && A <s INT_MAX", which we generate as "icmp ult (add A, 2^BW-1), 2^BW" to skip a few steps of instcombining.
https://alive2.llvm.org/ce/z/NjH6Ty


https://reviews.llvm.org/D109155

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
  llvm/test/Transforms/InstCombine/icmp-topbitssame.ll
  llvm/test/Transforms/InstCombine/truncating-saturate.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109155.370250.patch
Type: text/x-patch
Size: 16236 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210902/e974576a/attachment.bin>


More information about the llvm-commits mailing list