1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -basic-aa -loop-idiom < %s -S | FileCheck %s
5 define dso_local void @double_memset(i8* nocapture %p, i8* noalias nocapture %q, i32 %n) {
6 ; CHECK-LABEL: @double_memset(
8 ; CHECK-NEXT: [[CMP4:%.*]] = icmp sgt i32 [[N:%.*]], 0
9 ; CHECK-NEXT: br i1 [[CMP4]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_COND_CLEANUP:%.*]]
10 ; CHECK: for.body.preheader:
11 ; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[N]] to i64
12 ; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 1 [[Q:%.*]], i8 0, i64 [[TMP0]], i1 false)
13 ; CHECK-NEXT: [[TMP1:%.*]] = zext i32 [[N]] to i64
14 ; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 1 [[P:%.*]], i8 0, i64 [[TMP1]], i1 false)
15 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
16 ; CHECK: for.cond.cleanup.loopexit:
17 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]
18 ; CHECK: for.cond.cleanup:
19 ; CHECK-NEXT: ret void
21 ; CHECK-NEXT: [[I_07:%.*]] = phi i32 [ [[INC:%.*]], [[FOR_BODY]] ], [ 0, [[FOR_BODY_PREHEADER]] ]
22 ; CHECK-NEXT: [[P_ADDR_06:%.*]] = phi i8* [ [[INCDEC_PTR1:%.*]], [[FOR_BODY]] ], [ [[P]], [[FOR_BODY_PREHEADER]] ]
23 ; CHECK-NEXT: [[Q_ADDR_05:%.*]] = phi i8* [ [[INCDEC_PTR:%.*]], [[FOR_BODY]] ], [ [[Q]], [[FOR_BODY_PREHEADER]] ]
24 ; CHECK-NEXT: [[INCDEC_PTR]] = getelementptr inbounds i8, i8* [[Q_ADDR_05]], i64 1
25 ; CHECK-NEXT: [[INCDEC_PTR1]] = getelementptr inbounds i8, i8* [[P_ADDR_06]], i64 1
26 ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_07]], 1
27 ; CHECK-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i32 [[INC]], [[N]]
28 ; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label [[FOR_COND_CLEANUP_LOOPEXIT:%.*]], label [[FOR_BODY]]
31 %cmp4 = icmp sgt i32 %n, 0
32 br i1 %cmp4, label %for.body, label %for.cond.cleanup
38 %i.07 = phi i32 [ %inc, %for.body ], [ 0, %entry ]
39 %p.addr.06 = phi i8* [ %incdec.ptr1, %for.body ], [ %p, %entry ]
40 %q.addr.05 = phi i8* [ %incdec.ptr, %for.body ], [ %q, %entry ]
41 %incdec.ptr = getelementptr inbounds i8, i8* %q.addr.05, i64 1
42 store i8 0, i8* %q.addr.05, align 1
43 %incdec.ptr1 = getelementptr inbounds i8, i8* %p.addr.06, i64 1
44 store i8 0, i8* %p.addr.06, align 1
45 %inc = add nuw nsw i32 %i.07, 1
46 %exitcond.not = icmp eq i32 %inc, %n
47 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body