1 ; RUN: opt < %s -pgo-instr-gen -instrprof -do-counter-promotion=true -S | FileCheck --check-prefix=PROMO --check-prefix=NONATOMIC_PROMO %s
2 ; RUN: opt < %s --passes=pgo-instr-gen,instrprof -do-counter-promotion=true -S | FileCheck --check-prefix=PROMO --check-prefix=NONATOMIC_PROMO %s
3 ; RUN: opt < %s -pgo-instr-gen -instrprof -do-counter-promotion=true -atomic-counter-update-promoted -S | FileCheck --check-prefix=PROMO --check-prefix=ATOMIC_PROMO %s
4 ; RUN: opt < %s --passes=pgo-instr-gen,instrprof -do-counter-promotion=true -atomic-counter-update-promoted -S | FileCheck --check-prefix=PROMO --check-prefix=ATOMIC_PROMO %s
6 define void @foo(i32 %n, i32 %N) {
8 ; PROMO: {{.*}} = load {{.*}} @__profc_foo{{.*}} 3)
10 ; PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}3)
12 %tmp = add nsw i32 %n, 1
13 %tmp1 = add nsw i32 %n, -1
16 bb2: ; preds = %bb9, %bb
18 ; PROMO-NEXT: phi {{.*}}
19 ; PROMO-NEXT: phi {{.*}}
20 ; PROMO-NEXT: phi {{.*}}
21 %i.0 = phi i32 [ 0, %bb ], [ %tmp10, %bb9 ]
22 %tmp3 = icmp slt i32 %i.0, %tmp
23 br i1 %tmp3, label %bb4, label %bb5
26 tail call void @bar(i32 1)
30 %tmp6 = icmp slt i32 %i.0, %tmp1
31 br i1 %tmp6, label %bb7, label %bb8
34 tail call void @bar(i32 2)
38 tail call void @bar(i32 3)
41 bb9: ; preds = %bb8, %bb7, %bb4
42 ; PROMO: %[[LIVEOUT3:[a-z0-9]+]] = phi {{.*}}
43 ; PROMO-NEXT: %[[LIVEOUT2:[a-z0-9]+]] = phi {{.*}}
44 ; PROMO-NEXT: %[[LIVEOUT1:[a-z0-9]+]] = phi {{.*}}
45 %tmp10 = add nsw i32 %i.0, 1
46 %tmp11 = icmp slt i32 %tmp10, %N
47 br i1 %tmp11, label %bb2, label %bb12
51 ; NONATOMIC_PROMO: %[[PROMO1:[a-z0-9.]+]] = load {{.*}} @__profc_foo{{.*}} 0)
52 ; NONATOMIC_PROMO-NEXT: add {{.*}} %[[PROMO1]], %[[LIVEOUT1]]
53 ; NONATOMIC_PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}0)
54 ; NONATOMIC_PROMO-NEXT: %[[PROMO2:[a-z0-9.]+]] = load {{.*}} @__profc_foo{{.*}} 1)
55 ; NONATOMIC_PROMO-NEXT: add {{.*}} %[[PROMO2]], %[[LIVEOUT2]]
56 ; NONATOMIC_PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}1)
57 ; NONATOMIC_PROMO-NEXT: %[[PROMO3:[a-z0-9.]+]] = load {{.*}} @__profc_foo{{.*}} 2)
58 ; NONATOMIC_PROMO-NEXT: add {{.*}} %[[PROMO3]], %[[LIVEOUT3]]
59 ; NONATOMIC_PROMO-NEXT: store {{.*}}@__profc_foo{{.*}}2)
60 ; ATOMIC_PROMO: atomicrmw add {{.*}} @__profc_foo{{.*}}0), i64 %[[LIVEOUT1]] seq_cst
61 ; ATOMIC_PROMO-NEXT: atomicrmw add {{.*}} @__profc_foo{{.*}}1), i64 %[[LIVEOUT2]] seq_cst
62 ; ATOMIC_PROMO-NEXT: atomicrmw add {{.*}} @__profc_foo{{.*}}2), i64 %[[LIVEOUT3]] seq_cst
63 ; PROMO-NOT: @__profc_foo
68 declare void @bar(i32)