1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -run-pass=amdgpu-postlegalizer-combiner -verify-machineinstrs %s -o - | FileCheck %s
3 # RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -run-pass=amdgpu-postlegalizer-combiner -verify-machineinstrs %s -o - | FileCheck %s
4 # RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1100 -run-pass=amdgpu-postlegalizer-combiner -verify-machineinstrs %s -o - | FileCheck %s
7 name: remove_and_255_zextload
9 tracksRegLiveness: true
13 ; CHECK-LABEL: name: remove_and_255_zextload
14 ; CHECK: liveins: $vgpr0_vgpr1
16 ; CHECK-NEXT: %ptr:_(p1) = COPY $vgpr0_vgpr1
17 ; CHECK-NEXT: %and:_(s32) = G_ZEXTLOAD %ptr(p1) :: (load (s8), addrspace 1)
18 ; CHECK-NEXT: $vgpr0 = COPY %and(s32)
19 %ptr:_(p1) = COPY $vgpr0_vgpr1
20 %load:_(s32) = G_ZEXTLOAD %ptr :: (load (s8), addrspace 1, align 1)
21 %mask:_(s32) = G_CONSTANT i32 255
22 %and:_(s32) = G_AND %load, %mask
28 name: remove_and_255_smin_zextload
30 tracksRegLiveness: true
33 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
34 ; CHECK-LABEL: name: remove_and_255_smin_zextload
35 ; CHECK: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
37 ; CHECK-NEXT: %ptr0:_(p1) = COPY $vgpr0_vgpr1
38 ; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr2_vgpr3
39 ; CHECK-NEXT: %load0:_(s32) = G_ZEXTLOAD %ptr0(p1) :: (load (s8), addrspace 1)
40 ; CHECK-NEXT: %load1:_(s32) = G_ZEXTLOAD %ptr1(p1) :: (load (s8), addrspace 1)
41 ; CHECK-NEXT: %smin:_(s32) = G_SMIN %load0, %load1
42 ; CHECK-NEXT: $vgpr0 = COPY %smin(s32)
43 %ptr0:_(p1) = COPY $vgpr0_vgpr1
44 %ptr1:_(p1) = COPY $vgpr2_vgpr3
45 %load0:_(s32) = G_ZEXTLOAD %ptr0 :: (load (s8), addrspace 1, align 1)
46 %load1:_(s32) = G_ZEXTLOAD %ptr1 :: (load (s8), addrspace 1, align 1)
47 %smin:_(s32) = G_SMIN %load0, %load1
48 %mask:_(s32) = G_CONSTANT i32 255
49 %and:_(s32) = G_AND %smin, %mask
55 name: remove_and_255_smax_zextload
57 tracksRegLiveness: true
60 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
61 ; CHECK-LABEL: name: remove_and_255_smax_zextload
62 ; CHECK: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
64 ; CHECK-NEXT: %ptr0:_(p1) = COPY $vgpr0_vgpr1
65 ; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr2_vgpr3
66 ; CHECK-NEXT: %load0:_(s32) = G_ZEXTLOAD %ptr0(p1) :: (load (s8), addrspace 1)
67 ; CHECK-NEXT: %load1:_(s32) = G_ZEXTLOAD %ptr1(p1) :: (load (s8), addrspace 1)
68 ; CHECK-NEXT: %smax:_(s32) = G_SMAX %load0, %load1
69 ; CHECK-NEXT: $vgpr0 = COPY %smax(s32)
70 %ptr0:_(p1) = COPY $vgpr0_vgpr1
71 %ptr1:_(p1) = COPY $vgpr2_vgpr3
72 %load0:_(s32) = G_ZEXTLOAD %ptr0 :: (load (s8), addrspace 1, align 1)
73 %load1:_(s32) = G_ZEXTLOAD %ptr1 :: (load (s8), addrspace 1, align 1)
74 %smax:_(s32) = G_SMAX %load0, %load1
75 %mask:_(s32) = G_CONSTANT i32 255
76 %and:_(s32) = G_AND %smax, %mask
82 name: remove_and_255_umin_zextload
84 tracksRegLiveness: true
87 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
88 ; CHECK-LABEL: name: remove_and_255_umin_zextload
89 ; CHECK: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
91 ; CHECK-NEXT: %ptr0:_(p1) = COPY $vgpr0_vgpr1
92 ; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr2_vgpr3
93 ; CHECK-NEXT: %load0:_(s32) = G_ZEXTLOAD %ptr0(p1) :: (load (s8), addrspace 1)
94 ; CHECK-NEXT: %load1:_(s32) = G_ZEXTLOAD %ptr1(p1) :: (load (s8), addrspace 1)
95 ; CHECK-NEXT: %umin:_(s32) = G_UMIN %load0, %load1
96 ; CHECK-NEXT: $vgpr0 = COPY %umin(s32)
97 %ptr0:_(p1) = COPY $vgpr0_vgpr1
98 %ptr1:_(p1) = COPY $vgpr2_vgpr3
99 %load0:_(s32) = G_ZEXTLOAD %ptr0 :: (load (s8), addrspace 1, align 1)
100 %load1:_(s32) = G_ZEXTLOAD %ptr1 :: (load (s8), addrspace 1, align 1)
101 %umin:_(s32) = G_UMIN %load0, %load1
102 %mask:_(s32) = G_CONSTANT i32 255
103 %and:_(s32) = G_AND %umin, %mask
109 name: remove_and_255_umax_zextload
111 tracksRegLiveness: true
114 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
115 ; CHECK-LABEL: name: remove_and_255_umax_zextload
116 ; CHECK: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
118 ; CHECK-NEXT: %ptr0:_(p1) = COPY $vgpr0_vgpr1
119 ; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr2_vgpr3
120 ; CHECK-NEXT: %load0:_(s32) = G_ZEXTLOAD %ptr0(p1) :: (load (s8), addrspace 1)
121 ; CHECK-NEXT: %load1:_(s32) = G_ZEXTLOAD %ptr1(p1) :: (load (s8), addrspace 1)
122 ; CHECK-NEXT: %umax:_(s32) = G_UMAX %load0, %load1
123 ; CHECK-NEXT: $vgpr0 = COPY %umax(s32)
124 %ptr0:_(p1) = COPY $vgpr0_vgpr1
125 %ptr1:_(p1) = COPY $vgpr2_vgpr3
126 %load0:_(s32) = G_ZEXTLOAD %ptr0 :: (load (s8), addrspace 1, align 1)
127 %load1:_(s32) = G_ZEXTLOAD %ptr1 :: (load (s8), addrspace 1, align 1)
128 %umax:_(s32) = G_UMAX %load0, %load1
129 %mask:_(s32) = G_CONSTANT i32 255
130 %and:_(s32) = G_AND %umax, %mask
135 # Don't have enough known bits for lhs
137 name: remove_and_255_smin_fail_lhs
139 tracksRegLiveness: true
142 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
143 ; CHECK-LABEL: name: remove_and_255_smin_fail_lhs
144 ; CHECK: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
146 ; CHECK-NEXT: %ptr0:_(p1) = COPY $vgpr0_vgpr1
147 ; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr2_vgpr3
148 ; CHECK-NEXT: %load0:_(s32) = G_LOAD %ptr0(p1) :: (load (s32), addrspace 1)
149 ; CHECK-NEXT: %load1:_(s32) = G_ZEXTLOAD %ptr1(p1) :: (load (s8), addrspace 1)
150 ; CHECK-NEXT: %smin:_(s32) = G_SMIN %load0, %load1
151 ; CHECK-NEXT: %mask:_(s32) = G_CONSTANT i32 255
152 ; CHECK-NEXT: %and:_(s32) = G_AND %smin, %mask
153 ; CHECK-NEXT: $vgpr0 = COPY %and(s32)
154 %ptr0:_(p1) = COPY $vgpr0_vgpr1
155 %ptr1:_(p1) = COPY $vgpr2_vgpr3
156 %load0:_(s32) = G_LOAD %ptr0 :: (load (s32), addrspace 1, align 4)
157 %load1:_(s32) = G_ZEXTLOAD %ptr1 :: (load (s8), addrspace 1, align 1)
158 %smin:_(s32) = G_SMIN %load0, %load1
159 %mask:_(s32) = G_CONSTANT i32 255
160 %and:_(s32) = G_AND %smin, %mask
165 # Don't have enough known bits for rhs
167 name: remove_and_255_smin_fail_rhs
169 tracksRegLiveness: true
172 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
173 ; CHECK-LABEL: name: remove_and_255_smin_fail_rhs
174 ; CHECK: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
176 ; CHECK-NEXT: %ptr0:_(p1) = COPY $vgpr0_vgpr1
177 ; CHECK-NEXT: %ptr1:_(p1) = COPY $vgpr2_vgpr3
178 ; CHECK-NEXT: %load0:_(s32) = G_ZEXTLOAD %ptr0(p1) :: (load (s8), addrspace 1)
179 ; CHECK-NEXT: %load1:_(s32) = G_LOAD %ptr1(p1) :: (load (s32), addrspace 1)
180 ; CHECK-NEXT: %smin:_(s32) = G_SMIN %load0, %load1
181 ; CHECK-NEXT: %mask:_(s32) = G_CONSTANT i32 255
182 ; CHECK-NEXT: %and:_(s32) = G_AND %smin, %mask
183 ; CHECK-NEXT: $vgpr0 = COPY %and(s32)
184 %ptr0:_(p1) = COPY $vgpr0_vgpr1
185 %ptr1:_(p1) = COPY $vgpr2_vgpr3
186 %load0:_(s32) = G_ZEXTLOAD %ptr0 :: (load (s8), addrspace 1, align 1)
187 %load1:_(s32) = G_LOAD %ptr1 :: (load (s32), addrspace 1, align 4)
188 %smin:_(s32) = G_SMIN %load0, %load1
189 %mask:_(s32) = G_CONSTANT i32 255
190 %and:_(s32) = G_AND %smin, %mask
195 # Test known bits for groupstaticsize is the maximum LDS size.
197 name: remove_and_65535_groupstaticsize
199 tracksRegLiveness: true
202 liveins: $vgpr0_vgpr1
203 ; CHECK-LABEL: name: remove_and_65535_groupstaticsize
204 ; CHECK: liveins: $vgpr0_vgpr1
206 ; CHECK-NEXT: %lds_size:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.groupstaticsize)
207 ; CHECK-NEXT: %mask:_(s32) = G_CONSTANT i32 65535
208 ; CHECK-NEXT: %and:_(s32) = G_AND %lds_size, %mask
209 ; CHECK-NEXT: $vgpr0 = COPY %and(s32)
210 %ptr:_(p1) = COPY $vgpr0_vgpr1
211 %lds_size:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.groupstaticsize)
212 %mask:_(s32) = G_CONSTANT i32 65535
213 %and:_(s32) = G_AND %lds_size, %mask
219 name: remove_and_131071_groupstaticsize
221 tracksRegLiveness: true
224 liveins: $vgpr0_vgpr1
225 ; CHECK-LABEL: name: remove_and_131071_groupstaticsize
226 ; CHECK: liveins: $vgpr0_vgpr1
228 ; CHECK-NEXT: %lds_size:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.groupstaticsize)
229 ; CHECK-NEXT: $vgpr0 = COPY %lds_size(s32)
230 %ptr:_(p1) = COPY $vgpr0_vgpr1
231 %lds_size:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.groupstaticsize)
232 %mask:_(s32) = G_CONSTANT i32 131071
233 %and:_(s32) = G_AND %lds_size, %mask
239 name: no_remove_and_65536_groupstaticsize
241 tracksRegLiveness: true
244 liveins: $vgpr0_vgpr1
245 ; CHECK-LABEL: name: no_remove_and_65536_groupstaticsize
246 ; CHECK: liveins: $vgpr0_vgpr1
248 ; CHECK-NEXT: %lds_size:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.groupstaticsize)
249 ; CHECK-NEXT: %mask:_(s32) = G_CONSTANT i32 65536
250 ; CHECK-NEXT: %and:_(s32) = G_AND %lds_size, %mask
251 ; CHECK-NEXT: $vgpr0 = COPY %and(s32)
252 %ptr:_(p1) = COPY $vgpr0_vgpr1
253 %lds_size:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.groupstaticsize)
254 %mask:_(s32) = G_CONSTANT i32 65536
255 %and:_(s32) = G_AND %lds_size, %mask
261 name: no_remove_and_32767_groupstaticsize
263 tracksRegLiveness: true
266 liveins: $vgpr0_vgpr1
267 ; CHECK-LABEL: name: no_remove_and_32767_groupstaticsize
268 ; CHECK: liveins: $vgpr0_vgpr1
270 ; CHECK-NEXT: %lds_size:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.groupstaticsize)
271 ; CHECK-NEXT: %mask:_(s32) = G_CONSTANT i32 32767
272 ; CHECK-NEXT: %and:_(s32) = G_AND %lds_size, %mask
273 ; CHECK-NEXT: $vgpr0 = COPY %and(s32)
274 %ptr:_(p1) = COPY $vgpr0_vgpr1
275 %lds_size:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.groupstaticsize)
276 %mask:_(s32) = G_CONSTANT i32 32767
277 %and:_(s32) = G_AND %lds_size, %mask
282 # We can conclude the number of bits based only on one operand
284 name: remove_and_umin_lhs_only
286 tracksRegLiveness: true
289 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4
291 ; CHECK-LABEL: name: remove_and_umin_lhs_only
292 ; CHECK: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4
294 ; CHECK-NEXT: %val:_(s32) = COPY $vgpr4
295 ; CHECK-NEXT: %k255:_(s32) = G_CONSTANT i32 255
296 ; CHECK-NEXT: %umin0:_(s32) = G_UMIN %val, %k255
297 ; CHECK-NEXT: $vgpr0 = COPY %umin0(s32)
298 %ptr0:_(p1) = COPY $vgpr0_vgpr1
299 %ptr1:_(p1) = COPY $vgpr2_vgpr3
300 %val:_(s32) = COPY $vgpr4
301 %k255:_(s32) = G_CONSTANT i32 255
302 %umin0:_(s32) = G_UMIN %val, %k255
303 %and:_(s32) = G_AND %umin0, %k255
309 name: remove_and_umin_rhs_only
311 tracksRegLiveness: true
314 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4
316 ; CHECK-LABEL: name: remove_and_umin_rhs_only
317 ; CHECK: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4
319 ; CHECK-NEXT: %val:_(s32) = COPY $vgpr4
320 ; CHECK-NEXT: %k255:_(s32) = G_CONSTANT i32 255
321 ; CHECK-NEXT: %umin0:_(s32) = G_UMIN %val, %k255
322 ; CHECK-NEXT: $vgpr0 = COPY %umin0(s32)
323 %ptr0:_(p1) = COPY $vgpr0_vgpr1
324 %ptr1:_(p1) = COPY $vgpr2_vgpr3
325 %val:_(s32) = COPY $vgpr4
326 %k255:_(s32) = G_CONSTANT i32 255
327 %umin0:_(s32) = G_UMIN %k255, %val
328 %and:_(s32) = G_AND %umin0, %k255