[PATCH] D75808: [ValueTracking] isKnownNonZero, computeKnownBits for freeze

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 7 09:08:21 PST 2020


aqjune created this revision.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
aqjune updated this revision to Diff 248936.
aqjune added a comment.
aqjune added reviewers: reames, lebedev.ri, spatel, jdoerfert, nlopes.

Consider alloca/undef too, minor update


This implements support for isKnownNonZero, computeKnownBits when freeze is involved.

    br (x != 0), BB1, BB2
  BB1:
    y = freeze x

In the above program, we can say that y is non-zero. The reason is as follows:

(1) If x was poison, `br (x != 0)` raised UB
(2) If x was fully undef, the branch again raised UB
(3) If x was non-zero partially undef, say `undef | 1`, `freeze x` will return a nondeterministic value which is also non-zero.
(4) If x was just a concrete value, it is trivial

In addition to the value tracking support, small enhancement was made to isGuaranteedNotToBeUndefOrPoison so it considers ConstantFP/Function/BitCastInst/etc too.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75808

Files:
  llvm/include/llvm/Analysis/ValueTracking.h
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/test/Transforms/InstSimplify/freeze.ll
  llvm/test/Transforms/InstSimplify/known-non-zero.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75808.248936.patch
Type: text/x-patch
Size: 9290 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200307/59423ce8/attachment.bin>


More information about the llvm-commits mailing list