[PATCH] D130433: [InstCombine] Add fold for redundant sign bits count comparison

Alexander Shaposhnikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 23 17:50:49 PDT 2022


alexander-shaposhnikov created this revision.
alexander-shaposhnikov added reviewers: nikic, majnemer, craig.topper.
alexander-shaposhnikov created this object with visibility "All Users".
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
alexander-shaposhnikov requested review of this revision.
Herald added a project: LLVM.

Fold ult (xor X, (ashr X, C2)), C1 <https://reviews.llvm.org/C1> for particular values of C1 <https://reviews.llvm.org/C1>, C2, 
more specifically if  C2 is equal to BitWidth - K and C1 <https://reviews.llvm.org/C1> Is equal to 2^{K + 1}
then this comparison is equivalent to (X + 2^{K + 1} < 2^{K + 2}) to see this 
one may notice that this is equivalent to "higher BitWidth - K bits of X are identical".

Test plan:

0/ ninja check-llvm check-clang + bootstrap LLVM/Clang
1/ alive proofs for the tests: https://alive2.llvm.org/ce/z/opxNMm  https://alive2.llvm.org/ce/z/VfZoLM
2/ alive proof for the general case - WIP, will post it here.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D130433

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
  llvm/lib/Transforms/InstCombine/InstCombineInternal.h
  llvm/test/Transforms/InstCombine/icmp.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130433.447101.patch
Type: text/x-patch
Size: 7292 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220724/6a6faddf/attachment.bin>


More information about the llvm-commits mailing list