1 ; RUN: opt < %s -analyze -branch-prob | FileCheck %s
3 @A = global i32 0, align 4
4 @B = global i32 0, align 4
6 ; CHECK-LABEL: eq_opaque_minus_one
7 define void @eq_opaque_minus_one(i32* %base) {
9 %const = bitcast i32 -1 to i32
10 %tmp1 = load i32, i32* @B, align 4
13 ; CHECK: edge for.body -> if.then probability is 0x30000000 / 0x80000000 = 37.50%
14 ; CHECK: edge for.body -> for.inc probability is 0x50000000 / 0x80000000 = 62.50%
16 %tmp4 = phi i32 [ %tmp1, %entry ], [ %tmp7, %for.inc ]
17 %inc.iv = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
18 %storemerge176.in = getelementptr inbounds i32, i32* %base, i32 %inc.iv
19 %storemerge176 = load i32, i32* %storemerge176.in, align 4
20 store i32 %storemerge176, i32* @A, align 4
21 %cmp20 = icmp eq i32 %storemerge176, %const
22 br i1 %cmp20, label %if.then, label %for.inc
25 %lnot.ext = zext i1 %cmp20 to i32
26 store i32 %lnot.ext, i32* @B, align 4
30 %tmp7 = phi i32 [ %tmp4, %for.body ], [ %lnot.ext, %if.then ]
31 %inc = add nuw nsw i32 %inc.iv, 1
32 %cmp9 = icmp ult i32 %inc, 401
33 br i1 %cmp9, label %for.body, label %exit
39 ; CHECK-LABEL: ne_opaque_minus_one
40 define void @ne_opaque_minus_one(i32* %base) {
42 %const = bitcast i32 -1 to i32
43 %tmp1 = load i32, i32* @B, align 4
46 ; CHECK: edge for.body -> if.then probability is 0x50000000 / 0x80000000 = 62.50%
47 ; CHECK: edge for.body -> for.inc probability is 0x30000000 / 0x80000000 = 37.50%
49 %tmp4 = phi i32 [ %tmp1, %entry ], [ %tmp7, %for.inc ]
50 %inc.iv = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
51 %storemerge176.in = getelementptr inbounds i32, i32* %base, i32 %inc.iv
52 %storemerge176 = load i32, i32* %storemerge176.in, align 4
53 store i32 %storemerge176, i32* @A, align 4
54 %cmp20 = icmp ne i32 %storemerge176, %const
55 br i1 %cmp20, label %if.then, label %for.inc
58 %lnot.ext = zext i1 %cmp20 to i32
59 store i32 %lnot.ext, i32* @B, align 4
63 %tmp7 = phi i32 [ %tmp4, %for.body ], [ %lnot.ext, %if.then ]
64 %inc = add nuw nsw i32 %inc.iv, 1
65 %cmp9 = icmp ult i32 %inc, 401
66 br i1 %cmp9, label %for.body, label %exit
72 ; CHECK-LABEL: sgt_opaque_minus_one
73 define void @sgt_opaque_minus_one(i32* %base) {
75 %const = bitcast i32 -1 to i32
76 %tmp1 = load i32, i32* @B, align 4
79 ; CHECK: edge for.body -> if.then probability is 0x50000000 / 0x80000000 = 62.50%
80 ; CHECK: edge for.body -> for.inc probability is 0x30000000 / 0x80000000 = 37.50%
82 %tmp4 = phi i32 [ %tmp1, %entry ], [ %tmp7, %for.inc ]
83 %inc.iv = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
84 %storemerge176.in = getelementptr inbounds i32, i32* %base, i32 %inc.iv
85 %storemerge176 = load i32, i32* %storemerge176.in, align 4
86 store i32 %storemerge176, i32* @A, align 4
87 %cmp20 = icmp sgt i32 %storemerge176, %const
88 br i1 %cmp20, label %if.then, label %for.inc
91 %lnot.ext = zext i1 %cmp20 to i32
92 store i32 %lnot.ext, i32* @B, align 4
96 %tmp7 = phi i32 [ %tmp4, %for.body ], [ %lnot.ext, %if.then ]
97 %inc = add nuw nsw i32 %inc.iv, 1
98 %cmp9 = icmp ult i32 %inc, 401
99 br i1 %cmp9, label %for.body, label %exit