xref: /llvm-project/llvm/test/Transforms/CallSiteSplitting/callsite-split.ll (revision 78f2eb8d0f9cf5e8a79b64f6d64deeb487502e38)
1cee313d2SEric Christopher; RUN: opt < %s -passes='function(callsite-splitting),cgscc(inline),function(instcombine,jump-threading)' -S | FileCheck %s
2cee313d2SEric Christopher
3cee313d2SEric Christophertarget datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
4*78f2eb8dSFangrui Songtarget triple = "aarch64"
5cee313d2SEric Christopher
6055fb779SNikita Popov%struct.bitmap = type { i32, ptr }
7cee313d2SEric Christopher
8cee313d2SEric Christopher;CHECK-LABEL: @caller
9cee313d2SEric Christopher;CHECK-LABEL: Top.split:
10055fb779SNikita Popov;CHECK: call void @callee(ptr null, ptr null, ptr %b_elt, i1 false)
11cee313d2SEric Christopher;CHECK-LABEL: NextCond:
12cee313d2SEric Christopher;CHECK: br {{.*}} label %callee.exit
13cee313d2SEric Christopher;CHECK-LABEL: callee.exit:
14055fb779SNikita Popov;CHECK: call void @dummy2(ptr %a_elt)
15cee313d2SEric Christopher
16055fb779SNikita Popovdefine void @caller(i1 %c, ptr %a_elt, ptr %b_elt) {
17cee313d2SEric Christopherentry:
18cee313d2SEric Christopher  br label %Top
19cee313d2SEric Christopher
20cee313d2SEric ChristopherTop:
21055fb779SNikita Popov  %tobool1 = icmp eq ptr %a_elt, null
22cee313d2SEric Christopher  br i1 %tobool1, label %CallSiteBB, label %NextCond
23cee313d2SEric Christopher
24cee313d2SEric ChristopherNextCond:
25055fb779SNikita Popov  %cmp = icmp ne ptr %b_elt, null
26cee313d2SEric Christopher  br i1 %cmp, label %CallSiteBB, label %End
27cee313d2SEric Christopher
28cee313d2SEric ChristopherCallSiteBB:
29cee313d2SEric Christopher  %p = phi i1 [0, %Top], [%c, %NextCond]
30055fb779SNikita Popov  call void @callee(ptr %a_elt, ptr %a_elt, ptr %b_elt, i1 %p)
31cee313d2SEric Christopher  br label %End
32cee313d2SEric Christopher
33cee313d2SEric ChristopherEnd:
34cee313d2SEric Christopher  ret void
35cee313d2SEric Christopher}
36cee313d2SEric Christopher
37055fb779SNikita Popovdefine void @callee(ptr %dst_elt, ptr %a_elt, ptr %b_elt, i1 %c) {
38cee313d2SEric Christopherentry:
39055fb779SNikita Popov  %tobool = icmp ne ptr %a_elt, null
40055fb779SNikita Popov  %tobool1 = icmp ne ptr %b_elt, null
41cee313d2SEric Christopher  %or.cond = and i1 %tobool, %tobool1
42cee313d2SEric Christopher  br i1 %or.cond, label %Cond, label %Big
43cee313d2SEric Christopher
44cee313d2SEric ChristopherCond:
45055fb779SNikita Popov  %cmp = icmp eq ptr  %dst_elt, %a_elt
46cee313d2SEric Christopher  br i1 %cmp, label %Small, label %Big
47cee313d2SEric Christopher
48cee313d2SEric ChristopherSmall:
49055fb779SNikita Popov  call void @dummy2(ptr %a_elt)
50cee313d2SEric Christopher  br label %End
51cee313d2SEric Christopher
52cee313d2SEric ChristopherBig:
53055fb779SNikita Popov  call void @dummy1(ptr %a_elt, ptr %a_elt, ptr %a_elt, ptr %a_elt, ptr %a_elt, ptr %a_elt)
54055fb779SNikita Popov  call void @dummy1(ptr %a_elt, ptr %a_elt, ptr %a_elt, ptr %a_elt, ptr %a_elt, ptr %a_elt)
55055fb779SNikita Popov  call void @dummy1(ptr %a_elt, ptr %a_elt, ptr %a_elt, ptr %a_elt, ptr %a_elt, ptr %a_elt)
56055fb779SNikita Popov  call void @dummy1(ptr %a_elt, ptr %a_elt, ptr %a_elt, ptr %a_elt, ptr %a_elt, ptr %a_elt)
57055fb779SNikita Popov  call void @dummy1(ptr %a_elt, ptr %a_elt, ptr %a_elt, ptr %a_elt, ptr %a_elt, ptr %a_elt)
58055fb779SNikita Popov  call void @dummy1(ptr %a_elt, ptr %a_elt, ptr %a_elt, ptr %a_elt, ptr %a_elt, ptr %a_elt)
59055fb779SNikita Popov  call void @dummy1(ptr %a_elt, ptr %a_elt, ptr %a_elt, ptr %a_elt, ptr %a_elt, ptr %a_elt)
60cee313d2SEric Christopher  br label %End
61cee313d2SEric Christopher
62cee313d2SEric ChristopherEnd:
63cee313d2SEric Christopher  ret void
64cee313d2SEric Christopher}
65cee313d2SEric Christopher
66055fb779SNikita Popovdeclare void @dummy2(ptr)
67055fb779SNikita Popovdeclare void @dummy1(ptr, ptr, ptr, ptr, ptr, ptr)
68cee313d2SEric Christopher
69cee313d2SEric Christopher
70cee313d2SEric Christopher;CHECK-LABEL: @caller2
71cee313d2SEric Christopher;CHECK-LABEL: Top.split:
72cee313d2SEric Christopher;CHECK: call void @dummy4()
73cee313d2SEric Christopher;CHECK-LABEL: NextCond.split:
74cee313d2SEric Christopher;CHECK: call void @dummy3()
75cee313d2SEric Christopher;CheCK-LABEL: CallSiteBB:
764def99e6SRoman Lebedev;CHECK: call void @foo(i1 %tobool1)
77055fb779SNikita Popovdefine void @caller2(i1 %c, ptr %a_elt, ptr %b_elt, ptr %c_elt) {
78cee313d2SEric Christopherentry:
79cee313d2SEric Christopher  br label %Top
80cee313d2SEric Christopher
81cee313d2SEric ChristopherTop:
82055fb779SNikita Popov  %tobool1 = icmp eq ptr %a_elt, %b_elt
83cee313d2SEric Christopher  br i1 %tobool1, label %CallSiteBB, label %NextCond
84cee313d2SEric Christopher
85cee313d2SEric ChristopherNextCond:
86055fb779SNikita Popov  %cmp = icmp ne ptr %b_elt, %c_elt
87cee313d2SEric Christopher  br i1 %cmp, label %CallSiteBB, label %End
88cee313d2SEric Christopher
89cee313d2SEric ChristopherCallSiteBB:
90cee313d2SEric Christopher  %phi = phi i1 [0, %Top],[1, %NextCond]
91cee313d2SEric Christopher  %u = call i1 @callee2(i1 %phi)
92cee313d2SEric Christopher  call void @foo(i1 %u)
93cee313d2SEric Christopher  br label %End
94cee313d2SEric Christopher
95cee313d2SEric ChristopherEnd:
96cee313d2SEric Christopher  ret void
97cee313d2SEric Christopher}
98cee313d2SEric Christopher
99cee313d2SEric Christopherdefine i1 @callee2(i1 %b) {
100cee313d2SEric Christopherentry:
101cee313d2SEric Christopher  br i1 %b, label %BB1, label %BB2
102cee313d2SEric Christopher
103cee313d2SEric ChristopherBB1:
104cee313d2SEric Christopher  call void @dummy3()
105cee313d2SEric Christopher  br label %End
106cee313d2SEric Christopher
107cee313d2SEric ChristopherBB2:
108cee313d2SEric Christopher  call void @dummy4()
109cee313d2SEric Christopher  br label %End
110cee313d2SEric Christopher
111cee313d2SEric ChristopherEnd:
112cee313d2SEric Christopher  ret i1 %b
113cee313d2SEric Christopher}
114cee313d2SEric Christopher
115cee313d2SEric Christopherdeclare void @dummy3()
116cee313d2SEric Christopherdeclare void @dummy4()
117cee313d2SEric Christopherdeclare void @foo(i1)
118