43 lines · plain
1; RUN: opt -debug-only=branch-prob -passes=jump-threading -S %s 2>&1 | FileCheck %s2; REQUIRES: asserts3 4; Make sure that edges' probabilities would not accumulate if they are5; the same target BB.6; Edge L0 -> 2 and L0 -> 3 's targets are both L2, but their respective7; probability should not be L0 -> L2, because prob[L0->L2] equls to8; prob[L0->2] + prob[L0->3]9 10; CHECK: Computing probabilities for entry11; CHECK: eraseBlock L012; CHECK-NOT: set edge L0 -> 0 successor probability to 0x12492492 / 0x80000000 = 14.29%13; CHECK-NOT: set edge L0 -> 1 successor probability to 0x24924925 / 0x80000000 = 28.57%14; CHECK-NOT: set edge L0 -> 2 successor probability to 0x24924925 / 0x80000000 = 28.57%15; CHECK-NOT: set edge L0 -> 3 successor probability to 0x24924925 / 0x80000000 = 28.57%16; CHECK: set edge L0 -> 0 successor probability to 0x1999999a / 0x80000000 = 20.00%17; CHECK: set edge L0 -> 1 successor probability to 0x33333333 / 0x80000000 = 40.00%18; CHECK: set edge L0 -> 2 successor probability to 0x1999999a / 0x80000000 = 20.00%19; CHECK: set edge L0 -> 3 successor probability to 0x1999999a / 0x80000000 = 20.00%20; CHECK-NOT: !0 = !{!"branch_weights", i32 306783378, i32 613566757, i32 613566757, i32 613566757}21; CHECK: !0 = !{!"branch_weights", i32 429496730, i32 858993459, i32 429496730, i32 429496730}22define void @test_switch(i1 %cond, i8 %value) nounwind {23entry:24 br i1 %cond, label %L0, label %L425L0:26 %expr = select i1 %cond, i8 1, i8 %value27 switch i8 %expr, label %L3 [28 i8 1, label %L129 i8 2, label %L230 i8 3, label %L231 ], !prof !032 33L1:34 ret void35L2:36 ret void37L3:38 ret void39L4:40 br label %L041}42!0 = !{!"branch_weights", i32 1, i32 7, i32 1, i32 1}43