[PATCH] D157755: [InstSimplify] Use knownbits for simplifying `(icmp ugt/ule (or X, Y), X)`; PR64610

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 11 13:19:33 PDT 2023


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

`(icmp ule (or X, Y), X)`

  If there are any unique bits between `X` and `Y`
  --> false

`(icmp ugt (or X, Y), X)`

  If there are any unique bits between `X` and `Y`
  --> true

Proofs: https://alive2.llvm.org/ce/z/igZM4Q

This patch doesn't add any functionality that was previously missing
in LLVM, it just add a bit more to InstructionSimplify.

The rationale is InstCombine can produce `(icmp (or X, Y), X)`
relatively late in the pipeline (after the other passes that would
normally simplify this well have run), leading to missed
optimizations: https://github.com/llvm/llvm-project/issues/64610


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D157755

Files:
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/test/Transforms/InstSimplify/icmp-orx-x.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157755.549510.patch
Type: text/x-patch
Size: 4611 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230811/ba015612/attachment.bin>


More information about the llvm-commits mailing list