xref: /llvm-project/llvm/test/Transforms/Inline/AMDGPU/amdgpu-inline-stack-argument.ll (revision e3515ba3816b9cabeca6a3b03b90902ebcfd3c65)
1*e3515ba3SJanek van Oirschot; REQUIRES: asserts
2*e3515ba3SJanek van Oirschot; 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*e3515ba3SJanek van Oirschot
4*e3515ba3SJanek van Oirschot; CHECK:      NOT Inlining (cost={{[0-9]+}}, threshold={{[0-9]+}}), Call:   %noinlinecall1 = call noundef i32 @non_inlining_call
5*e3515ba3SJanek van Oirschot; CHECK:      NOT Inlining (cost={{[0-9]+}}, threshold={{[0-9]+}}), Call:   %noinlinecall2 = call noundef i32 @non_inlining_call
6*e3515ba3SJanek van Oirschot; CHECK-NOT:  NOT Inlining (cost={{[0-9]+}}, threshold={{[0-9]+}}), Call:   %inlinecall1 = call noundef i32 @inlining_call
7*e3515ba3SJanek van Oirschot; CHECK-NOT:  NOT Inlining (cost={{[0-9]+}}, threshold={{[0-9]+}}), Call:   %inlinecall2 = call noundef i32 @inlining_call
8*e3515ba3SJanek van Oirschot
9*e3515ba3SJanek van Oirschotdefine noundef i32 @non_inlining_call(i32 noundef %a0, i32 noundef %b0, i32 noundef %c0, i32 noundef %d0, i32 noundef %e0, i32 noundef %f0, i32 noundef %g0, i32 noundef %h0, i32 noundef %i0, i32 noundef %j0, i32 noundef %k0, i32 noundef %l0, i32 noundef %m0, i32 noundef %n0, i32 noundef %o0, i32 noundef %p0, i32 noundef %q0, i32 noundef %r0, i32 noundef %s0, i32 noundef %t0, i32 noundef %u0, i32 noundef %v0, i32 noundef %w0, i32 noundef %x0, i32 noundef %y0, i32 noundef %z0, i32 noundef %a1, i32 noundef %b1, i32 noundef %c1, i32 noundef %d1, i32 noundef %e1, i32 noundef %f1) {
10*e3515ba3SJanek van Oirschotentry:
11*e3515ba3SJanek van Oirschot  %xor = xor i32 %a0, %b0
12*e3515ba3SJanek van Oirschot  %xor1 = xor i32 %xor, %c0
13*e3515ba3SJanek van Oirschot  %xor2 = xor i32 %xor1, %d0
14*e3515ba3SJanek van Oirschot  %xor3 = xor i32 %xor2, %e0
15*e3515ba3SJanek van Oirschot  %xor4 = xor i32 %xor3, %f0
16*e3515ba3SJanek van Oirschot  %xor5 = xor i32 %xor4, %g0
17*e3515ba3SJanek van Oirschot  %xor6 = xor i32 %xor5, %h0
18*e3515ba3SJanek van Oirschot  %xor7 = xor i32 %xor6, %i0
19*e3515ba3SJanek van Oirschot  %xor8 = xor i32 %xor7, %j0
20*e3515ba3SJanek van Oirschot  %xor9 = xor i32 %xor8, %k0
21*e3515ba3SJanek van Oirschot  %xor10 = xor i32 %xor9, %l0
22*e3515ba3SJanek van Oirschot  %xor11 = xor i32 %xor10, %m0
23*e3515ba3SJanek van Oirschot  %xor12 = xor i32 %xor11, %n0
24*e3515ba3SJanek van Oirschot  %xor13 = xor i32 %xor12, %o0
25*e3515ba3SJanek van Oirschot  %xor14 = xor i32 %xor13, %p0
26*e3515ba3SJanek van Oirschot  %xor15 = xor i32 %xor14, %q0
27*e3515ba3SJanek van Oirschot  %xor16 = xor i32 %xor15, %r0
28*e3515ba3SJanek van Oirschot  %xor17 = xor i32 %xor16, %s0
29*e3515ba3SJanek van Oirschot  %xor18 = xor i32 %xor17, %t0
30*e3515ba3SJanek van Oirschot  %xor19 = xor i32 %xor18, %u0
31*e3515ba3SJanek van Oirschot  %xor20 = xor i32 %xor19, %v0
32*e3515ba3SJanek van Oirschot  %xor21 = xor i32 %xor20, %w0
33*e3515ba3SJanek van Oirschot  %xor22 = xor i32 %xor21, %x0
34*e3515ba3SJanek van Oirschot  %xor23 = xor i32 %xor22, %y0
35*e3515ba3SJanek van Oirschot  %xor24 = xor i32 %xor23, %z0
36*e3515ba3SJanek van Oirschot  %xor25 = xor i32 %xor24, %a1
37*e3515ba3SJanek van Oirschot  %xor26 = xor i32 %xor25, %b1
38*e3515ba3SJanek van Oirschot  %xor27 = xor i32 %xor26, %c1
39*e3515ba3SJanek van Oirschot  %xor28 = xor i32 %xor27, %d1
40*e3515ba3SJanek van Oirschot  %xor29 = xor i32 %xor28, %e1
41*e3515ba3SJanek van Oirschot  %xor30 = xor i32 %xor29, %f1
42*e3515ba3SJanek van Oirschot  %xor31 = xor i32 %xor30, 1
43*e3515ba3SJanek van Oirschot  %xor32 = xor i32 %xor31, 2
44*e3515ba3SJanek van Oirschot  ret i32 %xor32
45*e3515ba3SJanek van Oirschot}
46*e3515ba3SJanek van Oirschot
47*e3515ba3SJanek van Oirschotdefine noundef i32 @inlining_call(i32 noundef %a0, i32 noundef %b0, i32 noundef %c0, i32 noundef %d0, i32 noundef %e0, i32 noundef %f0, i32 noundef %g0, i32 noundef %h0, i32 noundef %i0, i32 noundef %j0, i32 noundef %k0, i32 noundef %l0, i32 noundef %m0, i32 noundef %n0, i32 noundef %o0, i32 noundef %p0, i32 noundef %q0, i32 noundef %r0, i32 noundef %s0, i32 noundef %t0, i32 noundef %u0, i32 noundef %v0, i32 noundef %w0, i32 noundef %x0, i32 noundef %y0, i32 noundef %z0, i32 noundef %a1, i32 noundef %b1, i32 noundef %c1, i32 noundef %d1, i32 noundef %e1, i32 noundef %f1, i32 noundef %g1) {
48*e3515ba3SJanek van Oirschotentry:
49*e3515ba3SJanek van Oirschot  %xor = xor i32 %a0, %b0
50*e3515ba3SJanek van Oirschot  %xor1 = xor i32 %xor, %c0
51*e3515ba3SJanek van Oirschot  %xor2 = xor i32 %xor1, %d0
52*e3515ba3SJanek van Oirschot  %xor3 = xor i32 %xor2, %e0
53*e3515ba3SJanek van Oirschot  %xor4 = xor i32 %xor3, %f0
54*e3515ba3SJanek van Oirschot  %xor5 = xor i32 %xor4, %g0
55*e3515ba3SJanek van Oirschot  %xor6 = xor i32 %xor5, %h0
56*e3515ba3SJanek van Oirschot  %xor7 = xor i32 %xor6, %i0
57*e3515ba3SJanek van Oirschot  %xor8 = xor i32 %xor7, %j0
58*e3515ba3SJanek van Oirschot  %xor9 = xor i32 %xor8, %k0
59*e3515ba3SJanek van Oirschot  %xor10 = xor i32 %xor9, %l0
60*e3515ba3SJanek van Oirschot  %xor11 = xor i32 %xor10, %m0
61*e3515ba3SJanek van Oirschot  %xor12 = xor i32 %xor11, %n0
62*e3515ba3SJanek van Oirschot  %xor13 = xor i32 %xor12, %o0
63*e3515ba3SJanek van Oirschot  %xor14 = xor i32 %xor13, %p0
64*e3515ba3SJanek van Oirschot  %xor15 = xor i32 %xor14, %q0
65*e3515ba3SJanek van Oirschot  %xor16 = xor i32 %xor15, %r0
66*e3515ba3SJanek van Oirschot  %xor17 = xor i32 %xor16, %s0
67*e3515ba3SJanek van Oirschot  %xor18 = xor i32 %xor17, %t0
68*e3515ba3SJanek van Oirschot  %xor19 = xor i32 %xor18, %u0
69*e3515ba3SJanek van Oirschot  %xor20 = xor i32 %xor19, %v0
70*e3515ba3SJanek van Oirschot  %xor21 = xor i32 %xor20, %w0
71*e3515ba3SJanek van Oirschot  %xor22 = xor i32 %xor21, %x0
72*e3515ba3SJanek van Oirschot  %xor23 = xor i32 %xor22, %y0
73*e3515ba3SJanek van Oirschot  %xor24 = xor i32 %xor23, %z0
74*e3515ba3SJanek van Oirschot  %xor25 = xor i32 %xor24, %a1
75*e3515ba3SJanek van Oirschot  %xor26 = xor i32 %xor25, %b1
76*e3515ba3SJanek van Oirschot  %xor27 = xor i32 %xor26, %c1
77*e3515ba3SJanek van Oirschot  %xor28 = xor i32 %xor27, %d1
78*e3515ba3SJanek van Oirschot  %xor29 = xor i32 %xor28, %e1
79*e3515ba3SJanek van Oirschot  %xor30 = xor i32 %xor29, %f1
80*e3515ba3SJanek van Oirschot  %xor31 = xor i32 %xor30, %g1
81*e3515ba3SJanek van Oirschot  %xor32 = xor i32 %xor30, 1
82*e3515ba3SJanek van Oirschot  %xor33 = xor i32 %xor31, 2
83*e3515ba3SJanek van Oirschot  ret i32 %xor33
84*e3515ba3SJanek van Oirschot}
85*e3515ba3SJanek van Oirschot
86*e3515ba3SJanek van Oirschot; Calling each (non-)inlining function twice to make sure they won't get the sole call inlining cost bonus.
87*e3515ba3SJanek van Oirschotdefine i32 @Caller(ptr noundef %in) {
88*e3515ba3SJanek van Oirschotentry:
89*e3515ba3SJanek van Oirschot  %arrayidx = getelementptr inbounds i32, ptr %in, i64 0
90*e3515ba3SJanek van Oirschot  %a0 = load i32, ptr %arrayidx, align 4
91*e3515ba3SJanek van Oirschot  %arrayidx1 = getelementptr inbounds i32, ptr %in, i64 1
92*e3515ba3SJanek van Oirschot  %b0 = load i32, ptr %arrayidx1, align 4
93*e3515ba3SJanek van Oirschot  %arrayidx2 = getelementptr inbounds i32, ptr %in, i64 2
94*e3515ba3SJanek van Oirschot  %c0 = load i32, ptr %arrayidx2, align 4
95*e3515ba3SJanek van Oirschot  %arrayidx3 = getelementptr inbounds i32, ptr %in, i64 3
96*e3515ba3SJanek van Oirschot  %d0 = load i32, ptr %arrayidx3, align 4
97*e3515ba3SJanek van Oirschot  %arrayidx4 = getelementptr inbounds i32, ptr %in, i64 4
98*e3515ba3SJanek van Oirschot  %e0 = load i32, ptr %arrayidx4, align 4
99*e3515ba3SJanek van Oirschot  %arrayidx5 = getelementptr inbounds i32, ptr %in, i64 5
100*e3515ba3SJanek van Oirschot  %f0 = load i32, ptr %arrayidx5, align 4
101*e3515ba3SJanek van Oirschot  %arrayidx6 = getelementptr inbounds i32, ptr %in, i64 6
102*e3515ba3SJanek van Oirschot  %g0 = load i32, ptr %arrayidx6, align 4
103*e3515ba3SJanek van Oirschot  %arrayidx7 = getelementptr inbounds i32, ptr %in, i64 7
104*e3515ba3SJanek van Oirschot  %h0 = load i32, ptr %arrayidx7, align 4
105*e3515ba3SJanek van Oirschot  %arrayidx8 = getelementptr inbounds i32, ptr %in, i64 8
106*e3515ba3SJanek van Oirschot  %i0 = load i32, ptr %arrayidx8, align 4
107*e3515ba3SJanek van Oirschot  %arrayidx9 = getelementptr inbounds i32, ptr %in, i64 9
108*e3515ba3SJanek van Oirschot  %j0 = load i32, ptr %arrayidx9, align 4
109*e3515ba3SJanek van Oirschot  %arrayidx10 = getelementptr inbounds i32, ptr %in, i64 10
110*e3515ba3SJanek van Oirschot  %k0 = load i32, ptr %arrayidx10, align 4
111*e3515ba3SJanek van Oirschot  %arrayidx11 = getelementptr inbounds i32, ptr %in, i64 11
112*e3515ba3SJanek van Oirschot  %l0 = load i32, ptr %arrayidx11, align 4
113*e3515ba3SJanek van Oirschot  %arrayidx12 = getelementptr inbounds i32, ptr %in, i64 12
114*e3515ba3SJanek van Oirschot  %m0 = load i32, ptr %arrayidx12, align 4
115*e3515ba3SJanek van Oirschot  %arrayidx13 = getelementptr inbounds i32, ptr %in, i64 13
116*e3515ba3SJanek van Oirschot  %n0 = load i32, ptr %arrayidx13, align 4
117*e3515ba3SJanek van Oirschot  %arrayidx14 = getelementptr inbounds i32, ptr %in, i64 14
118*e3515ba3SJanek van Oirschot  %o0 = load i32, ptr %arrayidx14, align 4
119*e3515ba3SJanek van Oirschot  %arrayidx15 = getelementptr inbounds i32, ptr %in, i64 15
120*e3515ba3SJanek van Oirschot  %p0 = load i32, ptr %arrayidx15, align 4
121*e3515ba3SJanek van Oirschot  %arrayidx16 = getelementptr inbounds i32, ptr %in, i64 16
122*e3515ba3SJanek van Oirschot  %q0 = load i32, ptr %arrayidx16, align 4
123*e3515ba3SJanek van Oirschot  %arrayidx17 = getelementptr inbounds i32, ptr %in, i64 17
124*e3515ba3SJanek van Oirschot  %r0 = load i32, ptr %arrayidx17, align 4
125*e3515ba3SJanek van Oirschot  %arrayidx18 = getelementptr inbounds i32, ptr %in, i64 18
126*e3515ba3SJanek van Oirschot  %s0 = load i32, ptr %arrayidx18, align 4
127*e3515ba3SJanek van Oirschot  %arrayidx19 = getelementptr inbounds i32, ptr %in, i64 19
128*e3515ba3SJanek van Oirschot  %t0 = load i32, ptr %arrayidx19, align 4
129*e3515ba3SJanek van Oirschot  %arrayidx20 = getelementptr inbounds i32, ptr %in, i64 20
130*e3515ba3SJanek van Oirschot  %u0 = load i32, ptr %arrayidx20, align 4
131*e3515ba3SJanek van Oirschot  %arrayidx21 = getelementptr inbounds i32, ptr %in, i64 21
132*e3515ba3SJanek van Oirschot  %v0 = load i32, ptr %arrayidx21, align 4
133*e3515ba3SJanek van Oirschot  %arrayidx22 = getelementptr inbounds i32, ptr %in, i64 22
134*e3515ba3SJanek van Oirschot  %w0 = load i32, ptr %arrayidx22, align 4
135*e3515ba3SJanek van Oirschot  %arrayidx23 = getelementptr inbounds i32, ptr %in, i64 23
136*e3515ba3SJanek van Oirschot  %x0 = load i32, ptr %arrayidx23, align 4
137*e3515ba3SJanek van Oirschot  %arrayidx24 = getelementptr inbounds i32, ptr %in, i64 24
138*e3515ba3SJanek van Oirschot  %y0 = load i32, ptr %arrayidx24, align 4
139*e3515ba3SJanek van Oirschot  %arrayidx25 = getelementptr inbounds i32, ptr %in, i64 25
140*e3515ba3SJanek van Oirschot  %z0 = load i32, ptr %arrayidx25, align 4
141*e3515ba3SJanek van Oirschot  %arrayidx26 = getelementptr inbounds i32, ptr %in, i64 26
142*e3515ba3SJanek van Oirschot  %a1 = load i32, ptr %arrayidx26, align 4
143*e3515ba3SJanek van Oirschot  %arrayidx27 = getelementptr inbounds i32, ptr %in, i64 27
144*e3515ba3SJanek van Oirschot  %b1 = load i32, ptr %arrayidx27, align 4
145*e3515ba3SJanek van Oirschot  %arrayidx28 = getelementptr inbounds i32, ptr %in, i64 28
146*e3515ba3SJanek van Oirschot  %c1 = load i32, ptr %arrayidx28, align 4
147*e3515ba3SJanek van Oirschot  %arrayidx29 = getelementptr inbounds i32, ptr %in, i64 29
148*e3515ba3SJanek van Oirschot  %d1 = load i32, ptr %arrayidx29, align 4
149*e3515ba3SJanek van Oirschot  %arrayidx30 = getelementptr inbounds i32, ptr %in, i64 30
150*e3515ba3SJanek van Oirschot  %e1 = load i32, ptr %arrayidx30, align 4
151*e3515ba3SJanek van Oirschot  %arrayidx31 = getelementptr inbounds i32, ptr %in, i64 31
152*e3515ba3SJanek van Oirschot  %f1 = load i32, ptr %arrayidx31, align 4
153*e3515ba3SJanek van Oirschot  %arrayidx32 = getelementptr inbounds i32, ptr %in, i64 32
154*e3515ba3SJanek van Oirschot  %g1 = load i32, ptr %arrayidx32, align 4
155*e3515ba3SJanek van Oirschot  %noinlinecall1 = call noundef i32 @non_inlining_call(i32 noundef %a0, i32 noundef %b0, i32 noundef %c0, i32 noundef %d0, i32 noundef %e0, i32 noundef %f0, i32 noundef %g0, i32 noundef %h0, i32 noundef %i0, i32 noundef %j0, i32 noundef %k0, i32 noundef %l0, i32 noundef %m0, i32 noundef %n0, i32 noundef %o0, i32 noundef %p0, i32 noundef %q0, i32 noundef %r0, i32 noundef %s0, i32 noundef %t0, i32 noundef %u0, i32 noundef %v0, i32 noundef %w0, i32 noundef %x0, i32 noundef %y0, i32 noundef %z0, i32 noundef %a1, i32 noundef %b1, i32 noundef %c1, i32 noundef %d1, i32 noundef %e1, i32 noundef %f1)
156*e3515ba3SJanek van Oirschot  %add = add i32 0, %noinlinecall1
157*e3515ba3SJanek van Oirschot  %noinlinecall2 = call noundef i32 @non_inlining_call(i32 noundef %a0, i32 noundef %b0, i32 noundef %c0, i32 noundef %d0, i32 noundef %e0, i32 noundef %f0, i32 noundef %g0, i32 noundef %h0, i32 noundef %i0, i32 noundef %j0, i32 noundef %k0, i32 noundef %l0, i32 noundef %m0, i32 noundef %n0, i32 noundef %o0, i32 noundef %p0, i32 noundef %q0, i32 noundef %r0, i32 noundef %s0, i32 noundef %t0, i32 noundef %u0, i32 noundef %v0, i32 noundef %w0, i32 noundef %x0, i32 noundef %y0, i32 noundef %z0, i32 noundef %a1, i32 noundef %b1, i32 noundef %c1, i32 noundef %d1, i32 noundef %e1, i32 noundef %f1)
158*e3515ba3SJanek van Oirschot  %add2 = add i32 %add, %noinlinecall2
159*e3515ba3SJanek van Oirschot  %inlinecall1 = call noundef i32 @inlining_call(i32 noundef %a0, i32 noundef %b0, i32 noundef %c0, i32 noundef %d0, i32 noundef %e0, i32 noundef %f0, i32 noundef %g0, i32 noundef %h0, i32 noundef %i0, i32 noundef %j0, i32 noundef %k0, i32 noundef %l0, i32 noundef %m0, i32 noundef %n0, i32 noundef %o0, i32 noundef %p0, i32 noundef %q0, i32 noundef %r0, i32 noundef %s0, i32 noundef %t0, i32 noundef %u0, i32 noundef %v0, i32 noundef %w0, i32 noundef %x0, i32 noundef %y0, i32 noundef %z0, i32 noundef %a1, i32 noundef %b1, i32 noundef %c1, i32 noundef %d1, i32 noundef %e1, i32 noundef %f1, i32 noundef %g1)
160*e3515ba3SJanek van Oirschot  %add3 = add i32 %add2, %inlinecall1
161*e3515ba3SJanek van Oirschot  %inlinecall2 = call noundef i32 @inlining_call(i32 noundef %a0, i32 noundef %b0, i32 noundef %c0, i32 noundef %d0, i32 noundef %e0, i32 noundef %f0, i32 noundef %g0, i32 noundef %h0, i32 noundef %i0, i32 noundef %j0, i32 noundef %k0, i32 noundef %l0, i32 noundef %m0, i32 noundef %n0, i32 noundef %o0, i32 noundef %p0, i32 noundef %q0, i32 noundef %r0, i32 noundef %s0, i32 noundef %t0, i32 noundef %u0, i32 noundef %v0, i32 noundef %w0, i32 noundef %x0, i32 noundef %y0, i32 noundef %z0, i32 noundef %a1, i32 noundef %b1, i32 noundef %c1, i32 noundef %d1, i32 noundef %e1, i32 noundef %f1, i32 noundef %g1)
162*e3515ba3SJanek van Oirschot  %add4 = add i32 %add3, %inlinecall2
163*e3515ba3SJanek van Oirschot  ret i32 %add4
164*e3515ba3SJanek van Oirschot}
165