[llvm] [AMDGPU][PromoteAlloca] Support memsets to ptr allocas (PR #80678)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 5 05:16:35 PST 2024


================
@@ -521,10 +521,18 @@ static Value *promoteAllocaUserToVector(
       // For memset, we don't need to know the previous value because we
       // currently only allow memsets that cover the whole alloca.
       Value *Elt = MSI->getOperand(1);
-      if (DL.getTypeStoreSize(VecEltTy) > 1) {
-        Value *EltBytes =
-            Builder.CreateVectorSplat(DL.getTypeStoreSize(VecEltTy), Elt);
-        Elt = Builder.CreateBitCast(EltBytes, VecEltTy);
+      const unsigned BytesPerElt = DL.getTypeStoreSize(VecEltTy);
+      if (BytesPerElt > 1) {
+        Value *EltBytes = Builder.CreateVectorSplat(BytesPerElt, Elt);
+
+        // If the element type of the vector is a pointer, we need to first cast
+        // to an integer, then use a PtrCast.
+        if (VecEltTy->isPointerTy()) {
----------------
arsenm wrote:

Will fail the same way for vector of pointers 

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


More information about the llvm-commits mailing list