[PATCH] D150043: [InferAddressSpaces] Handle vector of pointers type & Support intrinsic masked gather/scatter

CaprYang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 8 19:20:49 PDT 2023


CaprYang added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp:259-265
+static unsigned getPtrOrVecOfPtrsAddressSpace(Type *Ty) {
+  if (Ty->isVectorTy()) {
+    Ty = cast<VectorType>(Ty)->getElementType();
+  }
+  assert(Ty->isPointerTy());
+  return Ty->getPointerAddressSpace();
+}
----------------
arsenm wrote:
> This is reinventing Type::getPointerAddressSpace
Yes.. it seems like I am doing some useless work.


================
Comment at: llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp:268-271
+  if (Ty->isVectorTy()) {
+    Ty = cast<VectorType>(Ty)->getElementType();
+  }
+  return Ty->isPointerTy();
----------------
arsenm wrote:
> isPtrOrPtrVectorTy
Oh thanks! I just learned that there are these APIs, let me replace them.


================
Comment at: llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp:285
+  Type *NPT =
+      PointerType::getWithSamePointeeType(cast<PointerType>(PT), NewAddrSpace);
+  return VectorType::get(NPT, cast<VectorType>(Ty)->getElementCount());
----------------
arsenm wrote:
> Don't need to bother trying to maintain pointer element types anymore 
Sorry.. I don't know what to do, can you tell me?


================
Comment at: llvm/test/Transforms/InferAddressSpaces/AMDGPU/icmp.ll:151
 ; CHECK-LABEL: @icmp_flat_flat_from_group_vector(
-; CHECK: %cmp = icmp eq <2 x ptr> %cast0, %cast1
+; CHECK: %cmp = icmp eq <2 x ptr addrspace(3)> %group.ptr.0, %group.ptr.1
 define <2 x i1> @icmp_flat_flat_from_group_vector(<2 x ptr addrspace(3)> %group.ptr.0, <2 x ptr addrspace(3)> %group.ptr.1) #0 {
----------------
arsenm wrote:
> You touched a lot more than just icmp, so this needs more tests to cover all the newly handled cases 
I will add more tests later


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150043/new/

https://reviews.llvm.org/D150043



More information about the cfe-commits mailing list