[PATCH] D136470: Allow scalable vectors in computeKnownBits

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 24 13:31:52 PDT 2022


efriedma added inline comments.


================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:1840
     // Early out if the index is non-constant or out-of-range.
     unsigned NumElts = DemandedElts.getBitWidth();
     if (!CIdx || CIdx->getValue().uge(NumElts)) {
----------------
reames wrote:
> efriedma wrote:
> > I guess this is a more general thing, but does it make sense to analyze insertelement even if we can't figure out which element is being inserted?
> I'd had this same thought, and in fact was working on a patch for that locally.  This turns out to be a bit trickier than it seems as the unknown index can be out of bounds.  As a result, the resulting vector could be entirely poison.  In demanded bits, we seem to try not inferring bits of potentially undef values, and I think poison needs treated the same.  
Inferring bits in a poison value shouldn't be an issue.  Since it's poison, the entire value is meaningless.  (If it didn't work this way, we wouldn't be able to compute known bits at all without proving a value isn't poison.)

The issue with undef is just that we can't infer 1 or 0 for a bit we know is undef, because it could be both.  (This sort of difficult reasoning is one of the reasons we're trying to move away from undef...)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136470



More information about the llvm-commits mailing list