[llvm] [LoopIdiom] Select llvm.experimental.memset.pattern intrinsic rather than memset_pattern16 libcall (PR #126736)

Alex Bradbury via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 9 05:38:24 PDT 2025


================
@@ -1083,53 +1092,92 @@ bool LoopIdiomRecognize::processLoopStridedStore(
     return Changed;
 
   // Okay, everything looks good, insert the memset.
+  // MemsetArg is the number of bytes for the memset libcall, and the number
+  // of pattern repetitions if the memset.pattern intrinsic is being used.
+  Value *MemsetArg;
+  std::optional<int64_t> BytesWritten;
+
+  if (PatternValue && (HasMemsetPattern || ForceMemsetPatternIntrinsic)) {
+    const SCEV *TripCountS =
----------------
asb wrote:

Yes, it's the case of multiple stores in a loop iteration. I could perhaps build the necessary value with numbytes and a div, but I'm wary of cases where it may not be folded away.

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


More information about the llvm-commits mailing list