[llvm] [Vectorize] Vectorization for __builtin_prefetch (PR #66160)

via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 13 19:04:42 PST 2023


================
@@ -645,6 +666,34 @@ CallInst *IRBuilderBase::CreateMaskedCompressStore(Value *Val, Value *Ptr,
                                OverloadedTypes);
 }
 
+/// Create a call to a Masked Gather Prefetch intrinsic.
+/// \p Ptrs     - vector of pointers for loading
+/// \p ElemSize - element size for memory address generation
+/// \p Mask     - vector of booleans which indicates what vector lanes should
+///               be accessed in memory
+/// \p RW       - Read or Write
+/// \p Locality - Cache Level
+/// \p Name     - name of the result variable
+CallInst *IRBuilderBase::CreateMaskedGatherPrefetch(Value *Ptrs, Value *ElemSize,
+                                                    Value *Mask, Value *RW,
+                                                    Value *Locality,
+                                                    const Twine &Name) {
+  auto *PtrsTy = cast<VectorType>(Ptrs->getType());
+  ElementCount NumElts = PtrsTy->getElementCount();
+
+  if (!Mask)
----------------
m-saito-fj wrote:

Thanks for the comment.

I do the same with [gahter](https://github.com/llvm/llvm-project/pull/66160/files#diff-7b9ae5c1774880299e98d0bd713f6d0b881a6f70ad31ce5603ea6275fecf8a42R584)/[scatter](https://github.com/llvm/llvm-project/pull/66160/files#diff-7b9ae5c1774880299e98d0bd713f6d0b881a6f70ad31ce5603ea6275fecf8a42R615).

I think that if mask is null, then mask can be considered unnecessary. So I think there is no problem with all ones.
I think it is fine as it is.

https://github.com/llvm/llvm-project/pull/66160


More information about the llvm-commits mailing list