class ShuffleVectorInst

Declaration

class ShuffleVectorInst : public Instruction { /* full declaration omitted */ };

Description

This instruction constructs a fixed permutation of two input vectors. For each element of the result vector, the shuffle mask selects an element from one of the input vectors to copy to the result. Non-negative elements in the mask represent an index into the concatenated pair of input vectors. UndefMaskElem (-1) specifies that the result element is undefined. For scalable vectors, all the elements of the mask must be 0 or -1. This requirement may be relaxed in the future.

Declared at: llvm/include/llvm/IR/Instructions.h:2008

Inherits from: Instruction

Member Variables

private SmallVector<int, 4> ShuffleMask
private llvm::Constant* ShuffleMaskForBitcode

Inherited from Value:

protected SubclassOptionalData
protected NumUserOperands
protected IsUsedByMD
protected HasName
protected HasMetadata
protected HasHungOffUses
protected HasDescriptor
public static MaxAlignmentExponent = 32
public static MaximumAlignment = 1ULL << MaxAlignmentExponent

Method Overview

Inherited from Instruction:

Inherited from User:

Inherited from Value:

Methods

ShuffleVectorInst(
    llvm::Value* V1,
    llvm::Value* Mask,
    const llvm::Twine& NameStr = "",
    llvm::Instruction* InsertBefore = nullptr)

Declared at: llvm/include/llvm/IR/Instructions.h:2019

Parameters

llvm::Value* V1
llvm::Value* Mask
const llvm::Twine& NameStr = ""
llvm::Instruction* InsertBefore = nullptr

ShuffleVectorInst(llvm::Value* V1,
                  llvm::Value* Mask,
                  const llvm::Twine& NameStr,
                  llvm::BasicBlock* InsertAtEnd)

Declared at: llvm/include/llvm/IR/Instructions.h:2021

Parameters

llvm::Value* V1
llvm::Value* Mask
const llvm::Twine& NameStr
llvm::BasicBlock* InsertAtEnd

ShuffleVectorInst(
    llvm::Value* V1,
    ArrayRef<int> Mask,
    const llvm::Twine& NameStr = "",
    llvm::Instruction* InsertBefore = nullptr)

Declared at: llvm/include/llvm/IR/Instructions.h:2023

Parameters

llvm::Value* V1
ArrayRef<int> Mask
const llvm::Twine& NameStr = ""
llvm::Instruction* InsertBefore = nullptr

ShuffleVectorInst(llvm::Value* V1,
                  ArrayRef<int> Mask,
                  const llvm::Twine& NameStr,
                  llvm::BasicBlock* InsertAtEnd)

Declared at: llvm/include/llvm/IR/Instructions.h:2025

Parameters

llvm::Value* V1
ArrayRef<int> Mask
const llvm::Twine& NameStr
llvm::BasicBlock* InsertAtEnd

ShuffleVectorInst(
    llvm::Value* V1,
    llvm::Value* V2,
    llvm::Value* Mask,
    const llvm::Twine& NameStr = "",
    llvm::Instruction* InsertBefor = nullptr)

Declared at: llvm/include/llvm/IR/Instructions.h:2027

Parameters

llvm::Value* V1
llvm::Value* V2
llvm::Value* Mask
const llvm::Twine& NameStr = ""
llvm::Instruction* InsertBefor = nullptr

ShuffleVectorInst(llvm::Value* V1,
                  llvm::Value* V2,
                  llvm::Value* Mask,
                  const llvm::Twine& NameStr,
                  llvm::BasicBlock* InsertAtEnd)

Declared at: llvm/include/llvm/IR/Instructions.h:2030

Parameters

llvm::Value* V1
llvm::Value* V2
llvm::Value* Mask
const llvm::Twine& NameStr
llvm::BasicBlock* InsertAtEnd

