[llvm] [DirectX] Legalize memcpy (PR #139173)

Deric C. via llvm-commits llvm-commits at lists.llvm.org
Thu May 15 10:57:32 PDT 2025


================
@@ -296,6 +351,30 @@ static void emitMemsetExpansion(IRBuilder<> &Builder, Value *Dst, Value *Val,
   }
 }
 
+static void removeMemCpy(Instruction &I,
+                         SmallVectorImpl<Instruction *> &ToRemove,
+                         DenseMap<Value *, Value *> &ReplacedValues) {
+
+  CallInst *CI = dyn_cast<CallInst>(&I);
+  if (!CI)
+    return;
+
+  Intrinsic::ID ID = CI->getIntrinsicID();
+  if (ID != Intrinsic::memcpy)
+    return;
+
+  IRBuilder<> Builder(&I);
+  Value *Dst = CI->getArgOperand(0);
+  Value *Src = CI->getArgOperand(1);
+  ConstantInt *Length = dyn_cast<ConstantInt>(CI->getArgOperand(2));
----------------
Icohedron wrote:

I recall @tex3d mentioning that the length should always be constant. There was a case of it not being constant, but that has been eliminated by #138991

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


More information about the llvm-commits mailing list