Skip to content

Commit 575fdea

Browse files
committed
[LangRef] Update shufflevector's semantics to return poison if the mask is undef
This patch changes the shufflevector's semantics to yield poison if the mask is undefined. This allows the extraction of shufflevectors while also opening the door for more optimization opportunities due to the fact that poison is more undefined than undef. Differential Revision: https://reviews.llvm.org/D148637
1 parent 07e5f57 commit 575fdea

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

llvm/docs/LangRef.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10075,7 +10075,7 @@ Arguments:
1007510075
The first two operands of a '``shufflevector``' instruction are vectors
1007610076
with the same type. The third argument is a shuffle mask vector constant
1007710077
whose element type is ``i32``. The mask vector elements must be constant
10078-
integers or ``undef`` values. The result of the instruction is a vector
10078+
integers or ``poison`` values. The result of the instruction is a vector
1007910079
whose length is the same as the shuffle mask and whose element type is the
1008010080
same as the element type of the first two operands.
1008110081

@@ -10088,15 +10088,15 @@ shuffle mask selects an element from one of the input vectors to copy
1008810088
to the result. Non-negative elements in the mask represent an index
1008910089
into the concatenated pair of input vectors.
1009010090

10091-
If the shuffle mask is undefined, the result vector is undefined. If
10092-
the shuffle mask selects an undefined element from one of the input
10093-
vectors, the resulting element is undefined. An undefined element
10094-
in the mask vector specifies that the resulting element is undefined.
10095-
An undefined element in the mask vector prevents a poisoned vector
10096-
element from propagating.
10091+
A ``poison`` element in the mask vector specifies that the resulting element
10092+
is ``poison``.
10093+
For backwards-compatibility reasons, LLVM temporarily also accepts ``undef``
10094+
mask elements, which will be interpreted the same way as ``poison`` elements.
10095+
If the shuffle mask selects an ``undef`` element from one of the input
10096+
vectors, the resulting element is ``undef``.
1009710097

1009810098
For scalable vectors, the only valid mask values at present are
10099-
``zeroinitializer`` and ``undef``, since we cannot write all indices as
10099+
``zeroinitializer``, ``undef`` and ``poison``, since we cannot write all indices as
1010010100
literals for a vector with a length unknown at compile time.
1010110101

1010210102
Example:
@@ -10106,9 +10106,9 @@ Example:
1010610106

1010710107
<result> = shufflevector <4 x i32> %v1, <4 x i32> %v2,
1010810108
<4 x i32> <i32 0, i32 4, i32 1, i32 5> ; yields <4 x i32>
10109-
<result> = shufflevector <4 x i32> %v1, <4 x i32> undef,
10109+
<result> = shufflevector <4 x i32> %v1, <4 x i32> poison,
1011010110
<4 x i32> <i32 0, i32 1, i32 2, i32 3> ; yields <4 x i32> - Identity shuffle.
10111-
<result> = shufflevector <8 x i32> %v1, <8 x i32> undef,
10111+
<result> = shufflevector <8 x i32> %v1, <8 x i32> poison,
1011210112
<4 x i32> <i32 0, i32 1, i32 2, i32 3> ; yields <4 x i32>
1011310113
<result> = shufflevector <4 x i32> %v1, <4 x i32> %v2,
1011410114
<8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7 > ; yields <8 x i32>

0 commit comments

Comments
 (0)