1 ; RUN: opt -S --passes="ipsccp<func-spec>" -force-specialization < %s | FileCheck %s
3 @A = private constant [6 x i32] [i32 1, i32 2, i32 0, i32 0, i32 0, i32 0], align 16
4 @B = external global ptr, align 8
8 %c1 = call fastcc i32 @func(ptr @f0, i32 0, ptr null)
9 %c2 = call fastcc i32 @func(ptr @f1, i32 1, ptr @A)
10 %c3 = call fastcc i32 @func(ptr @f2, i32 2, ptr @A)
11 %add = add i32 %c1, %c2
12 %sub = sub i32 %add, %c3
16 define internal fastcc i32 @func(ptr %f, i32 %N, ptr %A) {
18 switch i32 %N, label %sw.epilog [
24 sw.bb: ; preds = %entry
25 %0 = getelementptr inbounds i32, ptr %A, i64 1
26 %1 = load i32, ptr %0, align 4
27 %2 = call i32 %f(i32 %1)
30 sw.bb2: ; preds = %entry
31 %3 = load i32, ptr %A, align 4
32 %4 = zext i32 %3 to i64
33 %5 = call i32 %f(i64 %4)
36 sw.bb4: ; preds = %entry
40 sw.epilog: ; preds = %sw.bb, %sw.bb2, %sw.bb4, %entry
41 %7 = phi i32 [undef, %entry], [%2, %sw.bb], [%5, %sw.bb2], [%6, %sw.bb4]
46 %ld = load i32, ptr @B, align 4
50 define i32 @f1(i64 %offset) {
51 %gep = getelementptr inbounds i32, ptr @B, i64 %offset
52 %ld = load i32, ptr %gep, align 4
56 define i32 @f2(i32 %offset) {
57 %zext = zext i32 %offset to i64
58 %call = call i32 @f1(i64 %zext)
62 ; Tests that `func` has been specialized and it didn't cause compiler crash.
63 ; CHECK-DAG: func.specialized.1
64 ; CHECK-DAG: func.specialized.2
65 ; CHECK-DAG: func.specialized.3