1 ; RUN: opt < %s -passes='print<branch-prob>' -disable-output 2>&1 | FileCheck %s
3 ; Since neither of while.body's out-edges is an exit or a back edge,
4 ; calcLoopBranchHeuristics should return early without setting the weights.
5 ; calcFloatingPointHeuristics, which is run later, sets the weights.
7 ; CHECK: edge %while.body -> %if.then probability is 0x50000000 / 0x80000000 = 62.50%
8 ; CHECK: edge %while.body -> %if.else probability is 0x30000000 / 0x80000000 = 37.50%
10 define void @foo1(i32 %n, ptr nocapture %b, ptr nocapture %c, ptr nocapture %d, ptr nocapture readonly %f0, ptr nocapture readonly %f1) {
12 %tobool8 = icmp eq i32 %n, 0
13 br i1 %tobool8, label %while.end, label %while.body.lr.ph
16 %0 = sext i32 %n to i64
20 %indvars.iv = phi i64 [ %0, %while.body.lr.ph ], [ %indvars.iv.next, %if.end ]
21 %b.addr.011 = phi ptr [ %b, %while.body.lr.ph ], [ %b.addr.1, %if.end ]
22 %d.addr.010 = phi ptr [ %d, %while.body.lr.ph ], [ %incdec.ptr4, %if.end ]
23 %c.addr.09 = phi ptr [ %c, %while.body.lr.ph ], [ %c.addr.1, %if.end ]
24 %indvars.iv.next = add nsw i64 %indvars.iv, -1
25 %arrayidx = getelementptr inbounds float, ptr %f0, i64 %indvars.iv.next
26 %1 = load float, ptr %arrayidx, align 4
27 %arrayidx2 = getelementptr inbounds float, ptr %f1, i64 %indvars.iv.next
28 %2 = load float, ptr %arrayidx2, align 4
29 %cmp = fcmp une float %1, %2
30 br i1 %cmp, label %if.then, label %if.else
33 %incdec.ptr = getelementptr inbounds i32, ptr %b.addr.011, i64 1
34 %3 = load i32, ptr %b.addr.011, align 4
35 %add = add nsw i32 %3, 12
36 store i32 %add, ptr %b.addr.011, align 4
40 %incdec.ptr3 = getelementptr inbounds i32, ptr %c.addr.09, i64 1
41 %4 = load i32, ptr %c.addr.09, align 4
42 %sub = add nsw i32 %4, -13
43 store i32 %sub, ptr %c.addr.09, align 4
47 %c.addr.1 = phi ptr [ %c.addr.09, %if.then ], [ %incdec.ptr3, %if.else ]
48 %b.addr.1 = phi ptr [ %incdec.ptr, %if.then ], [ %b.addr.011, %if.else ]
49 %incdec.ptr4 = getelementptr inbounds i32, ptr %d.addr.010, i64 1
50 store i32 14, ptr %d.addr.010, align 4
51 %5 = trunc i64 %indvars.iv.next to i32
52 %tobool = icmp eq i32 %5, 0
53 br i1 %tobool, label %while.end, label %while.body