1 ; RUN: opt -passes="ipsccp<func-spec>" -funcspec-min-function-size=3 -S < %s | FileCheck %s
3 define i64 @main(i64 %x, i1 %flag) {
5 br i1 %flag, label %plus, label %minus
8 %tmp0 = call i64 @compute(i64 %x, ptr @plus)
12 %tmp1 = call i64 @compute(i64 %x, ptr @minus)
16 %tmp2 = phi i64 [ %tmp0, %plus ], [ %tmp1, %minus]
20 ; CHECK-NOT: define internal i64 @compute(
22 ; CHECK-LABEL: define internal i64 @compute.specialized.1(i64 %n, ptr %binop) {
23 ; CHECK: [[TMP0:%.+]] = call i64 @plus(i64 %n)
24 ; CHECK: [[TMP1:%.+]] = call i64 @compute.specialized.1(i64 [[TMP2:%.+]], ptr @plus)
25 ; CHECK: add nsw i64 [[TMP1]], [[TMP0]]
27 ; CHECK-LABEL: define internal i64 @compute.specialized.2(i64 %n, ptr %binop) {
28 ; CHECK: [[TMP0:%.+]] = call i64 @minus(i64 %n)
29 ; CHECK: [[TMP1:%.+]] = call i64 @compute.specialized.2(i64 [[TMP2:%.+]], ptr @minus)
30 ; CHECK: add nsw i64 [[TMP1]], [[TMP0]]
32 define internal i64 @compute(i64 %n, ptr %binop) {
34 %cmp = icmp sgt i64 %n, 0
35 br i1 %cmp, label %if.then, label %if.end
38 %call = call i64 %binop(i64 %n)
39 %sub = add nsw i64 %n, -1
40 %call1 = call i64 @compute(i64 %sub, ptr %binop)
41 %add2 = add nsw i64 %call1, %call
45 %result.0 = phi i64 [ %add2, %if.then ], [ 0, %entry ]
49 define internal i64 @plus(i64 %x) {
55 define internal i64 @minus(i64 %x) {