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
6 name: remove_and_255_zextload
8 tracksRegLiveness: true
12 ; CHECK-LABEL: name: remove_and_255_zextload
13 ; CHECK: liveins: $vgpr0_vgpr1
14 ; CHECK: %ptr:_(p1) = COPY $vgpr0_vgpr1
15 ; CHECK: %and:_(s32) = G_ZEXTLOAD %ptr(p1) :: (load (s8), addrspace 1)
16 ; CHECK: $vgpr0 = COPY %and(s32)
17 %ptr:_(p1) = COPY $vgpr0_vgpr1
18 %load:_(s32) = G_ZEXTLOAD %ptr :: (load (s8), addrspace 1, align 1)
19 %mask:_(s32) = G_CONSTANT i32 255
20 %and:_(s32) = G_AND %load, %mask
26 name: remove_and_255_smin_zextload
28 tracksRegLiveness: true
31 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
32 ; CHECK-LABEL: name: remove_and_255_smin_zextload
33 ; CHECK: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
34 ; CHECK: %ptr0:_(p1) = COPY $vgpr0_vgpr1
35 ; CHECK: %ptr1:_(p1) = COPY $vgpr2_vgpr3
36 ; CHECK: %load0:_(s32) = G_ZEXTLOAD %ptr0(p1) :: (load (s8), addrspace 1)
37 ; CHECK: %load1:_(s32) = G_ZEXTLOAD %ptr1(p1) :: (load (s8), addrspace 1)
38 ; CHECK: %smin:_(s32) = G_SMIN %load0, %load1
39 ; CHECK: $vgpr0 = COPY %smin(s32)
40 %ptr0:_(p1) = COPY $vgpr0_vgpr1
41 %ptr1:_(p1) = COPY $vgpr2_vgpr3
42 %load0:_(s32) = G_ZEXTLOAD %ptr0 :: (load (s8), addrspace 1, align 1)
43 %load1:_(s32) = G_ZEXTLOAD %ptr1 :: (load (s8), addrspace 1, align 1)
44 %smin:_(s32) = G_SMIN %load0, %load1
45 %mask:_(s32) = G_CONSTANT i32 255
46 %and:_(s32) = G_AND %smin, %mask
52 name: remove_and_255_smax_zextload
54 tracksRegLiveness: true
57 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
58 ; CHECK-LABEL: name: remove_and_255_smax_zextload
59 ; CHECK: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
60 ; CHECK: %ptr0:_(p1) = COPY $vgpr0_vgpr1
61 ; CHECK: %ptr1:_(p1) = COPY $vgpr2_vgpr3
62 ; CHECK: %load0:_(s32) = G_ZEXTLOAD %ptr0(p1) :: (load (s8), addrspace 1)
63 ; CHECK: %load1:_(s32) = G_ZEXTLOAD %ptr1(p1) :: (load (s8), addrspace 1)
64 ; CHECK: %smax:_(s32) = G_SMAX %load0, %load1
65 ; CHECK: $vgpr0 = COPY %smax(s32)
66 %ptr0:_(p1) = COPY $vgpr0_vgpr1
67 %ptr1:_(p1) = COPY $vgpr2_vgpr3
68 %load0:_(s32) = G_ZEXTLOAD %ptr0 :: (load (s8), addrspace 1, align 1)
69 %load1:_(s32) = G_ZEXTLOAD %ptr1 :: (load (s8), addrspace 1, align 1)
70 %smax:_(s32) = G_SMAX %load0, %load1
71 %mask:_(s32) = G_CONSTANT i32 255
72 %and:_(s32) = G_AND %smax, %mask
78 name: remove_and_255_umin_zextload
80 tracksRegLiveness: true
83 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
84 ; CHECK-LABEL: name: remove_and_255_umin_zextload
85 ; CHECK: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
86 ; CHECK: %ptr0:_(p1) = COPY $vgpr0_vgpr1
87 ; CHECK: %ptr1:_(p1) = COPY $vgpr2_vgpr3
88 ; CHECK: %load0:_(s32) = G_ZEXTLOAD %ptr0(p1) :: (load (s8), addrspace 1)
89 ; CHECK: %load1:_(s32) = G_ZEXTLOAD %ptr1(p1) :: (load (s8), addrspace 1)
90 ; CHECK: %umin:_(s32) = G_UMIN %load0, %load1
91 ; CHECK: $vgpr0 = COPY %umin(s32)
92 %ptr0:_(p1) = COPY $vgpr0_vgpr1
93 %ptr1:_(p1) = COPY $vgpr2_vgpr3
94 %load0:_(s32) = G_ZEXTLOAD %ptr0 :: (load (s8), addrspace 1, align 1)
95 %load1:_(s32) = G_ZEXTLOAD %ptr1 :: (load (s8), addrspace 1, align 1)
96 %umin:_(s32) = G_UMIN %load0, %load1
97 %mask:_(s32) = G_CONSTANT i32 255
98 %and:_(s32) = G_AND %umin, %mask
104 name: remove_and_255_umax_zextload
106 tracksRegLiveness: true
109 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
110 ; CHECK-LABEL: name: remove_and_255_umax_zextload
111 ; CHECK: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
112 ; CHECK: %ptr0:_(p1) = COPY $vgpr0_vgpr1
113 ; CHECK: %ptr1:_(p1) = COPY $vgpr2_vgpr3
114 ; CHECK: %load0:_(s32) = G_ZEXTLOAD %ptr0(p1) :: (load (s8), addrspace 1)
115 ; CHECK: %load1:_(s32) = G_ZEXTLOAD %ptr1(p1) :: (load (s8), addrspace 1)
116 ; CHECK: %umax:_(s32) = G_UMAX %load0, %load1
117 ; CHECK: $vgpr0 = COPY %umax(s32)
118 %ptr0:_(p1) = COPY $vgpr0_vgpr1
119 %ptr1:_(p1) = COPY $vgpr2_vgpr3
120 %load0:_(s32) = G_ZEXTLOAD %ptr0 :: (load (s8), addrspace 1, align 1)
121 %load1:_(s32) = G_ZEXTLOAD %ptr1 :: (load (s8), addrspace 1, align 1)
122 %umax:_(s32) = G_UMAX %load0, %load1
123 %mask:_(s32) = G_CONSTANT i32 255
124 %and:_(s32) = G_AND %umax, %mask
129 # Don't have enough known bits for lhs
131 name: remove_and_255_smin_fail_lhs
133 tracksRegLiveness: true
136 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
137 ; CHECK-LABEL: name: remove_and_255_smin_fail_lhs
138 ; CHECK: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
139 ; CHECK: %ptr0:_(p1) = COPY $vgpr0_vgpr1
140 ; CHECK: %ptr1:_(p1) = COPY $vgpr2_vgpr3
141 ; CHECK: %load0:_(s32) = G_LOAD %ptr0(p1) :: (load (s32), addrspace 1)
142 ; CHECK: %load1:_(s32) = G_ZEXTLOAD %ptr1(p1) :: (load (s8), addrspace 1)
143 ; CHECK: %smin:_(s32) = G_SMIN %load0, %load1
144 ; CHECK: %mask:_(s32) = G_CONSTANT i32 255
145 ; CHECK: %and:_(s32) = G_AND %smin, %mask
146 ; CHECK: $vgpr0 = COPY %and(s32)
147 %ptr0:_(p1) = COPY $vgpr0_vgpr1
148 %ptr1:_(p1) = COPY $vgpr2_vgpr3
149 %load0:_(s32) = G_LOAD %ptr0 :: (load (s32), addrspace 1, align 4)
150 %load1:_(s32) = G_ZEXTLOAD %ptr1 :: (load (s8), addrspace 1, align 1)
151 %smin:_(s32) = G_SMIN %load0, %load1
152 %mask:_(s32) = G_CONSTANT i32 255
153 %and:_(s32) = G_AND %smin, %mask
158 # Don't have enough known bits for rhs
160 name: remove_and_255_smin_fail_rhs
162 tracksRegLiveness: true
165 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
166 ; CHECK-LABEL: name: remove_and_255_smin_fail_rhs
167 ; CHECK: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3
168 ; CHECK: %ptr0:_(p1) = COPY $vgpr0_vgpr1
169 ; CHECK: %ptr1:_(p1) = COPY $vgpr2_vgpr3
170 ; CHECK: %load0:_(s32) = G_ZEXTLOAD %ptr0(p1) :: (load (s8), addrspace 1)
171 ; CHECK: %load1:_(s32) = G_LOAD %ptr1(p1) :: (load (s32), addrspace 1)
172 ; CHECK: %smin:_(s32) = G_SMIN %load0, %load1
173 ; CHECK: %mask:_(s32) = G_CONSTANT i32 255
174 ; CHECK: %and:_(s32) = G_AND %smin, %mask
175 ; CHECK: $vgpr0 = COPY %and(s32)
176 %ptr0:_(p1) = COPY $vgpr0_vgpr1
177 %ptr1:_(p1) = COPY $vgpr2_vgpr3
178 %load0:_(s32) = G_ZEXTLOAD %ptr0 :: (load (s8), addrspace 1, align 1)
179 %load1:_(s32) = G_LOAD %ptr1 :: (load (s32), addrspace 1, align 4)
180 %smin:_(s32) = G_SMIN %load0, %load1
181 %mask:_(s32) = G_CONSTANT i32 255
182 %and:_(s32) = G_AND %smin, %mask
187 # Test known bits for groupstaticsize is the maximum LDS size.
189 name: remove_and_65535_groupstaticsize
191 tracksRegLiveness: true
194 liveins: $vgpr0_vgpr1
195 ; CHECK-LABEL: name: remove_and_65535_groupstaticsize
196 ; CHECK: liveins: $vgpr0_vgpr1
197 ; CHECK: %lds_size:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.groupstaticsize)
198 ; CHECK: %mask:_(s32) = G_CONSTANT i32 65535
199 ; CHECK: %and:_(s32) = G_AND %lds_size, %mask
200 ; CHECK: $vgpr0 = COPY %and(s32)
201 %ptr:_(p1) = COPY $vgpr0_vgpr1
202 %lds_size:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.groupstaticsize)
203 %mask:_(s32) = G_CONSTANT i32 65535
204 %and:_(s32) = G_AND %lds_size, %mask
210 name: remove_and_131071_groupstaticsize
212 tracksRegLiveness: true
215 liveins: $vgpr0_vgpr1
216 ; CHECK-LABEL: name: remove_and_131071_groupstaticsize
217 ; CHECK: liveins: $vgpr0_vgpr1
218 ; CHECK: %lds_size:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.groupstaticsize)
219 ; CHECK: $vgpr0 = COPY %lds_size(s32)
220 %ptr:_(p1) = COPY $vgpr0_vgpr1
221 %lds_size:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.groupstaticsize)
222 %mask:_(s32) = G_CONSTANT i32 131071
223 %and:_(s32) = G_AND %lds_size, %mask
229 name: no_remove_and_65536_groupstaticsize
231 tracksRegLiveness: true
234 liveins: $vgpr0_vgpr1
235 ; CHECK-LABEL: name: no_remove_and_65536_groupstaticsize
236 ; CHECK: liveins: $vgpr0_vgpr1
237 ; CHECK: %lds_size:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.groupstaticsize)
238 ; CHECK: %mask:_(s32) = G_CONSTANT i32 65536
239 ; CHECK: %and:_(s32) = G_AND %lds_size, %mask
240 ; CHECK: $vgpr0 = COPY %and(s32)
241 %ptr:_(p1) = COPY $vgpr0_vgpr1
242 %lds_size:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.groupstaticsize)
243 %mask:_(s32) = G_CONSTANT i32 65536
244 %and:_(s32) = G_AND %lds_size, %mask
250 name: no_remove_and_32767_groupstaticsize
252 tracksRegLiveness: true
255 liveins: $vgpr0_vgpr1
256 ; CHECK-LABEL: name: no_remove_and_32767_groupstaticsize
257 ; CHECK: liveins: $vgpr0_vgpr1
258 ; CHECK: %lds_size:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.groupstaticsize)
259 ; CHECK: %mask:_(s32) = G_CONSTANT i32 32767
260 ; CHECK: %and:_(s32) = G_AND %lds_size, %mask
261 ; CHECK: $vgpr0 = COPY %and(s32)
262 %ptr:_(p1) = COPY $vgpr0_vgpr1
263 %lds_size:_(s32) = G_INTRINSIC intrinsic(@llvm.amdgcn.groupstaticsize)
264 %mask:_(s32) = G_CONSTANT i32 32767
265 %and:_(s32) = G_AND %lds_size, %mask
270 # We can conclude the number of bits based only on one operand
272 name: remove_and_umin_lhs_only
274 tracksRegLiveness: true
277 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4
279 ; CHECK-LABEL: name: remove_and_umin_lhs_only
280 ; CHECK: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4
281 ; CHECK: %val:_(s32) = COPY $vgpr4
282 ; CHECK: %k255:_(s32) = G_CONSTANT i32 255
283 ; CHECK: %umin0:_(s32) = G_UMIN %val, %k255
284 ; CHECK: $vgpr0 = COPY %umin0(s32)
285 %ptr0:_(p1) = COPY $vgpr0_vgpr1
286 %ptr1:_(p1) = COPY $vgpr2_vgpr3
287 %val:_(s32) = COPY $vgpr4
288 %k255:_(s32) = G_CONSTANT i32 255
289 %umin0:_(s32) = G_UMIN %val, %k255
290 %and:_(s32) = G_AND %umin0, %k255
296 name: remove_and_umin_rhs_only
298 tracksRegLiveness: true
301 liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4
303 ; CHECK-LABEL: name: remove_and_umin_rhs_only
304 ; CHECK: liveins: $vgpr0_vgpr1, $vgpr2_vgpr3, $vgpr4
305 ; CHECK: %val:_(s32) = COPY $vgpr4
306 ; CHECK: %k255:_(s32) = G_CONSTANT i32 255
307 ; CHECK: %umin0:_(s32) = G_UMIN %k255, %val
308 ; CHECK: $vgpr0 = COPY %umin0(s32)
309 %ptr0:_(p1) = COPY $vgpr0_vgpr1
310 %ptr1:_(p1) = COPY $vgpr2_vgpr3
311 %val:_(s32) = COPY $vgpr4
312 %k255:_(s32) = G_CONSTANT i32 255
313 %umin0:_(s32) = G_UMIN %k255, %val
314 %and:_(s32) = G_AND %umin0, %k255