brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.2 KiB · e9a8432 Raw
104 lines · plain
1; RUN: opt -passes=lower-expect  -S -o - < %s | FileCheck %s2; RUN: opt -S -passes='function(lower-expect)' < %s | FileCheck %s3;4; if (__builtin_expect((x > goo() || y > hoo()), 1)) {5;  ..6; }7; For the above case, only the second branch should be8; annotated.9; if (__builtin_expect((x > goo() || y > hoo()), 0)) {10;  ..11; }12; For the above case, two branches should be annotated.13; Function Attrs: noinline nounwind uwtable14define void @foo(i32 %arg, i32 %arg1, i32 %arg2, i32 %arg3)  {15; CHECK-LABEL: void @foo16bb:17  %tmp8 = call i32 @goo()18  %tmp9 = icmp slt i32 %arg, %tmp819  br i1 %tmp9, label %bb14, label %bb1020; CHECK: br i1 %tmp921; CHECK-NOT: br i1 %tmp9{{.*}}!prof22 23bb10:                                             ; preds = %bb24  %tmp12 = call i32  @hoo()25  %tmp13 = icmp sgt i32 %arg1, %tmp1226  br label %bb1427 28bb14:                                             ; preds = %bb10, %bb29  %tmp15 = phi i1 [ true, %bb ], [ %tmp13, %bb10 ]30  %tmp16 = zext i1 %tmp15 to i3231  %tmp17 = sext i32 %tmp16 to i6432  %expect = call i64 @llvm.expect.i64(i64 %tmp17, i64 1)33  %tmp18 = icmp ne i64 %expect, 034  br i1 %tmp18, label %bb19, label %bb2135; CHECK: br i1 %tmp18{{.*}}!prof [[WEIGHT:![0-9]+]]36 37bb19:                                             ; preds = %bb1438  %tmp20 = call i32 @goo()39  br label %bb2340 41bb21:                                             ; preds = %bb1442  %tmp22 = call i32  @hoo()43  br label %bb2344 45bb23:                                             ; preds = %bb21, %bb1946  ret void47}48 49define void @foo2(i32 %arg, i32 %arg1, i32 %arg2, i32 %arg3)  {50; CHECK-LABEL: void @foo251bb:52  %tmp = alloca i32, align 453  %tmp4 = alloca i32, align 454  %tmp5 = alloca i32, align 455  %tmp6 = alloca i32, align 456  store i32 %arg, ptr %tmp, align 457  store i32 %arg1, ptr %tmp4, align 458  store i32 %arg2, ptr %tmp5, align 459  store i32 %arg3, ptr %tmp6, align 460  %tmp7 = load i32, ptr %tmp, align 461  %tmp8 = call i32  @goo()62  %tmp9 = icmp slt i32 %tmp7, %tmp863  br i1 %tmp9, label %bb14, label %bb1064; CHECK: br i1 %tmp9{{.*}}!prof [[WEIGHT2:![0-9]+]]65 66bb10:                                             ; preds = %bb67  %tmp11 = load i32, ptr %tmp5, align 468  %tmp12 = call i32 @hoo()69  %tmp13 = icmp sgt i32 %tmp11, %tmp1270  br label %bb1471 72bb14:                                             ; preds = %bb10, %bb73  %tmp15 = phi i1 [ true, %bb ], [ %tmp13, %bb10 ]74  %tmp16 = zext i1 %tmp15 to i3275  %tmp17 = sext i32 %tmp16 to i6476  %expect = call i64 @llvm.expect.i64(i64 %tmp17, i64 0)77  %tmp18 = icmp ne i64 %expect, 078  br i1 %tmp18, label %bb19, label %bb2179; CHECK: br i1 %tmp18{{.*}}!prof [[WEIGHT2]]80 81bb19:                                             ; preds = %bb1482  %tmp20 = call i32 @goo()83  br label %bb2384 85bb21:                                             ; preds = %bb1486  %tmp22 = call i32 @hoo()87  br label %bb2388 89bb23:                                             ; preds = %bb21, %bb1990  ret void91}92 93declare i32 @goo()94declare i32 @hoo()95declare i64 @llvm.expect.i64(i64, i64)96 97 98!llvm.ident = !{!0}99 100 101!0 = !{!"clang version 5.0.0 (trunk 302965)"}102; CHECK: [[WEIGHT]] = !{!"branch_weights", !"expected", i32 2000, i32 1}103; CHECK: [[WEIGHT2]] = !{!"branch_weights", !"expected", i32 1, i32 2000}104