[PATCH] D71660: [ValueTracking] isKnownNonZero() should take non-null-ness assumptions into consideration (PR43267)

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 18 06:37:43 PST 2019


lebedev.ri created this revision.
lebedev.ri added reviewers: spatel, jdoerfert, nikic, craig.topper.
lebedev.ri added a project: LLVM.
Herald added a subscriber: hiraditya.

It is pretty common to assume that something is not zero.
Even optimizer itself sometimes emits such assumptions
(e.g. `addAssumeNonNull()` in `PromoteMemoryToRegister.cpp`).

But we currently don't deal with such assumptions :)
The only way `isKnownNonZero()` handles assumptions is
by calling `computeKnownBits()` which calls `computeKnownBitsFromAssume()`.
But `x != 0` does not tell us anything about set bits,
it only says that there are *some* set bits.
So naturally, `KnownBits` does not get populated,
and we fail to make use of this assumption.

I propose to deal with this special case by special-casing it
via adding a `isKnownNonZeroFromAssume()` that returns boolean
when there is such an assumption.

Fixes PR43267 <https://bugs.llvm.org/show_bug.cgi?id=43267>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71660

Files:
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/test/Transforms/InstCombine/assume.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71660.234529.patch
Type: text/x-patch
Size: 5080 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191218/560a868b/attachment.bin>


More information about the llvm-commits mailing list