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

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 8 01:00:13 PDT 2020


aqjune added inline comments.


================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:1800
     break;
+  case Instruction::Freeze:
+    if (isGuaranteedNotToBeUndefOrPoison(I->getOperand(0), true, Q.CxtI, Q.DT))
----------------
nikic wrote:
> aqjune wrote:
> > reames wrote:
> > > I don't think this is worth adding.  Such a freeze is trivial, and I'd expect the optimizer to simply remove it instead.
> > KnownBits analysis on freeze can be done when the operand is partially undef. (isGuaranteedNotToBePoison vs. isGuaranteedNotToBeUndefOrPoison)
> And we can do that because "computeKnownBits" provides a "KnownBits or poison" result and not a "KnownBits or undef/poison" result, right?
Yes, that's true. Take this example:
```
y = or i8 x, 1
y.fr = freeze y
```

The current implementation of `computeKnownBits(y)` will answer that the LSB of `y` is one, and this means that  `y` is either poison or any value. `y` can be poison because `or poison, 1` is poison. However, `y` cannot be full undef because `or x, 1` cannot return full undef.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75808/new/

https://reviews.llvm.org/D75808



More information about the llvm-commits mailing list