[PATCH] D136470: Allow scalable vectors in computeKnownBits

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 24 13:24:29 PDT 2022


reames 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)) {
----------------
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.  


================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:1874
     auto *CIdx = dyn_cast<ConstantInt>(Idx);
     if (isa<ScalableVectorType>(Vec->getType())) {
       // FIXME: there's probably *something* we can do with scalable vectors
----------------
efriedma wrote:
> Duplicate ScalableVectorType check?
> 
> Does it make sense to analyze the vector operand without trying to figure out which elt is demanded?
Yep, looks like it's redundant, will remove.

Same point as above about poison/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