Home | History | Annotate | Download | only in SimplifyCFG
      1 ; RUN: opt -simplifycfg -S -o - < %s | FileCheck %s
      2 
      3 declare void @helper(i32)
      4 
      5 define void @test1(i1 %a, i1 %b) {
      6 ; CHECK: @test1
      7 entry:
      8   br i1 %a, label %Y, label %X, !prof !0
      9 ; CHECK: br i1 %or.cond, label %Z, label %Y, !prof !0
     10 
     11 X:
     12   %c = or i1 %b, false
     13   br i1 %c, label %Z, label %Y, !prof !1
     14 
     15 Y:
     16   call void @helper(i32 0)
     17   ret void
     18 
     19 Z:
     20   call void @helper(i32 1)
     21   ret void
     22 }
     23 
     24 define void @test2(i1 %a, i1 %b) {
     25 ; CHECK: @test2
     26 entry:
     27   br i1 %a, label %X, label %Y, !prof !1
     28 ; CHECK: br i1 %or.cond, label %Z, label %Y, !prof !1
     29 ; CHECK-NOT: !prof
     30 
     31 X:
     32   %c = or i1 %b, false
     33   br i1 %c, label %Z, label %Y, !prof !2
     34 
     35 Y:
     36   call void @helper(i32 0)
     37   ret void
     38 
     39 Z:
     40   call void @helper(i32 1)
     41   ret void
     42 }
     43 
     44 define void @test3(i1 %a, i1 %b) {
     45 ; CHECK: @test3
     46 ; CHECK-NOT: !prof
     47 entry:
     48   br i1 %a, label %X, label %Y, !prof !1
     49 
     50 X:
     51   %c = or i1 %b, false
     52   br i1 %c, label %Z, label %Y
     53 
     54 Y:
     55   call void @helper(i32 0)
     56   ret void
     57 
     58 Z:
     59   call void @helper(i32 1)
     60   ret void
     61 }
     62 
     63 define void @test4(i1 %a, i1 %b) {
     64 ; CHECK: @test4
     65 ; CHECK-NOT: !prof
     66 entry:
     67   br i1 %a, label %X, label %Y
     68 
     69 X:
     70   %c = or i1 %b, false
     71   br i1 %c, label %Z, label %Y, !prof !1
     72 
     73 Y:
     74   call void @helper(i32 0)
     75   ret void
     76 
     77 Z:
     78   call void @helper(i32 1)
     79   ret void
     80 }
     81 
     82 !0 = metadata !{metadata !"branch_weights", i32 3, i32 5}
     83 !1 = metadata !{metadata !"branch_weights", i32 1, i32 1}
     84 !2 = metadata !{metadata !"branch_weights", i32 1, i32 2}
     85 
     86 ; CHECK: !0 = metadata !{metadata !"branch_weights", i32 5, i32 11}
     87 ; CHECK: !1 = metadata !{metadata !"branch_weights", i32 1, i32 5}
     88 ; CHECK-NOT: !2
     89