1 ; RUN: opt -passes="ipsccp<func-spec>,inline,instcombine" -force-specialization -funcspec-max-iters=1 -S < %s | FileCheck %s --check-prefix=ITERS1
2 ; RUN: opt -passes="ipsccp<func-spec>,inline,instcombine" -force-specialization -funcspec-max-iters=2 -S < %s | FileCheck %s --check-prefix=ITERS2
3 ; RUN: opt -passes="ipsccp<func-spec>,inline,instcombine" -force-specialization -funcspec-max-iters=3 -S < %s | FileCheck %s --check-prefix=ITERS3
4 ; RUN: opt -passes="ipsccp<func-spec>,inline,instcombine" -force-specialization -funcspec-max-iters=4 -S < %s | FileCheck %s --check-prefix=ITERS4
6 @low = internal constant i32 0, align 4
7 @high = internal constant i32 6, align 4
9 define internal void @recursiveFunc(ptr nocapture readonly %lo, i32 %step, ptr nocapture readonly %hi) {
10 %lo.temp = alloca i32, align 4
11 %hi.temp = alloca i32, align 4
12 %lo.load = load i32, ptr %lo, align 4
13 %hi.load = load i32, ptr %hi, align 4
14 %cmp = icmp ne i32 %lo.load, %hi.load
15 br i1 %cmp, label %block6, label %ret.block
18 call void @print_val(i32 %lo.load, i32 %hi.load)
19 %add = add nsw i32 %lo.load, %step
20 %sub = sub nsw i32 %hi.load, %step
21 store i32 %add, ptr %lo.temp, align 4
22 store i32 %sub, ptr %hi.temp, align 4
23 call void @recursiveFunc(ptr nonnull %lo.temp, i32 %step, ptr nonnull %hi.temp)
30 ; ITERS1: @specialized.arg.1 = internal constant i32 0
31 ; ITERS1: @specialized.arg.2 = internal constant i32 6
32 ; ITERS1: @specialized.arg.3 = internal constant i32 1
33 ; ITERS1: @specialized.arg.4 = internal constant i32 5
35 ; ITERS2: @specialized.arg.1 = internal constant i32 0
36 ; ITERS2: @specialized.arg.2 = internal constant i32 6
37 ; ITERS2: @specialized.arg.3 = internal constant i32 1
38 ; ITERS2: @specialized.arg.4 = internal constant i32 5
39 ; ITERS2: @specialized.arg.5 = internal constant i32 2
40 ; ITERS2: @specialized.arg.6 = internal constant i32 4
42 ; ITERS3: @specialized.arg.1 = internal constant i32 0
43 ; ITERS3: @specialized.arg.2 = internal constant i32 6
44 ; ITERS3: @specialized.arg.3 = internal constant i32 1
45 ; ITERS3: @specialized.arg.4 = internal constant i32 5
46 ; ITERS3: @specialized.arg.5 = internal constant i32 2
47 ; ITERS3: @specialized.arg.6 = internal constant i32 4
48 ; ITERS3: @specialized.arg.7 = internal constant i32 3
49 ; ITERS3: @specialized.arg.8 = internal constant i32 3
51 ; ITERS4: @specialized.arg.1 = internal constant i32 0
52 ; ITERS4: @specialized.arg.2 = internal constant i32 6
53 ; ITERS4: @specialized.arg.3 = internal constant i32 1
54 ; ITERS4: @specialized.arg.4 = internal constant i32 5
55 ; ITERS4: @specialized.arg.5 = internal constant i32 2
56 ; ITERS4: @specialized.arg.6 = internal constant i32 4
57 ; ITERS4: @specialized.arg.7 = internal constant i32 3
58 ; ITERS4: @specialized.arg.8 = internal constant i32 3
61 ; ITERS1-LABEL: @main(
62 ; ITERS1-NEXT: call void @print_val(i32 0, i32 6)
63 ; ITERS1-NEXT: call void @recursiveFunc(ptr nonnull @specialized.arg.3, i32 1, ptr nonnull @specialized.arg.4)
64 ; ITERS1-NEXT: ret i32 0
66 ; ITERS2-LABEL: @main(
67 ; ITERS2-NEXT: call void @print_val(i32 0, i32 6)
68 ; ITERS2-NEXT: call void @print_val(i32 1, i32 5)
69 ; ITERS2-NEXT: call void @recursiveFunc(ptr nonnull @specialized.arg.5, i32 1, ptr nonnull @specialized.arg.6)
70 ; ITERS2-NEXT: ret i32 0
72 ; ITERS3-LABEL: @main(
73 ; ITERS3-NEXT: call void @print_val(i32 0, i32 6)
74 ; ITERS3-NEXT: call void @print_val(i32 1, i32 5)
75 ; ITERS3-NEXT: call void @print_val(i32 2, i32 4)
76 ; ITERS3-NEXT: call void @recursiveFunc(ptr nonnull @specialized.arg.7, i32 1, ptr nonnull @specialized.arg.8)
77 ; ITERS3-NEXT: ret i32 0
79 ; ITERS4-LABEL: @main(
80 ; ITERS4-NEXT: call void @print_val(i32 0, i32 6)
81 ; ITERS4-NEXT: call void @print_val(i32 1, i32 5)
82 ; ITERS4-NEXT: call void @print_val(i32 2, i32 4)
83 ; ITERS4-NEXT: ret i32 0
85 %lo.temp = alloca i32, align 4
86 %hi.temp = alloca i32, align 4
87 %lo.load = load i32, ptr @low, align 4
88 %hi.load = load i32, ptr @high, align 4
89 store i32 %lo.load, ptr %lo.temp, align 4
90 store i32 %hi.load, ptr %hi.temp, align 4
91 call void @recursiveFunc(ptr nonnull %lo.temp, i32 1, ptr nonnull %hi.temp)
95 declare dso_local void @print_val(i32, i32)