ShuffleVectorInst(
    llvm::Value* V1,
    llvm::Value* V2,
    ArrayRef<int> Mask,
    const llvm::Twine& NameStr = "",
    llvm::Instruction* InsertBefor = nullptr)

Declared at: llvm/include/llvm/IR/Instructions.h:2032

Parameters

llvm::Value* V1
llvm::Value* V2
ArrayRef<int> Mask
const llvm::Twine& NameStr = ""
llvm::Instruction* InsertBefor = nullptr

ShuffleVectorInst(llvm::Value* V1,
                  llvm::Value* V2,
                  ArrayRef<int> Mask,
                  const llvm::Twine& NameStr,
                  llvm::BasicBlock* InsertAtEnd)

Declared at: llvm/include/llvm/IR/Instructions.h:2035

Parameters

llvm::Value* V1
llvm::Value* V2
ArrayRef<int> Mask
const llvm::Twine& NameStr
llvm::BasicBlock* InsertAtEnd

bool changesLength() const

Description

Return true if this shuffle returns a vector with a different number of elements than its source vectors. Examples: shufflevector < 4 x n> A, < 4 x n> B, < 1,2,3> shufflevector < 4 x n> A, < 4 x n> B, < 1,2,3,4,5>

Declared at: llvm/include/llvm/IR/Instructions.h:2093

static bool classof(const llvm::Value* V)

Declared at: llvm/include/llvm/IR/Instructions.h:2393

Parameters

const llvm::Value* V

static bool classof(const llvm::Instruction* I)

Declared at: llvm/include/llvm/IR/Instructions.h:2390

Parameters

const llvm::Instruction* I

llvm::ShuffleVectorInst* cloneImpl() const

Declared at: llvm/include/llvm/IR/Instructions.h:2016

void commute()

Description

Swap the operands and adjust the mask to preserve the semantics of the instruction.

Declared at: llvm/include/llvm/IR/Instructions.h:2043

static void commuteShuffleMask(
    MutableArrayRef<int> Mask,
    unsigned int InVecNumElts)

Description

Change values in a shuffle permute mask assuming the two vector operands of length InVecNumElts have swapped position.

Declared at: llvm/include/llvm/IR/Instructions.h:2378

Parameters

MutableArrayRef<int> Mask
unsigned int InVecNumElts

static llvm::Constant*
convertShuffleMaskForBitcode(ArrayRef<int> Mask,
                             llvm::Type* ResultTy)

Declared at: llvm/include/llvm/IR/Instructions.h:2082

Parameters

ArrayRef<int> Mask
llvm::Type* ResultTy

int getMaskValue(unsigned int Elt) const

Description

Return the shuffle mask value of this instruction for the given element index. Return UndefMaskElem if the element is undef.

Declared at: llvm/include/llvm/IR/Instructions.h:2063

Parameters

unsigned int Elt

static void getShuffleMask(
    const llvm::Constant* Mask,
    SmallVectorImpl<int>& Result)

Description

Convert the input shuffle mask operand to a vector of integers. Undefined elements of the mask are returned as UndefMaskElem.

Declared at: llvm/include/llvm/IR/Instructions.h:2067

Parameters

const llvm::Constant* Mask
SmallVectorImpl<int>& Result

void getShuffleMask(
    SmallVectorImpl<int>& Result) const

Description

Return the mask for this instruction as a vector of integers. Undefined elements of the mask are returned as UndefMaskElem.

Declared at: llvm/include/llvm/IR/Instructions.h:2072

Parameters

SmallVectorImpl<int>& Result

ArrayRef<int> getShuffleMask() const

Declared at: llvm/include/llvm/IR/Instructions.h:2087

llvm::Constant* getShuffleMaskForBitcode() const

Description

Return the mask for this instruction, for use in bitcode. TODO: This is temporary until we decide a new bitcode encoding for shufflevector.

Declared at: llvm/include/llvm/IR/Instructions.h:2080

llvm::VectorType* getType() const

Description

Overload to return most specific vector type.

