xref: /llvm-project/llvm/test/Transforms/FunctionSpecialization/function-specialization-minsize3.ll (revision e15d72adac66790a78a51a3087b56b2bde6b778a)
1; RUN: opt -passes="ipsccp<func-spec>" -funcspec-min-function-size=3 -S < %s | FileCheck %s
2
3; Checks for callsites that have been annotated with MinSize. We only expect
4; specialisation for the call that does not have the attribute:
5;
6; CHECK: plus:
7; CHECK:   %tmp0 = call i64 @compute.specialized.1(i64 %x, ptr @plus)
8; CHECK:   br label %merge
9; CHECK: minus:
10; CHECK:   %tmp1 = call i64 @compute(i64 %x, ptr @minus) #0
11; CHECK:   br label %merge
12;
13define i64 @main(i64 %x, i1 %flag) {
14entry:
15  br i1 %flag, label %plus, label %minus
16
17plus:
18  %tmp0 = call i64 @compute(i64 %x, ptr @plus)
19  br label %merge
20
21minus:
22  %tmp1 = call i64 @compute(i64 %x, ptr @minus) #0
23  br label %merge
24
25merge:
26  %tmp2 = phi i64 [ %tmp0, %plus ], [ %tmp1, %minus]
27  ret i64 %tmp2
28}
29
30define internal i64 @compute(i64 %x, ptr %binop) {
31entry:
32  %tmp0 = call i64 %binop(i64 %x)
33  ret i64 %tmp0
34}
35
36define internal i64 @plus(i64 %x) {
37entry:
38  %tmp0 = add i64 %x, 1
39  ret i64 %tmp0
40}
41
42define internal i64 @minus(i64 %x) {
43entry:
44  %tmp0 = sub i64 %x, 1
45  ret i64 %tmp0
46}
47
48attributes #0 = { minsize optsize }
49