[PATCH] D134415: [InstCombine] Improve fold icmp of truncated left shift

Chenbing.Zheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 22 00:55:28 PDT 2022


Chenbing.Zheng created this revision.
Chenbing.Zheng added reviewers: spatel, RKSimon, hasyimibhar, benshi001.
Chenbing.Zheng added a project: LLVM.
Herald added a subscriber: hiraditya.
Herald added a project: All.
Chenbing.Zheng requested review of this revision.
Herald added subscribers: llvm-commits, jacquesguan.

Original version only solve shifted constant 1, this patch expend it to PowerOf2
(trunc (2**Z << Y) to iN) == 0 -> Y u>  N - Z + 1
(trunc (2**Z << Y) to iN) != 0 -> Y u<= N - Z + 1
and
(trunc (2**Z << Y) to iN) == 2**C --> Y == C - Z
(trunc (2**Z << Y) to iN) != 2**C --> Y != C - Z


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134415

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
  llvm/test/Transforms/InstCombine/icmp-trunc.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134415.462097.patch
Type: text/x-patch
Size: 4437 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220922/1fe5b05f/attachment.bin>


More information about the llvm-commits mailing list