1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
2 ; RUN: llc -O1 -mtriple ppc32le -o - %s | FileCheck --check-prefix CHECK-LE %s
3 ; RUN: llc -O1 -mtriple ppc32 -o - %s | FileCheck --check-prefix CHECK-BE %s
5 ; A collection of regression tests to verify the load-narrowing part of
6 ; TargetLowering::SimplifySetCC (and/or other similar rewrites such as
7 ; combining AND+LOAD into ZEXTLOAD).
10 ;--------------------------------------------------------------------------
11 ; Test non byte-sized types.
13 ; As long as LLVM IR isn't defining where the padding goes we can't really
14 ; optimize these (without adding a target lowering hook that can inform
15 ; ISel about which bits are padding).
16 ; --------------------------------------------------------------------------
18 define i1 @test_129_15_0(ptr %y) {
19 ; CHECK-LE-LABEL: test_129_15_0:
21 ; CHECK-LE-NEXT: lhz 3, 0(3)
22 ; CHECK-LE-NEXT: clrlwi 3, 3, 17
23 ; CHECK-LE-NEXT: addic 4, 3, -1
24 ; CHECK-LE-NEXT: subfe 3, 4, 3
27 ; CHECK-BE-LABEL: test_129_15_0:
29 ; CHECK-BE-NEXT: lhz 3, 15(3)
30 ; CHECK-BE-NEXT: clrlwi 3, 3, 17
31 ; CHECK-BE-NEXT: addic 4, 3, -1
32 ; CHECK-BE-NEXT: subfe 3, 4, 3
34 %a = load i129, ptr %y
35 %b = and i129 %a, u0x7fff
36 %cmp = icmp ne i129 %b, 0
40 define i1 @test_126_20_4(ptr %y) {
41 ; CHECK-LE-LABEL: test_126_20_4:
43 ; CHECK-LE-NEXT: lwz 3, 0(3)
44 ; CHECK-LE-NEXT: rlwinm 3, 3, 0, 8, 27
45 ; CHECK-LE-NEXT: addic 4, 3, -1
46 ; CHECK-LE-NEXT: subfe 3, 4, 3
49 ; CHECK-BE-LABEL: test_126_20_4:
51 ; CHECK-BE-NEXT: lwz 3, 12(3)
52 ; CHECK-BE-NEXT: rlwinm 3, 3, 0, 8, 27
53 ; CHECK-BE-NEXT: addic 4, 3, -1
54 ; CHECK-BE-NEXT: subfe 3, 4, 3
56 %a = load i126, ptr %y
57 %b = and i126 %a, u0xfffff0
58 %cmp = icmp ne i126 %b, 0
62 define i1 @test_33_8_0(ptr %y) {
63 ; CHECK-LE-LABEL: test_33_8_0:
65 ; CHECK-LE-NEXT: lbz 3, 0(3)
66 ; CHECK-LE-NEXT: addic 4, 3, -1
67 ; CHECK-LE-NEXT: subfe 3, 4, 3
70 ; CHECK-BE-LABEL: test_33_8_0:
72 ; CHECK-BE-NEXT: lbz 3, 4(3)
73 ; CHECK-BE-NEXT: addic 4, 3, -1
74 ; CHECK-BE-NEXT: subfe 3, 4, 3
77 %b = and i33 %a, u0xff
78 %cmp = icmp ne i33 %b, 0
82 define i1 @test_33_1_32(ptr %y) {
83 ; CHECK-LE-LABEL: test_33_1_32:
85 ; CHECK-LE-NEXT: lbz 3, 4(3)
88 ; CHECK-BE-LABEL: test_33_1_32:
90 ; CHECK-BE-NEXT: lwz 3, 0(3)
91 ; CHECK-BE-NEXT: srwi 3, 3, 24
94 %b = and i33 %a, u0x100000000
95 %cmp = icmp ne i33 %b, 0
99 define i1 @test_33_1_31(ptr %y) {
100 ; CHECK-LE-LABEL: test_33_1_31:
102 ; CHECK-LE-NEXT: lbz 3, 3(3)
103 ; CHECK-LE-NEXT: srwi 3, 3, 7
106 ; CHECK-BE-LABEL: test_33_1_31:
108 ; CHECK-BE-NEXT: lbz 3, 1(3)
109 ; CHECK-BE-NEXT: srwi 3, 3, 7
111 %a = load i33, ptr %y
112 %b = and i33 %a, u0x80000000
113 %cmp = icmp ne i33 %b, 0
117 define i1 @test_33_1_0(ptr %y) {
118 ; CHECK-LE-LABEL: test_33_1_0:
120 ; CHECK-LE-NEXT: lbz 3, 0(3)
121 ; CHECK-LE-NEXT: clrlwi 3, 3, 31
124 ; CHECK-BE-LABEL: test_33_1_0:
126 ; CHECK-BE-NEXT: lbz 3, 4(3)
127 ; CHECK-BE-NEXT: clrlwi 3, 3, 31
129 %a = load i33, ptr %y
130 %b = and i33 %a, u0x1
131 %cmp = icmp ne i33 %b, 0
135 ;--------------------------------------------------------------------------
136 ; Test byte-sized types.
137 ;--------------------------------------------------------------------------
140 define i1 @test_128_20_4(ptr %y) {
141 ; CHECK-LE-LABEL: test_128_20_4:
143 ; CHECK-LE-NEXT: lwz 3, 0(3)
144 ; CHECK-LE-NEXT: rlwinm 3, 3, 0, 8, 27
145 ; CHECK-LE-NEXT: addic 4, 3, -1
146 ; CHECK-LE-NEXT: subfe 3, 4, 3
149 ; CHECK-BE-LABEL: test_128_20_4:
151 ; CHECK-BE-NEXT: lwz 3, 12(3)
152 ; CHECK-BE-NEXT: rlwinm 3, 3, 0, 8, 27
153 ; CHECK-BE-NEXT: addic 4, 3, -1
154 ; CHECK-BE-NEXT: subfe 3, 4, 3
156 %a = load i128, ptr %y
157 %b = and i128 %a, u0xfffff0
158 %cmp = icmp ne i128 %b, 0
162 define i1 @test_48_16_0(ptr %y) {
163 ; CHECK-LE-LABEL: test_48_16_0:
165 ; CHECK-LE-NEXT: lhz 3, 0(3)
166 ; CHECK-LE-NEXT: addic 4, 3, -1
167 ; CHECK-LE-NEXT: subfe 3, 4, 3
170 ; CHECK-BE-LABEL: test_48_16_0:
172 ; CHECK-BE-NEXT: lhz 3, 4(3)
173 ; CHECK-BE-NEXT: addic 4, 3, -1
174 ; CHECK-BE-NEXT: subfe 3, 4, 3
176 %a = load i48, ptr %y
177 %b = and i48 %a, u0xffff
178 %cmp = icmp ne i48 %b, 0
182 define i1 @test_48_16_8(ptr %y) {
183 ; CHECK-LE-LABEL: test_48_16_8:
185 ; CHECK-LE-NEXT: lhz 3, 1(3)
186 ; CHECK-LE-NEXT: addic 4, 3, -1
187 ; CHECK-LE-NEXT: subfe 3, 4, 3
190 ; CHECK-BE-LABEL: test_48_16_8:
192 ; CHECK-BE-NEXT: lhz 3, 3(3)
193 ; CHECK-BE-NEXT: addic 4, 3, -1
194 ; CHECK-BE-NEXT: subfe 3, 4, 3
196 %a = load i48, ptr %y
197 %b = and i48 %a, u0xffff00
198 %cmp = icmp ne i48 %b, 0
202 define i1 @test_48_16_16(ptr %y) {
203 ; CHECK-LE-LABEL: test_48_16_16:
205 ; CHECK-LE-NEXT: lhz 3, 2(3)
206 ; CHECK-LE-NEXT: addic 4, 3, -1
207 ; CHECK-LE-NEXT: subfe 3, 4, 3
210 ; CHECK-BE-LABEL: test_48_16_16:
212 ; CHECK-BE-NEXT: lhz 3, 2(3)
213 ; CHECK-BE-NEXT: addic 4, 3, -1
214 ; CHECK-BE-NEXT: subfe 3, 4, 3
216 %a = load i48, ptr %y
217 %b = and i48 %a, u0xffff0000
218 %cmp = icmp ne i48 %b, 0
222 define i1 @test_48_16_32(ptr %y) {
223 ; CHECK-LE-LABEL: test_48_16_32:
225 ; CHECK-LE-NEXT: lhz 3, 4(3)
226 ; CHECK-LE-NEXT: addic 4, 3, -1
227 ; CHECK-LE-NEXT: subfe 3, 4, 3
230 ; CHECK-BE-LABEL: test_48_16_32:
232 ; CHECK-BE-NEXT: lhz 3, 0(3)
233 ; CHECK-BE-NEXT: addic 4, 3, -1
234 ; CHECK-BE-NEXT: subfe 3, 4, 3
236 %a = load i48, ptr %y
237 %b = and i48 %a, u0xffff00000000
238 %cmp = icmp ne i48 %b, 0
242 define i1 @test_48_17_0(ptr %y) {
243 ; CHECK-LE-LABEL: test_48_17_0:
245 ; CHECK-LE-NEXT: lwz 3, 0(3)
246 ; CHECK-LE-NEXT: clrlwi 3, 3, 15
247 ; CHECK-LE-NEXT: addic 4, 3, -1
248 ; CHECK-LE-NEXT: subfe 3, 4, 3
251 ; CHECK-BE-LABEL: test_48_17_0:
253 ; CHECK-BE-NEXT: lwz 3, 2(3)
254 ; CHECK-BE-NEXT: clrlwi 3, 3, 15
255 ; CHECK-BE-NEXT: addic 4, 3, -1
256 ; CHECK-BE-NEXT: subfe 3, 4, 3
258 %a = load i48, ptr %y
259 %b = and i48 %a, u0x1ffff
260 %cmp = icmp ne i48 %b, 0
264 define i1 @test_40_16_0(ptr %y) {
265 ; CHECK-LE-LABEL: test_40_16_0:
267 ; CHECK-LE-NEXT: lhz 3, 0(3)
268 ; CHECK-LE-NEXT: addic 4, 3, -1
269 ; CHECK-LE-NEXT: subfe 3, 4, 3
272 ; CHECK-BE-LABEL: test_40_16_0:
274 ; CHECK-BE-NEXT: lhz 3, 3(3)
275 ; CHECK-BE-NEXT: addic 4, 3, -1
276 ; CHECK-BE-NEXT: subfe 3, 4, 3
278 %a = load i40, ptr %y
279 %b = and i40 %a, u0xffff
280 %cmp = icmp ne i40 %b, 0
284 define i1 @test_40_1_32(ptr %y) {
285 ; CHECK-LE-LABEL: test_40_1_32:
287 ; CHECK-LE-NEXT: lbz 3, 4(3)
288 ; CHECK-LE-NEXT: clrlwi 3, 3, 31
291 ; CHECK-BE-LABEL: test_40_1_32:
293 ; CHECK-BE-NEXT: lbz 3, 0(3)
294 ; CHECK-BE-NEXT: clrlwi 3, 3, 31
296 %a = load i40, ptr %y
297 %b = and i40 %a, u0x100000000
298 %cmp = icmp ne i40 %b, 0
302 define i1 @test_24_16_0(ptr %y) {
303 ; CHECK-LE-LABEL: test_24_16_0:
305 ; CHECK-LE-NEXT: lhz 3, 0(3)
306 ; CHECK-LE-NEXT: addic 4, 3, -1
307 ; CHECK-LE-NEXT: subfe 3, 4, 3
310 ; CHECK-BE-LABEL: test_24_16_0:
312 ; CHECK-BE-NEXT: lhz 3, 1(3)
313 ; CHECK-BE-NEXT: addic 4, 3, -1
314 ; CHECK-BE-NEXT: subfe 3, 4, 3
316 %a = load i24, ptr %y
317 %b = and i24 %a, u0xffff
318 %cmp = icmp ne i24 %b, 0
322 define i1 @test_24_8_8(ptr %y) {
323 ; CHECK-LE-LABEL: test_24_8_8:
325 ; CHECK-LE-NEXT: lbz 3, 1(3)
326 ; CHECK-LE-NEXT: addic 4, 3, -1
327 ; CHECK-LE-NEXT: subfe 3, 4, 3
330 ; CHECK-BE-LABEL: test_24_8_8:
332 ; CHECK-BE-NEXT: lbz 3, 1(3)
333 ; CHECK-BE-NEXT: addic 4, 3, -1
334 ; CHECK-BE-NEXT: subfe 3, 4, 3
336 %a = load i24, ptr %y
337 %b = and i24 %a, u0xff00
338 %cmp = icmp ne i24 %b, 0
342 define i1 @test_24_8_12(ptr %y) {
343 ; CHECK-LE-LABEL: test_24_8_12:
345 ; CHECK-LE-NEXT: lhz 3, 1(3)
346 ; CHECK-LE-NEXT: rlwinm 3, 3, 0, 20, 27
347 ; CHECK-LE-NEXT: addic 4, 3, -1
348 ; CHECK-LE-NEXT: subfe 3, 4, 3
351 ; CHECK-BE-LABEL: test_24_8_12:
353 ; CHECK-BE-NEXT: lhz 3, 0(3)
354 ; CHECK-BE-NEXT: rlwinm 3, 3, 0, 20, 27
355 ; CHECK-BE-NEXT: addic 4, 3, -1
356 ; CHECK-BE-NEXT: subfe 3, 4, 3
358 %a = load i24, ptr %y
359 %b = and i24 %a, u0xff000
360 %cmp = icmp ne i24 %b, 0
364 define i1 @test_24_8_16(ptr %y) {
365 ; CHECK-LE-LABEL: test_24_8_16:
367 ; CHECK-LE-NEXT: lbz 3, 2(3)
368 ; CHECK-LE-NEXT: addic 4, 3, -1
369 ; CHECK-LE-NEXT: subfe 3, 4, 3
372 ; CHECK-BE-LABEL: test_24_8_16:
374 ; CHECK-BE-NEXT: lbz 3, 0(3)
375 ; CHECK-BE-NEXT: addic 4, 3, -1
376 ; CHECK-BE-NEXT: subfe 3, 4, 3
378 %a = load i24, ptr %y
379 %b = and i24 %a, u0xff0000
380 %cmp = icmp ne i24 %b, 0