Skip to content

vector.bitpack

vector dialect

Pack the low bits of each integer source lane into a contiguous little-endian bitstream stored in integer result lanes. Source lanes are consumed in logical lane order and width gives the number of bits taken from each source lane.

Operation contract

Property Value
Semantic phase executable
Traits Pure

Signature

Kind Name Type Cardinality Description
Operand source vector required Integer lanes whose low width bits are packed.
Result result vector required Integer storage lanes containing the packed bitstream.
Attribute width i64 required Number of low source bits consumed from each lane.

Verification constraints

  • HasIntegerElement(source)
  • HasIntegerElement(result)
  • PositiveBitWidthAttr(width)
  • ElementWidthAtLeastAttr(source, width)
  • PackedPayloadBitCountMatchesStorage(source, width, result, result)

Examples

%packed = vector.bitpack<4> %codes : vector<32xi8> -> vector<16xi8>
%packed = vector.bitpack<1> %mask : vector<128xi1> -> vector<16xi8>