Declared at: llvm/include/llvm/IR/Instructions.h:2054

bool increasesLength() const

Description

Return true if this shuffle returns a vector with a greater number of elements than its source vectors. Example: shufflevector < 2 x n> A, < 2 x n> B, < 1,2,3>

Declared at: llvm/include/llvm/IR/Instructions.h:2104

bool isConcat() const

Description

Return true if this shuffle concatenates its 2 source vectors. This returns false if either input is undefined. In that case, the shuffle is is better classified as an identity with padding operation.

Declared at: llvm/include/llvm/IR/Instructions.h:2175

static bool isExtractSubvectorMask(
    ArrayRef<int> Mask,
    int NumSrcElts,
    int& Index)

Description

Return true if this shuffle mask is an extract subvector mask. A valid extract subvector mask returns a smaller vector from a single source operand. The base extraction index is returned as well.

Declared at: llvm/include/llvm/IR/Instructions.h:2299

Parameters

ArrayRef<int> Mask
int NumSrcElts
int& Index

static bool isExtractSubvectorMask(
    const llvm::Constant* Mask,
    int NumSrcElts,
    int& Index)

Declared at: llvm/include/llvm/IR/Instructions.h:2301

Parameters

const llvm::Constant* Mask
int NumSrcElts
int& Index

bool isExtractSubvectorMask(int& Index) const

Description

Return true if this shuffle mask is an extract subvector mask.

Declared at: llvm/include/llvm/IR/Instructions.h:2314

Parameters

int& Index

bool isIdentity() const

Description

Return true if this shuffle chooses elements from exactly one source vector without lane crossings and does not change the number of elements from its input vectors. Example: shufflevector < 4 x n> A, < 4 x n> B, < 4,undef,6,undef>

Declared at: llvm/include/llvm/IR/Instructions.h:2155

static bool isIdentityMask(ArrayRef<int> Mask)

Description

Return true if this shuffle mask chooses elements from exactly one source vector without lane crossings. A shuffle using this mask is not necessarily a no-op because it may change the number of elements from its input vectors or it may provide demanded bits knowledge via undef lanes. Example: <undef ,undef,2,3>

Declared at: llvm/include/llvm/IR/Instructions.h:2137

Parameters

ArrayRef<int> Mask

static bool isIdentityMask(
    const llvm::Constant* Mask)

Declared at: llvm/include/llvm/IR/Instructions.h:2138

Parameters

const llvm::Constant* Mask

bool isIdentityWithExtract() const

Description

Return true if this shuffle extracts the first N elements of exactly one source vector.

Declared at: llvm/include/llvm/IR/Instructions.h:2170

bool isIdentityWithPadding() const

Description

Return true if this shuffle lengthens exactly one source vector with undefs in the high elements.

Declared at: llvm/include/llvm/IR/Instructions.h:2166

static bool isInsertSubvectorMask(
    const llvm::Constant* Mask,
    int NumSrcElts,
    int& NumSubElts,
    int& Index)

Declared at: llvm/include/llvm/IR/Instructions.h:2331

Parameters

const llvm::Constant* Mask
int NumSrcElts
int& NumSubElts
int& Index

static bool isInsertSubvectorMask(
    ArrayRef<int> Mask,
    int NumSrcElts,
    int& NumSubElts,
    int& Index)

Description

Return true if this shuffle mask is an insert subvector mask. A valid insert subvector mask inserts the lowest elements of a second source operand into an in-place first source operand operand. Both the sub vector width and the insertion index is returned.

Declared at: llvm/include/llvm/IR/Instructions.h:2329

Parameters

ArrayRef<int> Mask
int NumSrcElts
int& NumSubElts
int& Index

bool isInsertSubvectorMask(int& NumSubElts,
                           int& Index) const

Description

Return true if this shuffle mask is an insert subvector mask.

Declared at: llvm/include/llvm/IR/Instructions.h:2344

Parameters

int& NumSubElts
int& Index

