1 ; RUN: opt < %s --passes=pgo-instr-gen,instrprof -do-counter-promotion=true -speculative-counter-promotion-max-exiting=3 -S | FileCheck --check-prefix=PROMO %s
3 @g = common local_unnamed_addr global i32 0, align 4
5 define void @foo(i32 %arg) local_unnamed_addr {
8 %tmp = add nsw i32 %arg, -1
10 bb1: ; preds = %bb11, %bb
11 %tmp2 = phi i32 [ 0, %bb ], [ %tmp12, %bb11 ]
12 %tmp3 = icmp sgt i32 %tmp2, %arg
13 br i1 %tmp3, label %bb7, label %bb4
16 tail call void @bar(i32 1)
17 %tmp5 = load i32, ptr @g, align 4
18 %tmp6 = icmp sgt i32 %tmp5, 100
19 br i1 %tmp6, label %bb15_0, label %bb11
22 %tmp8 = icmp slt i32 %tmp2, %tmp
23 br i1 %tmp8, label %bb9, label %bb10
26 tail call void @bar(i32 2)
30 tail call void @bar(i32 3)
33 bb11: ; preds = %bb10, %bb9, %bb4
34 %tmp12 = add nuw nsw i32 %tmp2, 1
35 %tmp13 = icmp slt i32 %tmp2, 99
36 br i1 %tmp13, label %bb1, label %bb14
40 tail call void @bar(i32 0)
42 ; PROMO: %pgocount.promoted{{.*}} = load i64, ptr @__profc_foo, align 4
44 ; PROMO-NEXT: store i64 %3, ptr @__profc_foo, align 4
45 ; PROMO-NEXT: %pgocount.promoted{{.*}} = load i64, ptr getelementptr inbounds ([5 x i64], ptr @__profc_foo, i32 0, i32 1), align 4
47 ; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}1)
48 ; PROMO-NEXT: %pgocount.promoted{{.*}} = load i64, ptr getelementptr inbounds ([5 x i64], ptr @__profc_foo, i32 0, i32 2), align 4
50 ; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}2)
51 ; PROMO-NEXT: %pgocount{{.*}} = load i64, ptr getelementptr inbounds ([5 x i64], ptr @__profc_foo, i32 0, i32 3), align 4
53 ; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}3)
56 bb15_0: ; preds = %bb11
57 ; PROMO-LABEL: bb15_0:
59 ; PROMO: %pgocount.promoted{{.*}} = load i64, ptr @__profc_foo, align 4
61 ; PROMO-NEXT: store {{.*}} @__profc_foo, align 4
62 ; PROMO-NEXT: %pgocount.promoted{{.*}} = load i64, ptr getelementptr inbounds ([5 x i64], ptr @__profc_foo, i32 0, i32 1), align 4
64 ; PROMO-NEXT: store {{.*}} ptr getelementptr inbounds ([5 x i64], ptr @__profc_foo, i32 0, i32 1), align 4
65 ; PROMO-NEXT: %pgocount.promoted{{.*}} = load i64, ptr getelementptr inbounds ([5 x i64], ptr @__profc_foo, i32 0, i32 2), align 4
67 ; PROMO-NEXT: store {{.*}} ptr getelementptr inbounds ([5 x i64], ptr @__profc_foo, i32 0, i32 2), align 4
68 ; PROMO-NEXT: %pgocount{{.*}} = load {{.*}} @__profc_foo{{.*}} 4)
70 ; PROMO-NEXT: store {{.*}} ptr getelementptr inbounds ([5 x i64], ptr @__profc_foo, i32 0, i32 4), align 4
71 ; PROMO-NOT: @__profc_foo{{.*}})
74 bb15: ; preds = %bb14, %bb4
75 tail call void @bar(i32 1)
79 declare void @bar(i32) local_unnamed_addr