59 lines · plain
1; RUN: opt < %s -passes='print<branch-prob>' -disable-output 2>&1 | FileCheck %s2 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.6;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%9 10define void @foo1(i32 %n, ptr nocapture %b, ptr nocapture %c, ptr nocapture %d, ptr nocapture readonly %f0, ptr nocapture readonly %f1) {11entry:12 %tobool8 = icmp eq i32 %n, 013 br i1 %tobool8, label %while.end, label %while.body.lr.ph14 15while.body.lr.ph:16 %0 = sext i32 %n to i6417 br label %while.body18 19while.body: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, -125 %arrayidx = getelementptr inbounds float, ptr %f0, i64 %indvars.iv.next26 %1 = load float, ptr %arrayidx, align 427 %arrayidx2 = getelementptr inbounds float, ptr %f1, i64 %indvars.iv.next28 %2 = load float, ptr %arrayidx2, align 429 %cmp = fcmp une float %1, %230 br i1 %cmp, label %if.then, label %if.else31 32if.then:33 %incdec.ptr = getelementptr inbounds i32, ptr %b.addr.011, i64 134 %3 = load i32, ptr %b.addr.011, align 435 %add = add nsw i32 %3, 1236 store i32 %add, ptr %b.addr.011, align 437 br label %if.end38 39if.else:40 %incdec.ptr3 = getelementptr inbounds i32, ptr %c.addr.09, i64 141 %4 = load i32, ptr %c.addr.09, align 442 %sub = add nsw i32 %4, -1343 store i32 %sub, ptr %c.addr.09, align 444 br label %if.end45 46if.end: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 150 store i32 14, ptr %d.addr.010, align 451 %5 = trunc i64 %indvars.iv.next to i3252 %tobool = icmp eq i32 %5, 053 br i1 %tobool, label %while.end, label %while.body54 55while.end:56 ret void57}58 59