static bool isReplicationMask(
    ArrayRef<int> Mask,
    int& ReplicationFactor,
    int& VF)

Description

Return true if this shuffle mask replicates each of the \p VF elements in a vector \p ReplicationFactor times. For example, the mask for \p ReplicationFactor=3 and \p VF=4 is: < 0,0,0,1,1,1,2,2,2,3,3,3>

Declared at: llvm/include/llvm/IR/Instructions.h:2359

Parameters

ArrayRef<int> Mask
int& ReplicationFactor
int& VF

bool isReplicationMask(int& ReplicationFactor,
                       int& VF) const

Description

Return true if this shuffle mask is a replication mask.

Declared at: llvm/include/llvm/IR/Instructions.h:2374

Parameters

int& ReplicationFactor
int& VF

static bool isReplicationMask(
    const llvm::Constant* Mask,
    int& ReplicationFactor,
    int& VF)

Declared at: llvm/include/llvm/IR/Instructions.h:2361

Parameters

const llvm::Constant* Mask
int& ReplicationFactor
int& VF

bool isReverse() const

Description

Return true if this shuffle swaps the order of elements from exactly one source vector. Example: shufflevector < 4 x n> A, < 4 x n> B, < 3,undef,1,undef> TODO: Optionally allow length-changing shuffles.

Declared at: llvm/include/llvm/IR/Instructions.h:2221

static bool isReverseMask(
    const llvm::Constant* Mask)

Declared at: llvm/include/llvm/IR/Instructions.h:2210

Parameters

const llvm::Constant* Mask

static bool isReverseMask(ArrayRef<int> Mask)

Description

Return true if this shuffle mask swaps the order of elements from exactly one source vector. Example: < 7,6,undef,4> This assumes that vector operands are the same length as the mask.

Declared at: llvm/include/llvm/IR/Instructions.h:2209

Parameters

ArrayRef<int> Mask

bool isSelect() const

Description

Return true if this shuffle chooses elements from its source vectors without lane crossings and all operands have the same number of elements. In other words, this shuffle is equivalent to a vector select with a constant condition operand. Example: shufflevector < 4 x n> A, < 4 x n> B, <undef ,1,6,3> This returns false if the mask does not choose from both input vectors. In that case, the shuffle is better classified as an identity shuffle. TODO: Optionally allow length-changing shuffles.

Declared at: llvm/include/llvm/IR/Instructions.h:2201

static bool isSelectMask(
    const llvm::Constant* Mask)

Declared at: llvm/include/llvm/IR/Instructions.h:2186

Parameters

const llvm::Constant* Mask

static bool isSelectMask(ArrayRef<int> Mask)

Description

Return true if this shuffle mask chooses elements from its source vectors without lane crossings. A shuffle using this mask would be equivalent to a vector select with a constant condition operand. Example: < 4,1,6,undef> This returns false if the mask does not choose from both input vectors. In that case, the shuffle is better classified as an identity shuffle. This assumes that vector operands are the same length as the mask (a length-changing shuffle can never be equivalent to a vector select).

Declared at: llvm/include/llvm/IR/Instructions.h:2185

Parameters

ArrayRef<int> Mask

bool isSingleSource() const

Description

Return true if this shuffle chooses elements from exactly one source vector without changing the length of that vector. Example: shufflevector < 4 x n> A, < 4 x n> B, < 3,0,undef,3> TODO: Optionally allow length-changing shuffles.

Declared at: llvm/include/llvm/IR/Instructions.h:2128

static bool isSingleSourceMask(
    const llvm::Constant* Mask)

Declared at: llvm/include/llvm/IR/Instructions.h:2117

Parameters

const llvm::Constant* Mask

static bool isSingleSourceMask(ArrayRef<int> Mask)

Description

Return true if this shuffle mask chooses elements from exactly one source vector. Example: < 7,5,undef,7> This assumes that vector operands are the same length as the mask.

