57 lines · plain
1; RUN: opt -passes=lower-expect -S -o - < %s | FileCheck %s2; RUN: opt -S -passes='function(lower-expect)' < %s | FileCheck %s3 4; return __builtin_expect((a > b ? 1, goo(), 0);5;6; Function Attrs: noinline nounwind uwtable7define i32 @foo(i32 %arg, i32 %arg1) {8; CHECK-LABEL: i32 @foo9bb:10 %tmp5 = icmp sgt i32 %arg, %arg111 br i1 %tmp5, label %bb9, label %bb712; CHECK: br i1 %tmp5{{.*}}!prof [[WEIGHT:![0-9]+]]13 14bb7: ; preds = %bb15 %tmp8 = call i32 @goo()16 br label %bb917 18bb9: ; preds = %bb7, %bb919 %tmp10 = phi i32 [ 1, %bb ], [ %tmp8, %bb7 ]20 %tmp11 = sext i32 %tmp10 to i6421 %expect = call i64 @llvm.expect.i64(i64 %tmp11, i64 0)22 %tmp12 = trunc i64 %expect to i3223 ret i32 %tmp1224}25 26define i32 @foo2(i32 %arg, i32 %arg1) {27bb:28 %tmp5 = icmp sgt i32 %arg, %arg129 br i1 %tmp5, label %bb6, label %bb730; CHECK: br i1 %tmp5{{.*}}!prof [[WEIGHT:![0-9]+]]31 32bb6: ; preds = %bb33 br label %bb934 35bb7: ; preds = %bb36 %tmp8 = call i32 @goo()37 br label %bb938 39bb9: ; preds = %bb7, %bb640 %tmp10 = phi i32 [ 1, %bb6 ], [ %tmp8, %bb7 ]41 %tmp11 = sext i32 %tmp10 to i6442 %expect = call i64 @llvm.expect.i64(i64 %tmp11, i64 0)43 %tmp12 = trunc i64 %expect to i3244 ret i32 %tmp1245}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", !"expected", i32 1, i32 2000}57