1; RUN: opt < %s -analyze -branch-prob -enable-new-pm=0 | FileCheck %s 2; RUN: opt < %s -analyze -lazy-branch-prob -enable-new-pm=0 | FileCheck %s 3; RUN: opt < %s -passes='print<branch-prob>' -disable-output 2>&1 | FileCheck %s 4 5declare void @g(i32) 6 7; Check correctness of reported probabilities in case of multiple edges between 8; basic blocks. In this case sum of probabilities over all edges should be 9; returned by BranchProbabilityInfo::getEdgeProbability. 10 11define void @test1(i32 %x) { 12;CHECK: edge entry -> return probability is 0x0ccccccd / 0x80000000 = 10.00% 13;CHECK: edge entry -> bb0 probability is 0x26666666 / 0x80000000 = 30.00% 14;CHECK: edge entry -> bb0 probability is 0x26666666 / 0x80000000 = 30.00% 15;CHECK: edge entry -> bb0 probability is 0x26666666 / 0x80000000 = 30.00% 16;CHECK: edge entry -> bb1 probability is 0x26666666 / 0x80000000 = 30.00% 17;CHECK: edge entry -> bb1 probability is 0x26666666 / 0x80000000 = 30.00% 18;CHECK: edge entry -> bb1 probability is 0x26666666 / 0x80000000 = 30.00% 19;CHECK: edge entry -> bb2 probability is 0x26666666 / 0x80000000 = 30.00% 20;CHECK: edge entry -> bb2 probability is 0x26666666 / 0x80000000 = 30.00% 21;CHECK: edge entry -> bb2 probability is 0x26666666 / 0x80000000 = 30.00% 22;CHECK: edge bb0 -> return probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] 23;CHECK: edge bb1 -> return probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] 24;CHECK: edge bb2 -> return probability is 0x80000000 / 0x80000000 = 100.00% [HOT edge] 25 26entry: 27 switch i32 %x, label %return [ 28 i32 0, label %bb0 29 i32 3, label %bb0 30 i32 6, label %bb0 31 i32 1, label %bb1 32 i32 4, label %bb1 33 i32 7, label %bb1 34 i32 2, label %bb2 35 i32 5, label %bb2 36 i32 8, label %bb2 37 ] 38 39bb0: ; preds = %entry, %entry, %entry 40 tail call void @g(i32 0) 41 br label %return 42 43bb1: ; preds = %entry, %entry, %entry 44 tail call void @g(i32 1) 45 br label %return 46 47bb2: ; preds = %entry, %entry, %entry 48 tail call void @g(i32 2) 49 br label %return 50 51return: ; preds = %bb2, %bb1, %bb0, %entry 52 ret void 53} 54