1 ; RUN: opt < %s -analyze -branch-prob -enable-new-pm=0 | FileCheck %s
2 ; RUN: opt < %s -passes='print<branch-prob>' -disable-output 2>&1 | FileCheck %s
4 @A = global i32 0, align 4
5 @B = global i32 0, align 4
7 ; CHECK-LABEL: eq_opaque_minus_one
8 define void @eq_opaque_minus_one(i32* %base) {
10 %const = bitcast i32 -1 to i32
11 %tmp1 = load i32, i32* @B, align 4
14 ; CHECK: edge for.body -> if.then probability is 0x30000000 / 0x80000000 = 37.50%
15 ; CHECK: edge for.body -> for.inc probability is 0x50000000 / 0x80000000 = 62.50%
17 %tmp4 = phi i32 [ %tmp1, %entry ], [ %tmp7, %for.inc ]
18 %inc.iv = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
19 %storemerge176.in = getelementptr inbounds i32, i32* %base, i32 %inc.iv
20 %storemerge176 = load i32, i32* %storemerge176.in, align 4
21 store i32 %storemerge176, i32* @A, align 4
22 %cmp20 = icmp eq i32 %storemerge176, %const
23 br i1 %cmp20, label %if.then, label %for.inc
26 %lnot.ext = zext i1 %cmp20 to i32
27 store i32 %lnot.ext, i32* @B, align 4
31 %tmp7 = phi i32 [ %tmp4, %for.body ], [ %lnot.ext, %if.then ]
32 %inc = add nuw nsw i32 %inc.iv, 1
33 %cmp9 = icmp ult i32 %inc, 401
34 br i1 %cmp9, label %for.body, label %exit
40 ; CHECK-LABEL: ne_opaque_minus_one
41 define void @ne_opaque_minus_one(i32* %base) {
43 %const = bitcast i32 -1 to i32
44 %tmp1 = load i32, i32* @B, align 4
47 ; CHECK: edge for.body -> if.then probability is 0x50000000 / 0x80000000 = 62.50%
48 ; CHECK: edge for.body -> for.inc probability is 0x30000000 / 0x80000000 = 37.50%
50 %tmp4 = phi i32 [ %tmp1, %entry ], [ %tmp7, %for.inc ]
51 %inc.iv = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
52 %storemerge176.in = getelementptr inbounds i32, i32* %base, i32 %inc.iv
53 %storemerge176 = load i32, i32* %storemerge176.in, align 4
54 store i32 %storemerge176, i32* @A, align 4
55 %cmp20 = icmp ne i32 %storemerge176, %const
56 br i1 %cmp20, label %if.then, label %for.inc
59 %lnot.ext = zext i1 %cmp20 to i32
60 store i32 %lnot.ext, i32* @B, align 4
64 %tmp7 = phi i32 [ %tmp4, %for.body ], [ %lnot.ext, %if.then ]
65 %inc = add nuw nsw i32 %inc.iv, 1
66 %cmp9 = icmp ult i32 %inc, 401
67 br i1 %cmp9, label %for.body, label %exit
73 ; CHECK-LABEL: sgt_opaque_minus_one
74 define void @sgt_opaque_minus_one(i32* %base) {
76 %const = bitcast i32 -1 to i32
77 %tmp1 = load i32, i32* @B, align 4
80 ; CHECK: edge for.body -> if.then probability is 0x50000000 / 0x80000000 = 62.50%
81 ; CHECK: edge for.body -> for.inc probability is 0x30000000 / 0x80000000 = 37.50%
83 %tmp4 = phi i32 [ %tmp1, %entry ], [ %tmp7, %for.inc ]
84 %inc.iv = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
85 %storemerge176.in = getelementptr inbounds i32, i32* %base, i32 %inc.iv
86 %storemerge176 = load i32, i32* %storemerge176.in, align 4
87 store i32 %storemerge176, i32* @A, align 4
88 %cmp20 = icmp sgt i32 %storemerge176, %const
89 br i1 %cmp20, label %if.then, label %for.inc
92 %lnot.ext = zext i1 %cmp20 to i32
93 store i32 %lnot.ext, i32* @B, align 4
97 %tmp7 = phi i32 [ %tmp4, %for.body ], [ %lnot.ext, %if.then ]
98 %inc = add nuw nsw i32 %inc.iv, 1
99 %cmp9 = icmp ult i32 %inc, 401
100 br i1 %cmp9, label %for.body, label %exit