1 ; RUN: opt -S --passes="ipsccp<func-spec>" < %s | FileCheck %s
2 define dso_local i32 @p0(i32 noundef %x) {
4 %add = add nsw i32 %x, 1
8 define dso_local i32 @p1(i32 noundef %x) {
10 %sub = add nsw i32 %x, -1
14 ; CHECK-LABEL: define dso_local i32 @f0
15 ; CHECK: tail call fastcc i32 @g.specialized.[[#A:]]({{.*}}@p0)
17 define dso_local i32 @f0(i32 noundef %x) {
19 %call = tail call fastcc i32 @g(i32 noundef %x, ptr noundef nonnull @p0)
23 ; CHECK-LABEL: define dso_local i32 @f1
24 ; CHECK: tail call fastcc i32 @g.specialized.[[#B:]]({{.*}}@p1)
26 define dso_local i32 @f1(i32 noundef %x) {
28 %call = tail call fastcc i32 @g(i32 noundef %x, ptr noundef nonnull @p1)
32 ; @g gets fully specialized
33 ; CHECK-NOT: define internal fastcc i32 @g(
35 define internal fastcc i32 @g(i32 noundef %x, ptr nocapture noundef readonly %p) noinline {
37 %pcall = tail call i32 %p(i32 noundef %x)
38 %fcall = tail call fastcc i32 @f(i32 noundef %pcall, ptr noundef nonnull %p)
42 ; CHECK-LABEL: define dso_local i32 @g0
43 ; CHECK: tail call fastcc i32 @f.specialized.[[#C:]]({{.*}}@p0)
45 define dso_local i32 @g0(i32 noundef %x) {
47 %call = tail call fastcc i32 @f(i32 noundef %x, ptr noundef nonnull @p0)
51 define internal fastcc i32 @f(i32 noundef %x, ptr nocapture noundef readonly %p) noinline {
53 %call = tail call i32 %p(i32 noundef %x)
54 %add = add nsw i32 %call, %x
58 ; CHECK-LABEL: define dso_local i32 @g1
59 ; CHECK: tail call fastcc i32 @f.specialized.[[#D:]]({{.*}}@p1)
61 define dso_local i32 @g1(i32 noundef %x) {
63 %call = tail call fastcc i32 @f(i32 noundef %x, ptr noundef nonnull @p1)
67 define dso_local i32 @g2(i32 noundef %x) {
69 %call = tail call fastcc i32 @f(i32 noundef %x, ptr poison)
73 ; Check that a single argument, that cannot be used for specialisation, does not
74 ; prevent specialisation based on other arguments.
76 ; Also check that for callsites which reside in the body of newly created
77 ; (specialized) functions, the lattice value of the arguments is known.
79 ; CHECK-DAG: define internal fastcc i32 @g.specialized.[[#A]]
80 ; CHECK-DAG: define internal fastcc i32 @g.specialized.[[#B]]
81 ; CHECK-DAG: define internal fastcc i32 @f.specialized.[[#C]]
82 ; CHECK-DAG: define internal fastcc i32 @f.specialized.[[#D]]