[llvm] [LoopIdiom] Don't convert `memset.inline` into `memset` (PR #227650)
Ömer Sinan Ağacan via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 30 04:09:34 PDT 2026
================
@@ -4,15 +4,13 @@
define void @f(ptr %a, i64 %n) {
; CHECK-LABEL: @f(
; CHECK-NEXT: entry:
-; CHECK-NEXT: [[UMAX:%.*]] = call i64 @llvm.umax.i64(i64 [[N:%.*]], i64 1)
-; CHECK-NEXT: [[TMP0:%.*]] = shl nuw i64 [[UMAX]], 4
-; CHECK-NEXT: call void @llvm.memset.p0.i64(ptr [[A:%.*]], i8 0, i64 [[TMP0]], i1 false)
; CHECK-NEXT: br label [[LOOP:%.*]]
; CHECK: loop:
; CHECK-NEXT: [[I:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], [[LOOP]] ]
-; CHECK-NEXT: [[P:%.*]] = getelementptr inbounds [16 x i8], ptr [[A]], i64 [[I]]
+; CHECK-NEXT: [[P:%.*]] = getelementptr inbounds [16 x i8], ptr [[A:%.*]], i64 [[I]]
+; CHECK-NEXT: call void @llvm.memset.inline.p0.i64(ptr [[P]], i8 0, i64 16, i1 false)
----------------
osa1 wrote:
We have a dynamic size `llvm.memset.inline` test here: https://github.com/llvm/llvm-project/blob/main/llvm/test/Transforms/PreISelIntrinsicLowering/X86/memset-inline-non-constant-len.ll
There are a bunch of others for other backends. The tests are in backend directories as you handle those in pre-isel lowering.
https://github.com/llvm/llvm-project/pull/227650
More information about the llvm-commits
mailing list