1 ; RUN: opt < %s -pgo-instr-gen -instrprof -do-counter-promotion=true -speculative-counter-promotion-max-exiting=3 -S | FileCheck --check-prefix=PROMO %s
2 ; RUN: opt < %s --passes=pgo-instr-gen,instrprof -do-counter-promotion=true -speculative-counter-promotion-max-exiting=3 -S | FileCheck --check-prefix=PROMO %s
4 @g = common local_unnamed_addr global i32 0, align 4
6 define void @foo(i32 %arg) local_unnamed_addr {
9 %tmp = add nsw i32 %arg, -1
11 bb1: ; preds = %bb11, %bb
12 %tmp2 = phi i32 [ 0, %bb ], [ %tmp12, %bb11 ]
13 %tmp3 = icmp sgt i32 %tmp2, %arg
14 br i1 %tmp3, label %bb7, label %bb4
17 tail call void @bar(i32 1)
18 %tmp5 = load i32, i32* @g, align 4
19 %tmp6 = icmp sgt i32 %tmp5, 100
20 br i1 %tmp6, label %bb15_0, label %bb11
23 %tmp8 = icmp slt i32 %tmp2, %tmp
24 br i1 %tmp8, label %bb9, label %bb10
27 tail call void @bar(i32 2)
31 tail call void @bar(i32 3)
34 bb11: ; preds = %bb10, %bb9, %bb4
35 %tmp12 = add nuw nsw i32 %tmp2, 1
36 %tmp13 = icmp slt i32 %tmp2, 99
37 br i1 %tmp13, label %bb1, label %bb14
41 tail call void @bar(i32 0)
43 ; PROMO: %pgocount.promoted{{.*}} = load {{.*}} @__profc_foo{{.*}} 0)
45 ; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}0)
46 ; PROMO-NEXT: %pgocount.promoted{{.*}} = load {{.*}} @__profc_foo{{.*}} 1)
48 ; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}1)
49 ; PROMO-NEXT: %pgocount.promoted{{.*}} = load {{.*}} @__profc_foo{{.*}} 2)
51 ; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}2)
52 ; PROMO-NEXT: %pgocount{{.*}} = load {{.*}} @__profc_foo{{.*}} 3)
54 ; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}3)
57 bb15_0: ; preds = %bb11
58 ; PROMO-LABEL: bb15_0:
60 ; PROMO: %pgocount.promoted{{.*}} = load {{.*}} @__profc_foo{{.*}} 0)
62 ; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}0)
63 ; PROMO-NEXT: %pgocount.promoted{{.*}} = load {{.*}} @__profc_foo{{.*}} 1)
65 ; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}1)
66 ; PROMO-NEXT: %pgocount.promoted{{.*}} = load {{.*}} @__profc_foo{{.*}} 2)
68 ; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}2)
69 ; PROMO-NEXT: %pgocount{{.*}} = load {{.*}} @__profc_foo{{.*}} 4)
71 ; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}4)
72 ; PROMO-NOT: @__profc_foo
75 bb15: ; preds = %bb14, %bb4
76 tail call void @bar(i32 1)
80 declare void @bar(i32) local_unnamed_addr