1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt -S -O3 < %s | FileCheck %s
4 define void @test(ptr noundef %a, i32 noundef %beam) {
5 ; CHECK-LABEL: define void @test
6 ; CHECK-SAME: (ptr nocapture noundef writeonly [[A:%.*]], i32 noundef [[BEAM:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
8 ; CHECK-NEXT: [[MUL:%.*]] = shl nuw nsw i32 [[BEAM]], 1
9 ; CHECK-NEXT: [[IDXPROM:%.*]] = zext nneg i32 [[MUL]] to i64
10 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[IDXPROM]]
11 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
12 ; CHECK: for.cond.cleanup:
13 ; CHECK-NEXT: ret void
15 ; CHECK-NEXT: [[I_06:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], [[FOR_INC:%.*]] ]
16 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 [[I_06]], [[BEAM]]
17 ; CHECK-NEXT: br i1 [[CMP1]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
19 ; CHECK-NEXT: store i32 0, ptr [[ARRAYIDX]], align 4
20 ; CHECK-NEXT: br label [[FOR_INC]]
22 ; CHECK-NEXT: [[MUL2:%.*]] = shl nuw nsw i32 [[I_06]], 1
23 ; CHECK-NEXT: [[IDXPROM3:%.*]] = zext nneg i32 [[MUL2]] to i64
24 ; CHECK-NEXT: [[ARRAYIDX4:%.*]] = getelementptr inbounds i32, ptr [[A]], i64 [[IDXPROM3]]
25 ; CHECK-NEXT: store i32 1, ptr [[ARRAYIDX4]], align 4
26 ; CHECK-NEXT: br label [[FOR_INC]]
28 ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_06]], 1
29 ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i32 [[I_06]], 9999
30 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_COND_CLEANUP:%.*]]
33 %a.addr = alloca ptr, align 8
34 %beam.addr = alloca i32, align 4
35 %i = alloca i32, align 4
36 store ptr %a, ptr %a.addr, align 8
37 store i32 %beam, ptr %beam.addr, align 4
38 call void @llvm.lifetime.start.p0(i64 4, ptr %i)
39 store i32 0, ptr %i, align 4
42 for.cond: ; preds = %for.inc, %entry
43 %0 = load i32, ptr %i, align 4
44 %cmp = icmp slt i32 %0, 10000
45 br i1 %cmp, label %for.body, label %for.cond.cleanup
47 for.cond.cleanup: ; preds = %for.cond
48 call void @llvm.lifetime.end.p0(i64 4, ptr %i)
51 for.body: ; preds = %for.cond
52 %1 = load i32, ptr %i, align 4
53 %2 = load i32, ptr %beam.addr, align 4
54 %cmp1 = icmp eq i32 %1, %2
55 br i1 %cmp1, label %if.then, label %if.else
57 if.then: ; preds = %for.body
58 %3 = load ptr, ptr %a.addr, align 8
59 %4 = load i32, ptr %i, align 4
60 %mul = mul nsw i32 2, %4
61 %idxprom = sext i32 %mul to i64
62 %arrayidx = getelementptr inbounds i32, ptr %3, i64 %idxprom
63 store i32 0, ptr %arrayidx, align 4
66 if.else: ; preds = %for.body
67 %5 = load ptr, ptr %a.addr, align 8
68 %6 = load i32, ptr %i, align 4
69 %mul2 = mul nsw i32 2, %6
70 %idxprom3 = sext i32 %mul2 to i64
71 %arrayidx4 = getelementptr inbounds i32, ptr %5, i64 %idxprom3
72 store i32 1, ptr %arrayidx4, align 4
75 if.end: ; preds = %if.else, %if.then
78 for.inc: ; preds = %if.end
79 %7 = load i32, ptr %i, align 4
80 %inc = add nsw i32 %7, 1
81 store i32 %inc, ptr %i, align 4
84 for.end: ; preds = %for.cond.cleanup
88 declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture)
90 declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture)