[PATCH] D104472: [ValueTracking] look through bitcast of vector in computeKnownBits

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 17 12:09:34 PDT 2021


spatel added a comment.

In D104472#2825125 <https://reviews.llvm.org/D104472#2825125>, @lebedev.ri wrote:

> Would it please be possible to either enhance comments, or port more comments from the `SelectionDAG::computeKnownBits()`?
> It appears to match that original implementation, and seems correct, but it is hard to read/get through.

I thought I had improved the original code comments, but it might have made it worse.

The tricky part is the calling of computeKnownBits with the shifting demanded elements vector.
The original says this:

  // Collect known bits for the (larger) output by collecting the known
  // bits from each set of sub elements and shift these into place.
  // We need to separately call computeKnownBits for each set of
  // sub elements as the knownbits for each is likely to be different.

Is this better or worse?

  // Known bits are automatically intersected across demanded
  // elements of a vector. So for example, if a bit is computed as 
  // known zero, it must be zero across all demanded elements 
  // of the vector. 
  //
  // For this bitcast, each demanded element of the output is 
  // sub-divided across a set of smaller vector elements in the 
  // source vector. To get the known bits for an entire element 
  // of the output, compute the known bits for each sub-element 
  // sequentially. This is done by shifting the one-set-bit demanded 
  // elements parameter across the sub-elements for consecutive
  // calls to computeKnownBits.
  //
  // The known bits of each sub-element are then extended
  // and shifted into place (dependent on endian) to form the
  // full result of known bits.
   


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

https://reviews.llvm.org/D104472



More information about the llvm-commits mailing list