1; RUN: opt -lower-expect -S -o - < %s | FileCheck %s 2; RUN: opt -S -passes='function(lower-expect)' < %s | FileCheck %s 3 4; return __builtin_expect((a > b ? 1, goo(), 0); 5; 6; Function Attrs: noinline nounwind uwtable 7define i32 @foo(i32 %arg, i32 %arg1) { 8; CHECK-LABEL: i32 @foo 9bb: 10 %tmp5 = icmp sgt i32 %arg, %arg1 11 br i1 %tmp5, label %bb9, label %bb7 12; CHECK: br i1 %tmp5{{.*}}!prof [[WEIGHT:![0-9]+]] 13 14bb7: ; preds = %bb 15 %tmp8 = call i32 @goo() 16 br label %bb9 17 18bb9: ; preds = %bb7, %bb9 19 %tmp10 = phi i32 [ 1, %bb ], [ %tmp8, %bb7 ] 20 %tmp11 = sext i32 %tmp10 to i64 21 %expect = call i64 @llvm.expect.i64(i64 %tmp11, i64 0) 22 %tmp12 = trunc i64 %expect to i32 23 ret i32 %tmp12 24} 25 26define i32 @foo2(i32 %arg, i32 %arg1) { 27bb: 28 %tmp5 = icmp sgt i32 %arg, %arg1 29 br i1 %tmp5, label %bb6, label %bb7 30; CHECK: br i1 %tmp5{{.*}}!prof [[WEIGHT:![0-9]+]] 31 32bb6: ; preds = %bb 33 br label %bb9 34 35bb7: ; preds = %bb 36 %tmp8 = call i32 @goo() 37 br label %bb9 38 39bb9: ; preds = %bb7, %bb6 40 %tmp10 = phi i32 [ 1, %bb6 ], [ %tmp8, %bb7 ] 41 %tmp11 = sext i32 %tmp10 to i64 42 %expect = call i64 @llvm.expect.i64(i64 %tmp11, i64 0) 43 %tmp12 = trunc i64 %expect to i32 44 ret i32 %tmp12 45} 46 47declare i32 @goo() 48declare i64 @llvm.expect.i64(i64, i64) 49 50 51 52!llvm.ident = !{!0} 53 54!0 = !{!"clang version 5.0.0 (trunk 302965)"} 55 56; CHECK: [[WEIGHT]] = !{!"branch_weights", i32 1, i32 2000} 57