Skip to content

Commit 79f7630

Browse files
authored
[LangRef] Clarify semantics of masked vector load/store (#82469)
Basically, these operations are equivalent to a loop that iterates all elements and then does a `getelementptr` (without `inbounds`!) plus `load`/`store` only for the masked-on elements.
1 parent a3cf864 commit 79f7630

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

llvm/docs/LangRef.rst

+8-2
Original file line numberDiff line numberDiff line change
@@ -25182,7 +25182,10 @@ Semantics:
2518225182
""""""""""
2518325183

2518425184
The '``llvm.masked.load``' intrinsic is designed for conditional reading of selected vector elements in a single IR operation. It is useful for targets that support vector masked loads and allows vectorizing predicated basic blocks on these targets. Other targets may support this intrinsic differently, for example by lowering it into a sequence of branches that guard scalar load operations.
25185-
The result of this operation is equivalent to a regular vector load instruction followed by a 'select' between the loaded and the passthru values, predicated on the same mask. However, using this intrinsic prevents exceptions on memory access to masked-off lanes.
25185+
The result of this operation is equivalent to a regular vector load instruction followed by a 'select' between the loaded and the passthru values, predicated on the same mask, except that the masked-off lanes are not accessed.
25186+
Only the masked-on lanes of the vector need to be inbounds of an allocation (but all these lanes need to be inbounds of the same allocation).
25187+
In particular, using this intrinsic prevents exceptions on memory accesses to masked-off lanes.
25188+
Masked-off lanes are also not considered accessed for the purpose of data races or ``noalias`` constraints.
2518625189

2518725190

2518825191
::
@@ -25224,7 +25227,10 @@ Semantics:
2522425227
""""""""""
2522525228

2522625229
The '``llvm.masked.store``' intrinsics is designed for conditional writing of selected vector elements in a single IR operation. It is useful for targets that support vector masked store and allows vectorizing predicated basic blocks on these targets. Other targets may support this intrinsic differently, for example by lowering it into a sequence of branches that guard scalar store operations.
25227-
The result of this operation is equivalent to a load-modify-store sequence. However, using this intrinsic prevents exceptions and data races on memory access to masked-off lanes.
25230+
The result of this operation is equivalent to a load-modify-store sequence, except that the masked-off lanes are not accessed.
25231+
Only the masked-on lanes of the vector need to be inbounds of an allocation (but all these lanes need to be inbounds of the same allocation).
25232+
In particular, using this intrinsic prevents exceptions on memory accesses to masked-off lanes.
25233+
Masked-off lanes are also not considered accessed for the purpose of data races or ``noalias`` constraints.
2522825234

2522925235
::
2523025236

0 commit comments

Comments
 (0)