[llvm] [IRBuilder] Refactor for intrinsics const-folding (NFC) (PR #202738)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 9 12:05:18 PDT 2026


================
@@ -248,73 +248,79 @@ Value *IRBuilderBase::CreateStepVector(Type *DstType, const Twine &Name) {
   return ConstantVector::get(Indices);
 }
 
-CallInst *IRBuilderBase::CreateMemSet(Value *Ptr, Value *Val, Value *Size,
-                                      MaybeAlign Align, bool isVolatile,
-                                      const AAMDNodes &AAInfo) {
+Value *IRBuilderBase::CreateMemSet(Value *Ptr, Value *Val, Value *Size,
+                                   MaybeAlign Align, bool isVolatile,
+                                   const AAMDNodes &AAInfo) {
   Value *Ops[] = {Ptr, Val, Size, getInt1(isVolatile)};
   Type *Tys[] = {Ptr->getType(), Size->getType()};
 
-  CallInst *CI = CreateIntrinsic(Intrinsic::memset, Tys, Ops);
+  Value *V = CreateIntrinsic(Intrinsic::memset, Tys, Ops);
 
-  if (Align)
-    cast<MemSetInst>(CI)->setDestAlignment(*Align);
-  CI->setAAMetadata(AAInfo);
-  return CI;
+  if (auto *CI = dyn_cast<MemSetInst>(V)) {
----------------
topperc wrote:

In practice this can never fold. Could we use a cast?

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


More information about the llvm-commits mailing list