Home | History | Annotate | Download | only in CallSiteSplitting
      1 ; RUN: opt < %s -callsite-splitting -inline -instcombine -jump-threading -S | FileCheck %s
      2 ; RUN: opt < %s  -passes='function(callsite-splitting),cgscc(inline),function(instcombine,jump-threading)' -S | FileCheck %s
      3 
      4 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
      5 target triple = "aarch64-linaro-linux-gnueabi"
      6 
      7 %struct.bitmap = type { i32, %struct.bitmap* }
      8 
      9 ;CHECK-LABEL: @caller
     10 ;CHECK-LABEL: Top.split:
     11 ;CHECK: call void @callee(%struct.bitmap* null, %struct.bitmap* null, %struct.bitmap* %b_elt, i1 false)
     12 ;CHECK-LABEL: NextCond:
     13 ;CHECK: br {{.*}} label %callee.exit
     14 ;CHECK-LABEL: callee.exit:
     15 ;CHECK: call void @dummy2(%struct.bitmap* %a_elt)
     16 
     17 define void @caller(i1 %c, %struct.bitmap* %a_elt, %struct.bitmap* %b_elt) {
     18 entry:
     19   br label %Top
     20 
     21 Top:
     22   %tobool1 = icmp eq %struct.bitmap* %a_elt, null
     23   br i1 %tobool1, label %CallSiteBB, label %NextCond
     24 
     25 NextCond:
     26   %cmp = icmp ne %struct.bitmap* %b_elt, null
     27   br i1 %cmp, label %CallSiteBB, label %End
     28 
     29 CallSiteBB:
     30   %p = phi i1 [0, %Top], [%c, %NextCond]
     31   call void @callee(%struct.bitmap* %a_elt, %struct.bitmap* %a_elt, %struct.bitmap* %b_elt, i1 %p)
     32   br label %End
     33 
     34 End:
     35   ret void
     36 }
     37 
     38 define void @callee(%struct.bitmap* %dst_elt, %struct.bitmap* %a_elt, %struct.bitmap* %b_elt, i1 %c) {
     39 entry:
     40   %tobool = icmp ne %struct.bitmap* %a_elt, null
     41   %tobool1 = icmp ne %struct.bitmap* %b_elt, null
     42   %or.cond = and i1 %tobool, %tobool1
     43   br i1 %or.cond, label %Cond, label %Big
     44 
     45 Cond:
     46   %cmp = icmp eq %struct.bitmap*  %dst_elt, %a_elt
     47   br i1 %cmp, label %Small, label %Big
     48 
     49 Small:
     50   call void @dummy2(%struct.bitmap* %a_elt)
     51   br label %End
     52 
     53 Big:
     54   call void @dummy1(%struct.bitmap* %a_elt, %struct.bitmap* %a_elt, %struct.bitmap* %a_elt, %struct.bitmap* %a_elt, %struct.bitmap* %a_elt, %struct.bitmap* %a_elt)
     55   call void @dummy1(%struct.bitmap* %a_elt, %struct.bitmap* %a_elt, %struct.bitmap* %a_elt, %struct.bitmap* %a_elt, %struct.bitmap* %a_elt, %struct.bitmap* %a_elt)
     56   call void @dummy1(%struct.bitmap* %a_elt, %struct.bitmap* %a_elt, %struct.bitmap* %a_elt, %struct.bitmap* %a_elt, %struct.bitmap* %a_elt, %struct.bitmap* %a_elt)
     57   call void @dummy1(%struct.bitmap* %a_elt, %struct.bitmap* %a_elt, %struct.bitmap* %a_elt, %struct.bitmap* %a_elt, %struct.bitmap* %a_elt, %struct.bitmap* %a_elt)
     58   call void @dummy1(%struct.bitmap* %a_elt, %struct.bitmap* %a_elt, %struct.bitmap* %a_elt, %struct.bitmap* %a_elt, %struct.bitmap* %a_elt, %struct.bitmap* %a_elt)
     59   call void @dummy1(%struct.bitmap* %a_elt, %struct.bitmap* %a_elt, %struct.bitmap* %a_elt, %struct.bitmap* %a_elt, %struct.bitmap* %a_elt, %struct.bitmap* %a_elt)
     60   call void @dummy1(%struct.bitmap* %a_elt, %struct.bitmap* %a_elt, %struct.bitmap* %a_elt, %struct.bitmap* %a_elt, %struct.bitmap* %a_elt, %struct.bitmap* %a_elt)
     61   br label %End
     62 
     63 End:
     64   ret void
     65 }
     66 
     67 declare void @dummy2(%struct.bitmap*)
     68 declare void @dummy1(%struct.bitmap*, %struct.bitmap*, %struct.bitmap*, %struct.bitmap*, %struct.bitmap*, %struct.bitmap*)
     69 
     70 
     71 ;CHECK-LABEL: @caller2
     72 ;CHECK-LABEL: Top.split:
     73 ;CHECK: call void @dummy4()
     74 ;CHECK-LABEL: NextCond.split:
     75 ;CHECK: call void @dummy3()
     76 ;CheCK-LABEL: CallSiteBB:
     77 ;CHECK: %phi.call = phi i1 [ true, %NextCond.split ], [ false, %Top.split ]
     78 ;CHECK: call void @foo(i1 %phi.call)
     79 define void @caller2(i1 %c, %struct.bitmap* %a_elt, %struct.bitmap* %b_elt, %struct.bitmap* %c_elt) {
     80 entry:
     81   br label %Top
     82 
     83 Top:
     84   %tobool1 = icmp eq %struct.bitmap* %a_elt, %b_elt
     85   br i1 %tobool1, label %CallSiteBB, label %NextCond
     86 
     87 NextCond:
     88   %cmp = icmp ne %struct.bitmap* %b_elt, %c_elt
     89   br i1 %cmp, label %CallSiteBB, label %End
     90 
     91 CallSiteBB:
     92   %phi = phi i1 [0, %Top],[1, %NextCond]
     93   %u = call i1 @callee2(i1 %phi)
     94   call void @foo(i1 %u)
     95   br label %End
     96 
     97 End:
     98   ret void
     99 }
    100 
    101 define i1 @callee2(i1 %b) {
    102 entry:
    103   br i1 %b, label %BB1, label %BB2
    104 
    105 BB1:
    106   call void @dummy3()
    107   br label %End
    108 
    109 BB2:
    110   call void @dummy4()
    111   br label %End
    112 
    113 End:
    114   ret i1 %b
    115 }
    116 
    117 declare void @dummy3()
    118 declare void @dummy4()
    119 declare void @foo(i1)
    120