annotate llvm/test/CodeGen/AMDGPU/promote-alloca-to-lds-phi.ll @ 206:f17a3b42b08b

Added tag before-12 for changeset b7591485f4cd
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 07 Jun 2021 21:25:57 +0900
parents 1d019706d866
children 2e18cbf3894f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 ; RUN: opt -S -mtriple=amdgcn-unknown-amdhsa -mcpu=kaveri -amdgpu-promote-alloca < %s | FileCheck %s
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3
anatofuz
parents:
diff changeset
4 ; CHECK-LABEL: @branch_ptr_var_same_alloca(
anatofuz
parents:
diff changeset
5 ; CHECK: getelementptr inbounds [256 x [64 x i32]], [256 x [64 x i32]] addrspace(3)* @branch_ptr_var_same_alloca.alloca, i32 0, i32 %{{[0-9]+}}
anatofuz
parents:
diff changeset
6
anatofuz
parents:
diff changeset
7 ; CHECK: if:
anatofuz
parents:
diff changeset
8 ; CHECK: %arrayidx0 = getelementptr inbounds [64 x i32], [64 x i32] addrspace(3)* %{{[0-9]+}}, i32 0, i32 %a
anatofuz
parents:
diff changeset
9
anatofuz
parents:
diff changeset
10 ; CHECK: else:
anatofuz
parents:
diff changeset
11 ; CHECK: %arrayidx1 = getelementptr inbounds [64 x i32], [64 x i32] addrspace(3)* %15, i32 0, i32 %b
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 ; CHECK: endif:
anatofuz
parents:
diff changeset
14 ; CHECK: %phi.ptr = phi i32 addrspace(3)* [ %arrayidx0, %if ], [ %arrayidx1, %else ]
anatofuz
parents:
diff changeset
15 ; CHECK: store i32 0, i32 addrspace(3)* %phi.ptr, align 4
anatofuz
parents:
diff changeset
16 define amdgpu_kernel void @branch_ptr_var_same_alloca(i32 %a, i32 %b) #0 {
anatofuz
parents:
diff changeset
17 entry:
anatofuz
parents:
diff changeset
18 %alloca = alloca [64 x i32], align 4
anatofuz
parents:
diff changeset
19 br i1 undef, label %if, label %else
anatofuz
parents:
diff changeset
20
anatofuz
parents:
diff changeset
21 if:
anatofuz
parents:
diff changeset
22 %arrayidx0 = getelementptr inbounds [64 x i32], [64 x i32]* %alloca, i32 0, i32 %a
anatofuz
parents:
diff changeset
23 br label %endif
anatofuz
parents:
diff changeset
24
anatofuz
parents:
diff changeset
25 else:
anatofuz
parents:
diff changeset
26 %arrayidx1 = getelementptr inbounds [64 x i32], [64 x i32]* %alloca, i32 0, i32 %b
anatofuz
parents:
diff changeset
27 br label %endif
anatofuz
parents:
diff changeset
28
anatofuz
parents:
diff changeset
29 endif:
anatofuz
parents:
diff changeset
30 %phi.ptr = phi i32* [ %arrayidx0, %if ], [ %arrayidx1, %else ]
anatofuz
parents:
diff changeset
31 store i32 0, i32* %phi.ptr, align 4
anatofuz
parents:
diff changeset
32 ret void
anatofuz
parents:
diff changeset
33 }
anatofuz
parents:
diff changeset
34
anatofuz
parents:
diff changeset
35 ; CHECK-LABEL: @branch_ptr_phi_alloca_null_0(
anatofuz
parents:
diff changeset
36 ; CHECK: %phi.ptr = phi i32 addrspace(3)* [ %arrayidx0, %if ], [ null, %entry ]
anatofuz
parents:
diff changeset
37 define amdgpu_kernel void @branch_ptr_phi_alloca_null_0(i32 %a, i32 %b) #0 {
anatofuz
parents:
diff changeset
38 entry:
anatofuz
parents:
diff changeset
39 %alloca = alloca [64 x i32], align 4
anatofuz
parents:
diff changeset
40 br i1 undef, label %if, label %endif
anatofuz
parents:
diff changeset
41
anatofuz
parents:
diff changeset
42 if:
anatofuz
parents:
diff changeset
43 %arrayidx0 = getelementptr inbounds [64 x i32], [64 x i32]* %alloca, i32 0, i32 %a
anatofuz
parents:
diff changeset
44 br label %endif
anatofuz
parents:
diff changeset
45
anatofuz
parents:
diff changeset
46 endif:
anatofuz
parents:
diff changeset
47 %phi.ptr = phi i32* [ %arrayidx0, %if ], [ null, %entry ]
anatofuz
parents:
diff changeset
48 store i32 0, i32* %phi.ptr, align 4
anatofuz
parents:
diff changeset
49 ret void
anatofuz
parents:
diff changeset
50 }
anatofuz
parents:
diff changeset
51
anatofuz
parents:
diff changeset
52 ; CHECK-LABEL: @branch_ptr_phi_alloca_null_1(
anatofuz
parents:
diff changeset
53 ; CHECK: %phi.ptr = phi i32 addrspace(3)* [ null, %entry ], [ %arrayidx0, %if ]
anatofuz
parents:
diff changeset
54 define amdgpu_kernel void @branch_ptr_phi_alloca_null_1(i32 %a, i32 %b) #0 {
anatofuz
parents:
diff changeset
55 entry:
anatofuz
parents:
diff changeset
56 %alloca = alloca [64 x i32], align 4
anatofuz
parents:
diff changeset
57 br i1 undef, label %if, label %endif
anatofuz
parents:
diff changeset
58
anatofuz
parents:
diff changeset
59 if:
anatofuz
parents:
diff changeset
60 %arrayidx0 = getelementptr inbounds [64 x i32], [64 x i32]* %alloca, i32 0, i32 %a
anatofuz
parents:
diff changeset
61 br label %endif
anatofuz
parents:
diff changeset
62
anatofuz
parents:
diff changeset
63 endif:
anatofuz
parents:
diff changeset
64 %phi.ptr = phi i32* [ null, %entry ], [ %arrayidx0, %if ]
anatofuz
parents:
diff changeset
65 store i32 0, i32* %phi.ptr, align 4
anatofuz
parents:
diff changeset
66 ret void
anatofuz
parents:
diff changeset
67 }
anatofuz
parents:
diff changeset
68
anatofuz
parents:
diff changeset
69 ; CHECK-LABEL: @one_phi_value(
anatofuz
parents:
diff changeset
70 ; CHECK: getelementptr inbounds [256 x [64 x i32]], [256 x [64 x i32]] addrspace(3)* @one_phi_value.alloca, i32 0, i32 %14
anatofuz
parents:
diff changeset
71 ; CHECK: %arrayidx0 = getelementptr inbounds [64 x i32], [64 x i32] addrspace(3)* %{{[0-9]+}}, i32 0, i32 %a
anatofuz
parents:
diff changeset
72
anatofuz
parents:
diff changeset
73 ; CHECK: br label %exit
anatofuz
parents:
diff changeset
74 ; CHECK: %phi.ptr = phi i32 addrspace(3)* [ %arrayidx0, %entry ]
anatofuz
parents:
diff changeset
75 ; CHECK: store i32 0, i32 addrspace(3)* %phi.ptr, align 4
anatofuz
parents:
diff changeset
76 define amdgpu_kernel void @one_phi_value(i32 %a) #0 {
anatofuz
parents:
diff changeset
77 entry:
anatofuz
parents:
diff changeset
78 %alloca = alloca [64 x i32], align 4
anatofuz
parents:
diff changeset
79 %arrayidx0 = getelementptr inbounds [64 x i32], [64 x i32]* %alloca, i32 0, i32 %a
anatofuz
parents:
diff changeset
80 br label %exit
anatofuz
parents:
diff changeset
81
anatofuz
parents:
diff changeset
82 exit:
anatofuz
parents:
diff changeset
83 %phi.ptr = phi i32* [ %arrayidx0, %entry ]
anatofuz
parents:
diff changeset
84 store i32 0, i32* %phi.ptr, align 4
anatofuz
parents:
diff changeset
85 ret void
anatofuz
parents:
diff changeset
86 }
anatofuz
parents:
diff changeset
87
anatofuz
parents:
diff changeset
88 ; CHECK-LABEL: @branch_ptr_alloca_unknown_obj(
anatofuz
parents:
diff changeset
89 ; CHECK: %alloca = alloca [64 x i32], align 4
anatofuz
parents:
diff changeset
90
anatofuz
parents:
diff changeset
91 ; CHECK: if:
anatofuz
parents:
diff changeset
92 ; CHECK: %arrayidx0 = getelementptr inbounds [64 x i32], [64 x i32]* %alloca, i32 0, i32 %a
anatofuz
parents:
diff changeset
93
anatofuz
parents:
diff changeset
94 ; CHECK: else:
anatofuz
parents:
diff changeset
95 ; CHECK: %arrayidx1 = call i32* @get_unknown_pointer()
anatofuz
parents:
diff changeset
96
anatofuz
parents:
diff changeset
97 ; CHECK: endif:
anatofuz
parents:
diff changeset
98 ; CHECK: %phi.ptr = phi i32* [ %arrayidx0, %if ], [ %arrayidx1, %else ]
anatofuz
parents:
diff changeset
99 ; CHECK: store i32 0, i32* %phi.ptr, align 4
anatofuz
parents:
diff changeset
100 define amdgpu_kernel void @branch_ptr_alloca_unknown_obj(i32 %a, i32 %b) #0 {
anatofuz
parents:
diff changeset
101 entry:
anatofuz
parents:
diff changeset
102 %alloca = alloca [64 x i32], align 4
anatofuz
parents:
diff changeset
103 br i1 undef, label %if, label %else
anatofuz
parents:
diff changeset
104
anatofuz
parents:
diff changeset
105 if:
anatofuz
parents:
diff changeset
106 %arrayidx0 = getelementptr inbounds [64 x i32], [64 x i32]* %alloca, i32 0, i32 %a
anatofuz
parents:
diff changeset
107 br label %endif
anatofuz
parents:
diff changeset
108
anatofuz
parents:
diff changeset
109 else:
anatofuz
parents:
diff changeset
110 %arrayidx1 = call i32* @get_unknown_pointer()
anatofuz
parents:
diff changeset
111 br label %endif
anatofuz
parents:
diff changeset
112
anatofuz
parents:
diff changeset
113 endif:
anatofuz
parents:
diff changeset
114 %phi.ptr = phi i32* [ %arrayidx0, %if ], [ %arrayidx1, %else ]
anatofuz
parents:
diff changeset
115 store i32 0, i32* %phi.ptr, align 4
anatofuz
parents:
diff changeset
116 ret void
anatofuz
parents:
diff changeset
117 }
anatofuz
parents:
diff changeset
118
anatofuz
parents:
diff changeset
119 ; kernel void ptr_induction_var_same_alloca(void)
anatofuz
parents:
diff changeset
120 ; {
anatofuz
parents:
diff changeset
121 ; int alloca[64];
anatofuz
parents:
diff changeset
122 ; int i = 0;
anatofuz
parents:
diff changeset
123
anatofuz
parents:
diff changeset
124 ; #pragma nounroll
anatofuz
parents:
diff changeset
125 ; for (int* p = &alloca[2], *e = &alloca[48]; p != e; ++p, ++i)
anatofuz
parents:
diff changeset
126 ; {
anatofuz
parents:
diff changeset
127 ; *p = i;
anatofuz
parents:
diff changeset
128 ; }
anatofuz
parents:
diff changeset
129 ; }
anatofuz
parents:
diff changeset
130
anatofuz
parents:
diff changeset
131 ; FIXME: This should be promotable. We need to use
anatofuz
parents:
diff changeset
132 ; GetUnderlyingObjects when looking at the icmp user.
anatofuz
parents:
diff changeset
133
anatofuz
parents:
diff changeset
134 ; CHECK-LABEL: @ptr_induction_var_same_alloca(
anatofuz
parents:
diff changeset
135 ; CHECK: %alloca = alloca [64 x i32], align 4
anatofuz
parents:
diff changeset
136 ; CHECK: phi i32* [ %arrayidx, %entry ], [ %incdec.ptr, %for.body ]
anatofuz
parents:
diff changeset
137 define amdgpu_kernel void @ptr_induction_var_same_alloca() #0 {
anatofuz
parents:
diff changeset
138 entry:
anatofuz
parents:
diff changeset
139 %alloca = alloca [64 x i32], align 4
anatofuz
parents:
diff changeset
140 %arrayidx = getelementptr inbounds [64 x i32], [64 x i32]* %alloca, i32 0, i32 2
anatofuz
parents:
diff changeset
141 %arrayidx1 = getelementptr inbounds [64 x i32], [64 x i32]* %alloca, i32 0, i32 48
anatofuz
parents:
diff changeset
142 br label %for.body
anatofuz
parents:
diff changeset
143
anatofuz
parents:
diff changeset
144 for.cond.cleanup: ; preds = %for.body
anatofuz
parents:
diff changeset
145 ret void
anatofuz
parents:
diff changeset
146
anatofuz
parents:
diff changeset
147 for.body: ; preds = %for.body, %entry
anatofuz
parents:
diff changeset
148 %i.09 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
anatofuz
parents:
diff changeset
149 %p.08 = phi i32* [ %arrayidx, %entry ], [ %incdec.ptr, %for.body ]
anatofuz
parents:
diff changeset
150 store i32 %i.09, i32* %p.08, align 4
anatofuz
parents:
diff changeset
151 %incdec.ptr = getelementptr inbounds i32, i32* %p.08, i32 1
anatofuz
parents:
diff changeset
152 %inc = add nuw nsw i32 %i.09, 1
anatofuz
parents:
diff changeset
153 %cmp = icmp eq i32* %incdec.ptr, %arrayidx1
anatofuz
parents:
diff changeset
154 br i1 %cmp, label %for.cond.cleanup, label %for.body
anatofuz
parents:
diff changeset
155 }
anatofuz
parents:
diff changeset
156
anatofuz
parents:
diff changeset
157
anatofuz
parents:
diff changeset
158 ; extern int* get_unknown_pointer(void);
anatofuz
parents:
diff changeset
159
anatofuz
parents:
diff changeset
160 ; kernel void ptr_induction_var_alloca_unknown(void)
anatofuz
parents:
diff changeset
161 ; {
anatofuz
parents:
diff changeset
162 ; int alloca[64];
anatofuz
parents:
diff changeset
163 ; int i = 0;
anatofuz
parents:
diff changeset
164 ;
anatofuz
parents:
diff changeset
165 ; for (int* p = &alloca[2], *e = get_unknown_pointer(); p != e; ++p, ++i)
anatofuz
parents:
diff changeset
166 ; {
anatofuz
parents:
diff changeset
167 ; *p = i;
anatofuz
parents:
diff changeset
168 ; }
anatofuz
parents:
diff changeset
169 ; }
anatofuz
parents:
diff changeset
170
anatofuz
parents:
diff changeset
171 ; CHECK-LABEL: @ptr_induction_var_alloca_unknown(
anatofuz
parents:
diff changeset
172 ; CHECK: %alloca = alloca [64 x i32], align 4
anatofuz
parents:
diff changeset
173 ; CHECK: %p.08 = phi i32* [ %incdec.ptr, %for.body ], [ %arrayidx, %for.body.preheader ]
anatofuz
parents:
diff changeset
174 ; CHECK: %cmp = icmp eq i32* %incdec.ptr, %call
anatofuz
parents:
diff changeset
175 define amdgpu_kernel void @ptr_induction_var_alloca_unknown() #0 {
anatofuz
parents:
diff changeset
176 entry:
anatofuz
parents:
diff changeset
177 %alloca = alloca [64 x i32], align 4
anatofuz
parents:
diff changeset
178 %arrayidx = getelementptr inbounds [64 x i32], [64 x i32]* %alloca, i32 0, i32 2
anatofuz
parents:
diff changeset
179 %call = tail call i32* @get_unknown_pointer() #2
anatofuz
parents:
diff changeset
180 %cmp.7 = icmp eq i32* %arrayidx, %call
anatofuz
parents:
diff changeset
181 br i1 %cmp.7, label %for.cond.cleanup, label %for.body.preheader
anatofuz
parents:
diff changeset
182
anatofuz
parents:
diff changeset
183 for.body.preheader: ; preds = %entry
anatofuz
parents:
diff changeset
184 br label %for.body
anatofuz
parents:
diff changeset
185
anatofuz
parents:
diff changeset
186 for.cond.cleanup.loopexit: ; preds = %for.body
anatofuz
parents:
diff changeset
187 br label %for.cond.cleanup
anatofuz
parents:
diff changeset
188
anatofuz
parents:
diff changeset
189 for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %entry
anatofuz
parents:
diff changeset
190 ret void
anatofuz
parents:
diff changeset
191
anatofuz
parents:
diff changeset
192 for.body: ; preds = %for.body, %for.body.preheader
anatofuz
parents:
diff changeset
193 %i.09 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ]
anatofuz
parents:
diff changeset
194 %p.08 = phi i32* [ %incdec.ptr, %for.body ], [ %arrayidx, %for.body.preheader ]
anatofuz
parents:
diff changeset
195 store i32 %i.09, i32* %p.08, align 4
anatofuz
parents:
diff changeset
196 %incdec.ptr = getelementptr inbounds i32, i32* %p.08, i32 1
anatofuz
parents:
diff changeset
197 %inc = add nuw nsw i32 %i.09, 1
anatofuz
parents:
diff changeset
198 %cmp = icmp eq i32* %incdec.ptr, %call
anatofuz
parents:
diff changeset
199 br i1 %cmp, label %for.cond.cleanup.loopexit, label %for.body
anatofuz
parents:
diff changeset
200 }
anatofuz
parents:
diff changeset
201
anatofuz
parents:
diff changeset
202 declare i32* @get_unknown_pointer() #0
anatofuz
parents:
diff changeset
203
anatofuz
parents:
diff changeset
204 attributes #0 = { nounwind "amdgpu-waves-per-eu"="1,1" "amdgpu-flat-work-group-size"="1,256" }