1 ; RUN: opt < %s --passes=instrprof -do-counter-promotion=true -speculative-counter-promotion-max-exiting=3 -S | FileCheck --check-prefix=PROMO %s
3 $__llvm_profile_raw_version = comdat any
5 @g = common local_unnamed_addr global i32 0, align 4
6 @__llvm_profile_raw_version = constant i64 72057594037927940, comdat
7 @__profn_foo = private constant [3 x i8] c"foo"
9 define void @foo(i32 %arg) local_unnamed_addr {
11 %tmp = add nsw i32 %arg, -1
14 bb1: ; preds = %bb11, %bb
15 %tmp2 = phi i32 [ 0, %bb ], [ %tmp12, %bb11 ]
16 %tmp3 = icmp sgt i32 %tmp2, %arg
17 br i1 %tmp3, label %bb7, label %bb4
20 call void @llvm.instrprof.increment(ptr @__profn_foo, i64 63969943867, i32 5, i32 1)
21 tail call void @bar(i32 1)
22 %tmp5 = load i32, ptr @g, align 4
23 %tmp6 = icmp sgt i32 %tmp5, 100
24 br i1 %tmp6, label %bb14, label %bb11
27 %tmp8 = icmp slt i32 %tmp2, %tmp
28 br i1 %tmp8, label %bb9, label %bb10
31 call void @llvm.instrprof.increment(ptr @__profn_foo, i64 63969943867, i32 5, i32 2)
32 tail call void @bar(i32 2)
36 call void @llvm.instrprof.increment(ptr @__profn_foo, i64 63969943867, i32 5, i32 3)
37 tail call void @bar(i32 3)
40 bb11: ; preds = %bb10, %bb9, %bb4
41 %tmp12 = add nuw nsw i32 %tmp2, 1
42 %tmp13 = icmp slt i32 %tmp2, 99
43 br i1 %tmp13, label %bb1, label %bb14
45 bb14: ; preds = %bb4.bb14_crit_edge, %bb11
46 tail call void @bar(i32 0)
49 ; PROMO: %[[MERGE1:[a-z0-9]+]] = phi {{.*}}
50 ; PROMO-NEXT: %[[MERGE2:[a-z0-9.]+]] = phi {{.*}}
51 ; PROMO-NEXT: %[[MERGE3:[a-z0-9.]+]] = phi {{.*}}
52 ; PROMO-NEXT: %[[PROMO3:[a-z0-9.]+]] = load{{.*}}@__profc_foo{{.*}}1)
53 ; PROMO-NEXT: {{.*}} = add {{.*}}%[[PROMO3]], %[[MERGE3]]
54 ; PROMO-NEXT: store{{.*}}@__profc_foo{{.*}}1)
55 ; PROMO-NEXT: %[[PROMO2:[a-z0-9.]+]] = load{{.*}}@__profc_foo{{.*}}2)
56 ; PROMO-NEXT: {{.*}} = add {{.*}}%[[PROMO2]], %[[MERGE2]]
57 ; PROMO-NEXT: store{{.*}}@__profc_foo{{.*}}2)
58 ; PROMO-NEXT: %[[PROMO1:[a-z0-9.]+]] = load{{.*}}@__profc_foo{{.*}}3)
59 ; PROMO-NEXT: {{.*}} = add {{.*}}%[[PROMO1]], %[[MERGE1]]
60 ; PROMO-NEXT: store{{.*}}@__profc_foo{{.*}}3)
63 call void @llvm.instrprof.increment(ptr @__profn_foo, i64 63969943867, i32 5, i32 4)
64 tail call void @bar(i32 1)
68 declare void @bar(i32) local_unnamed_addr
70 ; Function Attrs: nounwind
71 declare void @llvm.instrprof.increment(ptr, i64, i32, i32) #0
73 attributes #0 = { nounwind }