1 ; RUN: opt -passes="ipsccp<func-spec>" -force-specialization -funcspec-for-literal-constant -funcspec-max-iters=3 -S < %s | FileCheck %s
4 ; CHECK: define i64 @main
6 ; CHECK-NEXT: [[C1:%.*]] = call i64 @foo.specialized.1(i1 true, i64 3, i64 1)
7 ; CHECK-NEXT: [[C2:%.*]] = call i64 @foo.specialized.2(i1 false, i64 4, i64 -1)
8 ; CHECK-NEXT: ret i64 8
11 %c1 = call i64 @foo(i1 true, i64 3, i64 1)
12 %c2 = call i64 @foo(i1 false, i64 4, i64 -1)
13 %add = add i64 %c1, %c2
17 define internal i64 @foo(i1 %flag, i64 %m, i64 %n) {
19 ; CHECK: define internal i64 @foo.specialized.1
21 ; CHECK-NEXT: br label %plus
23 ; CHECK-NEXT: [[N0:%.*]] = call i64 @binop.specialized.4(i64 3, i64 1)
24 ; CHECK-NEXT: [[RES0:%.*]] = call i64 @bar.specialized.6(i64 4)
25 ; CHECK-NEXT: br label %merge
27 ; CHECK-NEXT: ret i64 undef
29 ; CHECK: define internal i64 @foo.specialized.2
31 ; CHECK-NEXT: br label %minus
33 ; CHECK-NEXT: [[N1:%.*]] = call i64 @binop.specialized.3(i64 4, i64 -1)
34 ; CHECK-NEXT: [[RES1:%.*]] = call i64 @bar.specialized.5(i64 3)
35 ; CHECK-NEXT: br label %merge
37 ; CHECK-NEXT: ret i64 undef
40 br i1 %flag, label %plus, label %minus
43 %n0 = call i64 @binop(i64 %m, i64 %n)
44 %res0 = call i64 @bar(i64 %n0)
48 %n1 = call i64 @binop(i64 %m, i64 %n)
49 %res1 = call i64 @bar(i64 %n1)
53 %res = phi i64 [ %res0, %plus ], [ %res1, %minus]
57 define internal i64 @binop(i64 %x, i64 %y) {
59 ; CHECK: define internal i64 @binop.specialized.3
61 ; CHECK-NEXT: ret i64 undef
63 ; CHECK: define internal i64 @binop.specialized.4
65 ; CHECK-NEXT: ret i64 undef
72 define internal i64 @bar(i64 %n) {
74 ; CHECK: define internal i64 @bar.specialized.5
76 ; CHECK-NEXT: br label %if.else
78 ; CHECK-NEXT: br label %if.end
80 ; CHECK-NEXT: ret i64 undef
82 ; CHECK: define internal i64 @bar.specialized.6
84 ; CHECK-NEXT: br label %if.then
86 ; CHECK-NEXT: br label %if.end
88 ; CHECK-NEXT: ret i64 undef
91 %cmp = icmp sgt i64 %n, 3
92 br i1 %cmp, label %if.then, label %if.else
95 %res0 = sdiv i64 %n, 2
103 %res = phi i64 [ %res0, %if.then ], [ %res1, %if.else]