[PATCH] D142830: [ValueTracking] Improve non-zero tracking of `X` by also searching through `Use(X)` that imply non-zero

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 28 20:58:36 PST 2023


goldstein.w.n created this revision.
Herald added a subscriber: 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.

We currently are able to prove `X` is non-zero if there are dominating
compares or assumes directly on `X`, but we can do a bit better and
also check `uses` of `X` s.t `Use(X) != 0` implies `X != 0`.

For example if we have `assume(X & Y != 0)`, we know `X != 0`.
Likewise if we have a dominating condition:

  if(X & Y != 0)
    {
      // X is known zero here
    }

Currently implemented to track through:

- X&Y            -- https://alive2.llvm.org/ce/z/zdkf-x
- 0-X            -- https://alive2.llvm.org/ce/z/yvEAZx
- bitreverse(X)  -- https://alive2.llvm.org/ce/z/zEPy9z
- bswap(X)       -- https://alive2.llvm.org/ce/z/i_li18
- ctpop(X)       -- https://alive2.llvm.org/ce/z/fXMDTs
- abs(X)         -- https://alive2.llvm.org/ce/z/EbP82g https://alive2.llvm.org/ce/z/hfzZuX


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142830

Files:
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/test/Analysis/ValueTracking/known-non-zero-through-dom-use.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D142830.493063.patch
Type: text/x-patch
Size: 11860 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230129/ce7b2c25/attachment.bin>


More information about the llvm-commits mailing list