1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -function-specialization -deadargelim -S < %s | FileCheck %s
3 ; RUN: opt -function-specialization -func-specialization-max-iters=1 -deadargelim -S < %s | FileCheck %s
4 ; RUN: opt -function-specialization -func-specialization-max-iters=0 -deadargelim -S < %s | FileCheck %s --check-prefix=DISABLED
5 ; RUN: opt -function-specialization -func-specialization-avg-iters-cost=1 -deadargelim -S < %s | FileCheck %s
7 ; DISABLED-NOT: @func.1(
8 ; DISABLED-NOT: @func.2(
10 define internal i32 @func(i32* %0, i32 %1, void (i32*)* nocapture %2) {
11 %4 = alloca i32, align 4
12 store i32 %1, i32* %4, align 4
13 %5 = load i32, i32* %4, align 4
14 %6 = icmp slt i32 %5, 1
15 br i1 %6, label %14, label %7
18 %8 = load i32, i32* %4, align 4
19 %9 = sext i32 %8 to i64
20 %10 = getelementptr inbounds i32, i32* %0, i64 %9
21 call void %2(i32* %10)
22 %11 = load i32, i32* %4, align 4
23 %12 = add nsw i32 %11, -1
24 %13 = call i32 @func(i32* %0, i32 %12, void (i32*)* %2)
31 define internal void @increment(i32* nocapture %0) {
32 %2 = load i32, i32* %0, align 4
33 %3 = add nsw i32 %2, 1
34 store i32 %3, i32* %0, align 4
38 define internal void @decrement(i32* nocapture %0) {
39 %2 = load i32, i32* %0, align 4
40 %3 = add nsw i32 %2, -1
41 store i32 %3, i32* %0, align 4
45 define i32 @main(i32* %0, i32 %1) {
46 ; CHECK: [[TMP3:%.*]] = call i32 @func.2(i32* [[TMP0:%.*]], i32 [[TMP1:%.*]])
47 %3 = call i32 @func(i32* %0, i32 %1, void (i32*)* nonnull @increment)
48 ; CHECK: [[TMP4:%.*]] = call i32 @func.1(i32* [[TMP0]], i32 [[TMP3]])
49 %4 = call i32 @func(i32* %0, i32 %3, void (i32*)* nonnull @decrement)
54 ; CHECK: [[TMP3:%.*]] = alloca i32, align 4
55 ; CHECK: store i32 [[TMP1:%.*]], i32* [[TMP3]], align 4
56 ; CHECK: [[TMP4:%.*]] = load i32, i32* [[TMP3]], align 4
57 ; CHECK: [[TMP5:%.*]] = icmp slt i32 [[TMP4]], 1
58 ; CHECK: br i1 [[TMP5]], label [[TMP13:%.*]], label [[TMP6:%.*]]
60 ; CHECK: [[TMP7:%.*]] = load i32, i32* [[TMP3]], align 4
61 ; CHECK: [[TMP8:%.*]] = sext i32 [[TMP7]] to i64
62 ; CHECK: [[TMP9:%.*]] = getelementptr inbounds i32, i32* [[TMP0:%.*]], i64 [[TMP8]]
63 ; CHECK: call void @decrement(i32* [[TMP9]])
64 ; CHECK: [[TMP10:%.*]] = load i32, i32* [[TMP3]], align 4
65 ; CHECK: [[TMP11:%.*]] = add nsw i32 [[TMP10]], -1
66 ; CHECK: [[TMP12:%.*]] = call i32 @func.1(i32* [[TMP0]], i32 [[TMP11]])
67 ; CHECK: br label [[TMP13]]
73 ; CHECK: [[TMP3:%.*]] = alloca i32, align 4
74 ; CHECK: store i32 [[TMP1:%.*]], i32* [[TMP3]], align 4
75 ; CHECK: [[TMP4:%.*]] = load i32, i32* [[TMP3]], align 4
76 ; CHECK: [[TMP5:%.*]] = icmp slt i32 [[TMP4]], 1
77 ; CHECK: br i1 [[TMP5]], label [[TMP13:%.*]], label [[TMP6:%.*]]
79 ; CHECK: [[TMP7:%.*]] = load i32, i32* [[TMP3]], align 4
80 ; CHECK: [[TMP8:%.*]] = sext i32 [[TMP7]] to i64
81 ; CHECK: [[TMP9:%.*]] = getelementptr inbounds i32, i32* [[TMP0:%.*]], i64 [[TMP8]]
82 ; CHECK: call void @increment(i32* [[TMP9]])
83 ; CHECK: [[TMP10:%.*]] = load i32, i32* [[TMP3]], align 4
84 ; CHECK: [[TMP11:%.*]] = add nsw i32 [[TMP10]], -1
85 ; CHECK: [[TMP12:%.*]] = call i32 @func.2(i32* [[TMP0]], i32 [[TMP11]])
86 ; CHECK: br label [[TMP13]]