Declared at: llvm/include/llvm/IR/Instructions.h:2116

Parameters

ArrayRef<int> Mask

bool isTranspose() const

Description

Return true if this shuffle transposes the elements of its inputs without changing the length of the vectors. This operation may also be known as a merge or interleave. See the description for isTransposeMask() for the exact specification. Example: shufflevector < 4 x n> A, < 4 x n> B, < 0,4,2,6>

Declared at: llvm/include/llvm/IR/Instructions.h:2292

static bool isTransposeMask(ArrayRef<int> Mask)

Description

Return true if this shuffle mask is a transpose mask. Transpose vector masks transpose a 2xn matrix. They read corresponding even- or odd-numbered vector elements from two n-dimensional source vectors and write each result into consecutive elements of an n-dimensional destination vector. Two shuffles are necessary to complete the transpose, one for the even elements and another for the odd elements. This description closely follows how the TRN1 and TRN2 AArch64 instructions operate. For example, a simple 2x2 matrix can be transposed with: ; Original matrix m0 = < a, b > m1 = < c, d > ; Transposed matrix t0 = < a, c > = shufflevector m0, m1, < 0, 2 > t1 = < b, d > = shufflevector m0, m1, < 1, 3 > For matrices having greater than n columns, the resulting nx2 transposed matrix is stored in two result vectors such that one vector contains interleaved elements from all the even-numbered rows and the other vector contains interleaved elements from all the odd-numbered rows. For example, a 2x4 matrix can be transposed with: ; Original matrix m0 = < a, b, c, d > m1 = < e, f, g, h > ; Transposed matrix t0 = < a, e, c, g > = shufflevector m0, m1 < 0, 4, 2, 6 > t1 = < b, f, d, h > = shufflevector m0, m1 < 1, 5, 3, 7 >

Declared at: llvm/include/llvm/IR/Instructions.h:2279

Parameters

ArrayRef<int> Mask

static bool isTransposeMask(
    const llvm::Constant* Mask)

Declared at: llvm/include/llvm/IR/Instructions.h:2280

Parameters

const llvm::Constant* Mask

static bool isValidOperands(
    const llvm::Value* V1,
    const llvm::Value* V2,
    const llvm::Value* Mask)

Description

Return true if a shufflevector instruction can be formed with the specified operands.

Declared at: llvm/include/llvm/IR/Instructions.h:2047

Parameters

const llvm::Value* V1
const llvm::Value* V2
const llvm::Value* Mask

static bool isValidOperands(const llvm::Value* V1,
                            const llvm::Value* V2,
                            ArrayRef<int> Mask)

Declared at: llvm/include/llvm/IR/Instructions.h:2049

Parameters

const llvm::Value* V1
const llvm::Value* V2
ArrayRef<int> Mask

bool isZeroEltSplat() const

Description

Return true if all elements of this shuffle are the same value as the first element of exactly one source vector without changing the length of that vector. Example: shufflevector < 4 x n> A, < 4 x n> B, <undef ,0,undef,0> TODO: Optionally allow length-changing shuffles. TODO: Optionally allow splats from other elements.

Declared at: llvm/include/llvm/IR/Instructions.h:2243

static bool isZeroEltSplatMask(
    const llvm::Constant* Mask)

Declared at: llvm/include/llvm/IR/Instructions.h:2230

Parameters

const llvm::Constant* Mask

static bool isZeroEltSplatMask(ArrayRef<int> Mask)

Description

Return true if this shuffle mask chooses all elements with the same value as the first element of exactly one source vector. Example: < 4,undef,undef,4> This assumes that vector operands are the same length as the mask.

Declared at: llvm/include/llvm/IR/Instructions.h:2229

Parameters

ArrayRef<int> Mask

void setShuffleMask(ArrayRef<int> Mask)

Declared at: llvm/include/llvm/IR/Instructions.h:2085

Parameters

ArrayRef<int> Mask