1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -basic-aa -loop-idiom < %s -S | FileCheck %s
4 define void @f(i32* nocapture nonnull align 4 dereferenceable(20) %0, i32 %1) local_unnamed_addr #0 align 32 {
6 ; CHECK-NEXT: [[TMP3:%.*]] = trunc i32 [[TMP1:%.*]] to i2
7 ; CHECK-NEXT: [[TMP4:%.*]] = zext i2 [[TMP3]] to i64
8 ; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i32, i32* [[TMP0:%.*]], i64 [[TMP4]]
9 ; CHECK-NEXT: [[SCEVGEP1:%.*]] = bitcast i32* [[SCEVGEP]] to i8*
10 ; CHECK-NEXT: [[TMP5:%.*]] = sub i2 -1, [[TMP3]]
11 ; CHECK-NEXT: [[TMP6:%.*]] = zext i2 [[TMP5]] to i64
12 ; CHECK-NEXT: [[TMP7:%.*]] = shl nuw nsw i64 [[TMP6]], 2
13 ; CHECK-NEXT: [[TMP8:%.*]] = add nuw nsw i64 [[TMP7]], 4
14 ; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 4 [[SCEVGEP1]], i8 0, i64 [[TMP8]], i1 false)
15 ; CHECK-NEXT: br label [[TMP9:%.*]]
17 ; CHECK-NEXT: [[TMP10:%.*]] = phi i32 [ [[TMP14:%.*]], [[TMP9]] ], [ [[TMP1]], [[TMP2:%.*]] ]
18 ; CHECK-NEXT: [[TMP11:%.*]] = and i32 [[TMP10]], 3
19 ; CHECK-NEXT: [[TMP12:%.*]] = zext i32 [[TMP11]] to i64
20 ; CHECK-NEXT: [[TMP13:%.*]] = getelementptr inbounds i32, i32* [[TMP0]], i64 [[TMP12]]
21 ; CHECK-NEXT: [[TMP14]] = add nsw i32 [[TMP10]], 1
22 ; CHECK-NEXT: [[TMP15:%.*]] = and i32 [[TMP14]], 3
23 ; CHECK-NEXT: [[TMP16:%.*]] = icmp eq i32 [[TMP15]], 0
24 ; CHECK-NEXT: br i1 [[TMP16]], label [[TMP17:%.*]], label [[TMP9]]
26 ; CHECK-NEXT: ret void
31 %4 = phi i32 [ %8, %3 ], [ %1, %2 ]
33 %6 = zext i32 %5 to i64
34 %7 = getelementptr inbounds i32, i32* %0, i64 %6
35 store i32 0, i32* %7, align 4
36 %8 = add nsw i32 %4, 1
38 %10 = icmp eq i32 %9, 0
39 br i1 %10, label %11, label %3