xref: /aosp_15_r20/external/llvm/test/CodeGen/AMDGPU/large-work-group-promote-alloca.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt -S -mtriple=amdgcn-unknown-unknown -amdgpu-promote-alloca < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; CHECK: @promote_alloca_size_63.stack = internal unnamed_addr addrspace(3) global [63 x [5 x i32]] undef, align 4
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Workerdefine void @promote_alloca_size_63(i32 addrspace(1)* nocapture %out, i32 addrspace(1)* nocapture %in) #0 {
6*9880d681SAndroid Build Coastguard Workerentry:
7*9880d681SAndroid Build Coastguard Worker  %stack = alloca [5 x i32], align 4
8*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32 addrspace(1)* %in, align 4
9*9880d681SAndroid Build Coastguard Worker  %arrayidx1 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 %0
10*9880d681SAndroid Build Coastguard Worker  store i32 4, i32* %arrayidx1, align 4
11*9880d681SAndroid Build Coastguard Worker  %arrayidx2 = getelementptr inbounds i32, i32 addrspace(1)* %in, i32 1
12*9880d681SAndroid Build Coastguard Worker  %1 = load i32, i32 addrspace(1)* %arrayidx2, align 4
13*9880d681SAndroid Build Coastguard Worker  %arrayidx3 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 %1
14*9880d681SAndroid Build Coastguard Worker  store i32 5, i32* %arrayidx3, align 4
15*9880d681SAndroid Build Coastguard Worker  %arrayidx10 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 0
16*9880d681SAndroid Build Coastguard Worker  %2 = load i32, i32* %arrayidx10, align 4
17*9880d681SAndroid Build Coastguard Worker  store i32 %2, i32 addrspace(1)* %out, align 4
18*9880d681SAndroid Build Coastguard Worker  %arrayidx12 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 1
19*9880d681SAndroid Build Coastguard Worker  %3 = load i32, i32* %arrayidx12
20*9880d681SAndroid Build Coastguard Worker  %arrayidx13 = getelementptr inbounds i32, i32 addrspace(1)* %out, i32 1
21*9880d681SAndroid Build Coastguard Worker  store i32 %3, i32 addrspace(1)* %arrayidx13
22*9880d681SAndroid Build Coastguard Worker  ret void
23*9880d681SAndroid Build Coastguard Worker}
24*9880d681SAndroid Build Coastguard Worker
25*9880d681SAndroid Build Coastguard Worker; CHECK: @promote_alloca_size_256.stack = internal unnamed_addr addrspace(3) global [256 x [5 x i32]] undef, align 4
26*9880d681SAndroid Build Coastguard Worker
27*9880d681SAndroid Build Coastguard Workerdefine void @promote_alloca_size_256(i32 addrspace(1)* nocapture %out, i32 addrspace(1)* nocapture %in) #1 {
28*9880d681SAndroid Build Coastguard Workerentry:
29*9880d681SAndroid Build Coastguard Worker  %stack = alloca [5 x i32], align 4
30*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32 addrspace(1)* %in, align 4
31*9880d681SAndroid Build Coastguard Worker  %arrayidx1 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 %0
32*9880d681SAndroid Build Coastguard Worker  store i32 4, i32* %arrayidx1, align 4
33*9880d681SAndroid Build Coastguard Worker  %arrayidx2 = getelementptr inbounds i32, i32 addrspace(1)* %in, i32 1
34*9880d681SAndroid Build Coastguard Worker  %1 = load i32, i32 addrspace(1)* %arrayidx2, align 4
35*9880d681SAndroid Build Coastguard Worker  %arrayidx3 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 %1
36*9880d681SAndroid Build Coastguard Worker  store i32 5, i32* %arrayidx3, align 4
37*9880d681SAndroid Build Coastguard Worker  %arrayidx10 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 0
38*9880d681SAndroid Build Coastguard Worker  %2 = load i32, i32* %arrayidx10, align 4
39*9880d681SAndroid Build Coastguard Worker  store i32 %2, i32 addrspace(1)* %out, align 4
40*9880d681SAndroid Build Coastguard Worker  %arrayidx12 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 1
41*9880d681SAndroid Build Coastguard Worker  %3 = load i32, i32* %arrayidx12
42*9880d681SAndroid Build Coastguard Worker  %arrayidx13 = getelementptr inbounds i32, i32 addrspace(1)* %out, i32 1
43*9880d681SAndroid Build Coastguard Worker  store i32 %3, i32 addrspace(1)* %arrayidx13
44*9880d681SAndroid Build Coastguard Worker  ret void
45*9880d681SAndroid Build Coastguard Worker}
46*9880d681SAndroid Build Coastguard Worker
47*9880d681SAndroid Build Coastguard Worker; CHECK: @promote_alloca_size_1600.stack = internal unnamed_addr addrspace(3) global [1600 x [5 x i32]] undef, align 4
48*9880d681SAndroid Build Coastguard Worker
49*9880d681SAndroid Build Coastguard Workerdefine void @promote_alloca_size_1600(i32 addrspace(1)* nocapture %out, i32 addrspace(1)* nocapture %in) #2 {
50*9880d681SAndroid Build Coastguard Workerentry:
51*9880d681SAndroid Build Coastguard Worker  %stack = alloca [5 x i32], align 4
52*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32 addrspace(1)* %in, align 4
53*9880d681SAndroid Build Coastguard Worker  %arrayidx1 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 %0
54*9880d681SAndroid Build Coastguard Worker  store i32 4, i32* %arrayidx1, align 4
55*9880d681SAndroid Build Coastguard Worker  %arrayidx2 = getelementptr inbounds i32, i32 addrspace(1)* %in, i32 1
56*9880d681SAndroid Build Coastguard Worker  %1 = load i32, i32 addrspace(1)* %arrayidx2, align 4
57*9880d681SAndroid Build Coastguard Worker  %arrayidx3 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 %1
58*9880d681SAndroid Build Coastguard Worker  store i32 5, i32* %arrayidx3, align 4
59*9880d681SAndroid Build Coastguard Worker  %arrayidx10 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 0
60*9880d681SAndroid Build Coastguard Worker  %2 = load i32, i32* %arrayidx10, align 4
61*9880d681SAndroid Build Coastguard Worker  store i32 %2, i32 addrspace(1)* %out, align 4
62*9880d681SAndroid Build Coastguard Worker  %arrayidx12 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 1
63*9880d681SAndroid Build Coastguard Worker  %3 = load i32, i32* %arrayidx12
64*9880d681SAndroid Build Coastguard Worker  %arrayidx13 = getelementptr inbounds i32, i32 addrspace(1)* %out, i32 1
65*9880d681SAndroid Build Coastguard Worker  store i32 %3, i32 addrspace(1)* %arrayidx13
66*9880d681SAndroid Build Coastguard Worker  ret void
67*9880d681SAndroid Build Coastguard Worker}
68*9880d681SAndroid Build Coastguard Worker
69*9880d681SAndroid Build Coastguard Worker; CHECK: @occupancy_0(
70*9880d681SAndroid Build Coastguard Worker; CHECK: alloca [5 x i32]
71*9880d681SAndroid Build Coastguard Workerdefine void @occupancy_0(i32 addrspace(1)* nocapture %out, i32 addrspace(1)* nocapture %in) #3 {
72*9880d681SAndroid Build Coastguard Workerentry:
73*9880d681SAndroid Build Coastguard Worker  %stack = alloca [5 x i32], align 4
74*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32 addrspace(1)* %in, align 4
75*9880d681SAndroid Build Coastguard Worker  %arrayidx1 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 %0
76*9880d681SAndroid Build Coastguard Worker  store i32 4, i32* %arrayidx1, align 4
77*9880d681SAndroid Build Coastguard Worker  %arrayidx2 = getelementptr inbounds i32, i32 addrspace(1)* %in, i32 1
78*9880d681SAndroid Build Coastguard Worker  %1 = load i32, i32 addrspace(1)* %arrayidx2, align 4
79*9880d681SAndroid Build Coastguard Worker  %arrayidx3 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 %1
80*9880d681SAndroid Build Coastguard Worker  store i32 5, i32* %arrayidx3, align 4
81*9880d681SAndroid Build Coastguard Worker  %arrayidx10 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 0
82*9880d681SAndroid Build Coastguard Worker  %2 = load i32, i32* %arrayidx10, align 4
83*9880d681SAndroid Build Coastguard Worker  store i32 %2, i32 addrspace(1)* %out, align 4
84*9880d681SAndroid Build Coastguard Worker  %arrayidx12 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 1
85*9880d681SAndroid Build Coastguard Worker  %3 = load i32, i32* %arrayidx12
86*9880d681SAndroid Build Coastguard Worker  %arrayidx13 = getelementptr inbounds i32, i32 addrspace(1)* %out, i32 1
87*9880d681SAndroid Build Coastguard Worker  store i32 %3, i32 addrspace(1)* %arrayidx13
88*9880d681SAndroid Build Coastguard Worker  ret void
89*9880d681SAndroid Build Coastguard Worker}
90*9880d681SAndroid Build Coastguard Worker
91*9880d681SAndroid Build Coastguard Worker; CHECK: @occupancy_max(
92*9880d681SAndroid Build Coastguard Worker; CHECK: alloca [5 x i32]
93*9880d681SAndroid Build Coastguard Workerdefine void @occupancy_max(i32 addrspace(1)* nocapture %out, i32 addrspace(1)* nocapture %in) #4 {
94*9880d681SAndroid Build Coastguard Workerentry:
95*9880d681SAndroid Build Coastguard Worker  %stack = alloca [5 x i32], align 4
96*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32 addrspace(1)* %in, align 4
97*9880d681SAndroid Build Coastguard Worker  %arrayidx1 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 %0
98*9880d681SAndroid Build Coastguard Worker  store i32 4, i32* %arrayidx1, align 4
99*9880d681SAndroid Build Coastguard Worker  %arrayidx2 = getelementptr inbounds i32, i32 addrspace(1)* %in, i32 1
100*9880d681SAndroid Build Coastguard Worker  %1 = load i32, i32 addrspace(1)* %arrayidx2, align 4
101*9880d681SAndroid Build Coastguard Worker  %arrayidx3 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 %1
102*9880d681SAndroid Build Coastguard Worker  store i32 5, i32* %arrayidx3, align 4
103*9880d681SAndroid Build Coastguard Worker  %arrayidx10 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 0
104*9880d681SAndroid Build Coastguard Worker  %2 = load i32, i32* %arrayidx10, align 4
105*9880d681SAndroid Build Coastguard Worker  store i32 %2, i32 addrspace(1)* %out, align 4
106*9880d681SAndroid Build Coastguard Worker  %arrayidx12 = getelementptr inbounds [5 x i32], [5 x i32]* %stack, i32 0, i32 1
107*9880d681SAndroid Build Coastguard Worker  %3 = load i32, i32* %arrayidx12
108*9880d681SAndroid Build Coastguard Worker  %arrayidx13 = getelementptr inbounds i32, i32 addrspace(1)* %out, i32 1
109*9880d681SAndroid Build Coastguard Worker  store i32 %3, i32 addrspace(1)* %arrayidx13
110*9880d681SAndroid Build Coastguard Worker  ret void
111*9880d681SAndroid Build Coastguard Worker}
112*9880d681SAndroid Build Coastguard Worker
113*9880d681SAndroid Build Coastguard Workerattributes #0 = { nounwind "amdgpu-max-work-group-size"="63" }
114*9880d681SAndroid Build Coastguard Workerattributes #1 = { nounwind "amdgpu-max-waves-per-eu"="3" "amdgpu-max-work-group-size"="256" }
115*9880d681SAndroid Build Coastguard Workerattributes #2 = { nounwind "amdgpu-max-waves-per-eu"="1" "amdgpu-max-work-group-size"="1600" }
116*9880d681SAndroid Build Coastguard Workerattributes #3 = { nounwind "amdgpu-max-waves-per-eu"="0" }
117*9880d681SAndroid Build Coastguard Workerattributes #4 = { nounwind "amdgpu-max-waves-per-eu"="-1" }
118