xref: /llvm-project/llvm/test/Transforms/Inline/AMDGPU/amdgpu-inline-stack-ptr-argument.ll (revision e3515ba3816b9cabeca6a3b03b90902ebcfd3c65)
1; REQUIRES: asserts
2; RUN: opt -mtriple=amdgcn-amd-amdhsa -S -passes=inline -inline-cost-full=true -inline-threshold=0 -inline-instr-cost=5 -inline-call-penalty=0 -debug-only=inline < %s 2>&1 | FileCheck %s
3
4; CHECK:      NOT Inlining (cost={{[0-9]+}}, threshold={{[0-9]+}}), Call:   %noinlinecall1 = call noundef i64 @non_inlining_call
5; CHECK:      NOT Inlining (cost={{[0-9]+}}, threshold={{[0-9]+}}), Call:   %noinlinecall2 = call noundef i64 @non_inlining_call
6; CHECK-NOT:  NOT Inlining (cost={{[0-9]+}}, threshold={{[0-9]+}}), Call:   %inlinecall1 = call noundef i64 @inlining_call
7; CHECK-NOT:  NOT Inlining (cost={{[0-9]+}}, threshold={{[0-9]+}}), Call:   %inlinecall2 = call noundef i64 @inlining_call
8
9define noundef i64 @non_inlining_call(ptr noundef %ptra0, ptr noundef %ptrb0, ptr noundef %ptrc0, ptr noundef %ptrd0, ptr noundef %ptre0, ptr noundef %ptrf0, ptr noundef %ptrg0, ptr noundef %ptrh0, ptr noundef %ptri0, ptr noundef %ptrj0, ptr noundef %ptrk0, ptr noundef %ptrl0, ptr noundef %ptrm0, ptr noundef %ptrn0, ptr noundef %ptro0, ptr noundef %ptrp0) {
10entry:
11  %a0 = load i64, ptr %ptra0, align 8
12  %b0 = load i64, ptr %ptrb0, align 8
13  %c0 = load i64, ptr %ptrc0, align 8
14  %d0 = load i64, ptr %ptrd0, align 8
15  %e0 = load i64, ptr %ptre0, align 8
16  %f0 = load i64, ptr %ptrf0, align 8
17  %g0 = load i64, ptr %ptrg0, align 8
18  %h0 = load i64, ptr %ptrh0, align 8
19  %i0 = load i64, ptr %ptri0, align 8
20  %j0 = load i64, ptr %ptrj0, align 8
21  %k0 = load i64, ptr %ptrk0, align 8
22  %l0 = load i64, ptr %ptrl0, align 8
23  %m0 = load i64, ptr %ptrm0, align 8
24  %n0 = load i64, ptr %ptrn0, align 8
25  %o0 = load i64, ptr %ptro0, align 8
26  %p0 = load i64, ptr %ptrp0, align 8
27  %xor = xor i64 %a0, %b0
28  %xor1 = xor i64 %xor, %c0
29  %xor2 = xor i64 %xor1, %d0
30  %xor3 = xor i64 %xor2, %e0
31  %xor4 = xor i64 %xor3, %f0
32  %xor5 = xor i64 %xor4, %g0
33  %xor6 = xor i64 %xor5, %h0
34  %xor7 = xor i64 %xor6, %i0
35  %xor8 = xor i64 %xor7, %j0
36  %xor9 = xor i64 %xor8, %k0
37  %xor10 = xor i64 %xor9, %l0
38  %xor11 = xor i64 %xor10, %m0
39  %xor12 = xor i64 %xor11, %n0
40  %xor13 = xor i64 %xor12, %o0
41  %xor14 = xor i64 %xor13, %p0
42  ret i64 %xor14
43}
44
45define noundef i64 @inlining_call(ptr noundef %ptra0, ptr noundef %ptrb0, ptr noundef %ptrc0, ptr noundef %ptrd0, ptr noundef %ptre0, ptr noundef %ptrf0, ptr noundef %ptrg0, ptr noundef %ptrh0, ptr noundef %ptri0, ptr noundef %ptrj0, ptr noundef %ptrk0, ptr noundef %ptrl0, ptr noundef %ptrm0, ptr noundef %ptrn0, ptr noundef %ptro0, ptr noundef %ptrp0, ptr noundef %ptrq0) {
46entry:
47  %a0 = load i64, ptr %ptra0, align 8
48  %b0 = load i64, ptr %ptrb0, align 8
49  %c0 = load i64, ptr %ptrc0, align 8
50  %d0 = load i64, ptr %ptrd0, align 8
51  %e0 = load i64, ptr %ptre0, align 8
52  %f0 = load i64, ptr %ptrf0, align 8
53  %g0 = load i64, ptr %ptrg0, align 8
54  %h0 = load i64, ptr %ptrh0, align 8
55  %i0 = load i64, ptr %ptri0, align 8
56  %j0 = load i64, ptr %ptrj0, align 8
57  %k0 = load i64, ptr %ptrk0, align 8
58  %l0 = load i64, ptr %ptrl0, align 8
59  %m0 = load i64, ptr %ptrm0, align 8
60  %n0 = load i64, ptr %ptrn0, align 8
61  %o0 = load i64, ptr %ptro0, align 8
62  %p0 = load i64, ptr %ptrp0, align 8
63  %q0 = load i64, ptr %ptrq0, align 8
64  %xor = xor i64 %a0, %b0
65  %xor1 = xor i64 %xor, %c0
66  %xor2 = xor i64 %xor1, %d0
67  %xor3 = xor i64 %xor2, %e0
68  %xor4 = xor i64 %xor3, %f0
69  %xor5 = xor i64 %xor4, %g0
70  %xor6 = xor i64 %xor5, %h0
71  %xor7 = xor i64 %xor6, %i0
72  %xor8 = xor i64 %xor7, %j0
73  %xor9 = xor i64 %xor8, %k0
74  %xor10 = xor i64 %xor9, %l0
75  %xor11 = xor i64 %xor10, %m0
76  %xor12 = xor i64 %xor11, %n0
77  %xor13 = xor i64 %xor12, %o0
78  %xor14 = xor i64 %xor13, %p0
79  %xor15 = xor i64 %xor14, %q0
80  ret i64 %xor15
81}
82
83; Calling each (non-)inlining function twice to make sure they won't get the sole call inlining cost bonus.
84define i64 @Caller(ptr noundef %in) {
85entry:
86  %a0 = getelementptr inbounds i64, ptr %in, i64 0
87  %b0 = getelementptr inbounds i64, ptr %in, i64 1
88  %c0 = getelementptr inbounds i64, ptr %in, i64 2
89  %d0 = getelementptr inbounds i64, ptr %in, i64 3
90  %e0 = getelementptr inbounds i64, ptr %in, i64 4
91  %f0 = getelementptr inbounds i64, ptr %in, i64 5
92  %g0 = getelementptr inbounds i64, ptr %in, i64 6
93  %h0 = getelementptr inbounds i64, ptr %in, i64 7
94  %i0 = getelementptr inbounds i64, ptr %in, i64 8
95  %j0 = getelementptr inbounds i64, ptr %in, i64 9
96  %k0 = getelementptr inbounds i64, ptr %in, i64 10
97  %l0 = getelementptr inbounds i64, ptr %in, i64 11
98  %m0 = getelementptr inbounds i64, ptr %in, i64 12
99  %n0 = getelementptr inbounds i64, ptr %in, i64 13
100  %o0 = getelementptr inbounds i64, ptr %in, i64 14
101  %p0 = getelementptr inbounds i64, ptr %in, i64 15
102  %q0 = getelementptr inbounds i64, ptr %in, i64 16
103  %noinlinecall1 = call noundef i64 @non_inlining_call(ptr noundef %a0, ptr noundef %b0, ptr noundef %c0, ptr noundef %d0, ptr noundef %e0, ptr noundef %f0, ptr noundef %g0, ptr noundef %h0, ptr noundef %i0, ptr noundef %j0, ptr noundef %k0, ptr noundef %l0, ptr noundef %m0, ptr noundef %n0, ptr noundef %o0, ptr noundef %p0)
104  %add = add i64 0, %noinlinecall1
105  %noinlinecall2 = call noundef i64 @non_inlining_call(ptr noundef %a0, ptr noundef %b0, ptr noundef %c0, ptr noundef %d0, ptr noundef %e0, ptr noundef %f0, ptr noundef %g0, ptr noundef %h0, ptr noundef %i0, ptr noundef %j0, ptr noundef %k0, ptr noundef %l0, ptr noundef %m0, ptr noundef %n0, ptr noundef %o0, ptr noundef %p0)
106  %add2 = add i64 %add, %noinlinecall2
107  %inlinecall1 = call noundef i64 @inlining_call(ptr noundef %a0, ptr noundef %b0, ptr noundef %c0, ptr noundef %d0, ptr noundef %e0, ptr noundef %f0, ptr noundef %g0, ptr noundef %h0, ptr noundef %i0, ptr noundef %j0, ptr noundef %k0, ptr noundef %l0, ptr noundef %m0, ptr noundef %n0, ptr noundef %o0, ptr noundef %p0, ptr noundef %q0)
108  %add3 = add i64 %add2, %inlinecall1
109  %inlinecall2 = call noundef i64 @inlining_call(ptr noundef %a0, ptr noundef %b0, ptr noundef %c0, ptr noundef %d0, ptr noundef %e0, ptr noundef %f0, ptr noundef %g0, ptr noundef %h0, ptr noundef %i0, ptr noundef %j0, ptr noundef %k0, ptr noundef %l0, ptr noundef %m0, ptr noundef %n0, ptr noundef %o0, ptr noundef %p0, ptr noundef %q0)
110  %add4 = add i64 %add3, %inlinecall2
111  ret i64 %add4
112}
113