[PATCH] D146149: [InstCombine] Canonicalize icmp eq pow2 more thoroughly

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 15 09:11:02 PDT 2023


nikic created this revision.
nikic added reviewers: spatel, RKSimon, goldstein.w.n.
Herald added subscribers: StephenFan, JDevlieghere, hiraditya.
Herald added a project: All.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

We currently already canonicalize `icmp eq (%x & Pow2), Pow2` to `icmp ne (%x & Pow2), 0`. This patch generalizes the fold based on known bits.

In particular, this allows us to handle comparisons against `!range !{i64 0, i64 2}` loads, which addresses an optimization regression in Rust caused by https://github.com/llvm/llvm-project/commit/8df376db7282b955e7990cb8887ee9dcd3565040.


https://reviews.llvm.org/D146149

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
  llvm/test/Transforms/InstCombine/div.ll
  llvm/test/Transforms/InstCombine/icmp-range.ll
  llvm/test/Transforms/InstCombine/icmp-shl-nsw.ll
  llvm/test/Transforms/InstCombine/icmp-shr-lt-gt.ll
  llvm/test/Transforms/InstCombine/zext.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146149.505522.patch
Type: text/x-patch
Size: 5050 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230315/93522175/attachment.bin>


More information about the llvm-commits mailing list