1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instcombine -S | FileCheck %s
4 ; https://bugs.llvm.org/show_bug.cgi?id=37603
5 ; https://reviews.llvm.org/D46760#1123713
9 ; Should be transformed into:
12 ; ============================================================================ ;
13 ; Basic positive tests
14 ; ============================================================================ ;
16 define i8 @positive_samevar(i8 %x, i8 %y) {
17 ; CHECK-LABEL: @positive_samevar(
18 ; CHECK-NEXT: [[TMP1:%.*]] = shl nsw i8 -1, [[Y:%.*]]
19 ; CHECK-NEXT: [[RET:%.*]] = and i8 [[TMP1]], [[X:%.*]]
20 ; CHECK-NEXT: ret i8 [[RET]]
22 %tmp0 = ashr i8 %x, %y
23 %ret = shl i8 %tmp0, %y
27 define i8 @positive_sameconst(i8 %x) {
28 ; CHECK-LABEL: @positive_sameconst(
29 ; CHECK-NEXT: [[RET:%.*]] = and i8 [[X:%.*]], -8
30 ; CHECK-NEXT: ret i8 [[RET]]
33 %ret = shl i8 %tmp0, 3
37 define i8 @positive_biggerashr(i8 %x) {
38 ; CHECK-LABEL: @positive_biggerashr(
39 ; CHECK-NEXT: [[TMP1:%.*]] = ashr i8 [[X:%.*]], 3
40 ; CHECK-NEXT: [[RET:%.*]] = and i8 [[TMP1]], -8
41 ; CHECK-NEXT: ret i8 [[RET]]
44 %ret = shl i8 %tmp0, 3
48 define i8 @positive_biggershl(i8 %x) {
49 ; CHECK-LABEL: @positive_biggershl(
50 ; CHECK-NEXT: [[TMP1:%.*]] = shl i8 [[X:%.*]], 3
51 ; CHECK-NEXT: [[RET:%.*]] = and i8 [[TMP1]], -64
52 ; CHECK-NEXT: ret i8 [[RET]]
55 %ret = shl i8 %tmp0, 6
59 ; ============================================================================ ;
61 ; ============================================================================ ;
63 define i8 @positive_samevar_shlnuw(i8 %x, i8 %y) {
64 ; CHECK-LABEL: @positive_samevar_shlnuw(
65 ; CHECK-NEXT: [[TMP1:%.*]] = shl nsw i8 -1, [[Y:%.*]]
66 ; CHECK-NEXT: [[RET:%.*]] = and i8 [[TMP1]], [[X:%.*]]
67 ; CHECK-NEXT: ret i8 [[RET]]
69 %tmp0 = ashr i8 %x, %y
70 %ret = shl nuw i8 %tmp0, %y
74 define i8 @positive_sameconst_shlnuw(i8 %x) {
75 ; CHECK-LABEL: @positive_sameconst_shlnuw(
76 ; CHECK-NEXT: [[RET:%.*]] = and i8 [[X:%.*]], -8
77 ; CHECK-NEXT: ret i8 [[RET]]
80 %ret = shl nuw i8 %tmp0, 3
84 define i8 @positive_biggerashr_shlnuw(i8 %x) {
85 ; CHECK-LABEL: @positive_biggerashr_shlnuw(
86 ; CHECK-NEXT: [[TMP1:%.*]] = ashr i8 [[X:%.*]], 3
87 ; CHECK-NEXT: [[RET:%.*]] = and i8 [[TMP1]], -8
88 ; CHECK-NEXT: ret i8 [[RET]]
91 %ret = shl nuw i8 %tmp0, 3
95 define i8 @positive_biggershl_shlnuw(i8 %x) {
96 ; CHECK-LABEL: @positive_biggershl_shlnuw(
97 ; CHECK-NEXT: [[TMP1:%.*]] = shl nuw i8 [[X:%.*]], 3
98 ; CHECK-NEXT: [[RET:%.*]] = and i8 [[TMP1]], -64
99 ; CHECK-NEXT: ret i8 [[RET]]
101 %tmp0 = ashr i8 %x, 3
102 %ret = shl nuw i8 %tmp0, 6
106 ; ============================================================================ ;
108 ; ============================================================================ ;
110 define i8 @positive_samevar_shlnsw(i8 %x, i8 %y) {
111 ; CHECK-LABEL: @positive_samevar_shlnsw(
112 ; CHECK-NEXT: [[TMP1:%.*]] = shl nsw i8 -1, [[Y:%.*]]
113 ; CHECK-NEXT: [[RET:%.*]] = and i8 [[TMP1]], [[X:%.*]]
114 ; CHECK-NEXT: ret i8 [[RET]]
116 %tmp0 = ashr i8 %x, %y
117 %ret = shl nsw i8 %tmp0, %y
121 define i8 @positive_sameconst_shlnsw(i8 %x) {
122 ; CHECK-LABEL: @positive_sameconst_shlnsw(
123 ; CHECK-NEXT: [[RET:%.*]] = and i8 [[X:%.*]], -8
124 ; CHECK-NEXT: ret i8 [[RET]]
126 %tmp0 = ashr i8 %x, 3
127 %ret = shl nsw i8 %tmp0, 3
131 define i8 @positive_biggerashr_shlnsw(i8 %x) {
132 ; CHECK-LABEL: @positive_biggerashr_shlnsw(
133 ; CHECK-NEXT: [[TMP1:%.*]] = ashr i8 [[X:%.*]], 3
134 ; CHECK-NEXT: [[RET:%.*]] = and i8 [[TMP1]], -8
135 ; CHECK-NEXT: ret i8 [[RET]]
137 %tmp0 = ashr i8 %x, 6
138 %ret = shl nsw i8 %tmp0, 3
142 define i8 @positive_biggershl_shlnsw(i8 %x) {
143 ; CHECK-LABEL: @positive_biggershl_shlnsw(
144 ; CHECK-NEXT: [[TMP1:%.*]] = shl nsw i8 [[X:%.*]], 3
145 ; CHECK-NEXT: [[RET:%.*]] = and i8 [[TMP1]], -64
146 ; CHECK-NEXT: ret i8 [[RET]]
148 %tmp0 = ashr i8 %x, 3
149 %ret = shl nsw i8 %tmp0, 6
153 ; ============================================================================ ;
155 ; ============================================================================ ;
157 define i8 @positive_samevar_shlnuwnsw(i8 %x, i8 %y) {
158 ; CHECK-LABEL: @positive_samevar_shlnuwnsw(
159 ; CHECK-NEXT: [[TMP1:%.*]] = shl nsw i8 -1, [[Y:%.*]]
160 ; CHECK-NEXT: [[RET:%.*]] = and i8 [[TMP1]], [[X:%.*]]
161 ; CHECK-NEXT: ret i8 [[RET]]
163 %tmp0 = ashr i8 %x, %y
164 %ret = shl nuw nsw i8 %tmp0, %y
168 define i8 @positive_sameconst_shlnuwnsw(i8 %x) {
169 ; CHECK-LABEL: @positive_sameconst_shlnuwnsw(
170 ; CHECK-NEXT: [[RET:%.*]] = and i8 [[X:%.*]], -8
171 ; CHECK-NEXT: ret i8 [[RET]]
173 %tmp0 = ashr i8 %x, 3
174 %ret = shl nuw nsw i8 %tmp0, 3
178 define i8 @positive_biggerashr_shlnuwnsw(i8 %x) {
179 ; CHECK-LABEL: @positive_biggerashr_shlnuwnsw(
180 ; CHECK-NEXT: [[TMP1:%.*]] = ashr i8 [[X:%.*]], 3
181 ; CHECK-NEXT: [[RET:%.*]] = and i8 [[TMP1]], -8
182 ; CHECK-NEXT: ret i8 [[RET]]
184 %tmp0 = ashr i8 %x, 6
185 %ret = shl nuw nsw i8 %tmp0, 3
189 define i8 @positive_biggershl_shlnuwnsw(i8 %x) {
190 ; CHECK-LABEL: @positive_biggershl_shlnuwnsw(
191 ; CHECK-NEXT: [[TMP1:%.*]] = shl nuw nsw i8 [[X:%.*]], 3
192 ; CHECK-NEXT: [[RET:%.*]] = and i8 [[TMP1]], 64
193 ; CHECK-NEXT: ret i8 [[RET]]
195 %tmp0 = ashr i8 %x, 3
196 %ret = shl nuw nsw i8 %tmp0, 6
200 ; ============================================================================ ;
202 ; ============================================================================ ;
204 define i8 @positive_samevar_ashrexact(i8 %x, i8 %y) {
205 ; CHECK-LABEL: @positive_samevar_ashrexact(
206 ; CHECK-NEXT: ret i8 [[X:%.*]]
208 %tmp0 = ashr exact i8 %x, %y
209 %ret = shl i8 %tmp0, %y
213 define i8 @positive_sameconst_ashrexact(i8 %x) {
214 ; CHECK-LABEL: @positive_sameconst_ashrexact(
215 ; CHECK-NEXT: ret i8 [[X:%.*]]
217 %tmp0 = ashr exact i8 %x, 3
218 %ret = shl i8 %tmp0, 3
222 define i8 @positive_biggerashr_ashrexact(i8 %x) {
223 ; CHECK-LABEL: @positive_biggerashr_ashrexact(
224 ; CHECK-NEXT: [[RET:%.*]] = ashr exact i8 [[X:%.*]], 3
225 ; CHECK-NEXT: ret i8 [[RET]]
227 %tmp0 = ashr exact i8 %x, 6
228 %ret = shl i8 %tmp0, 3
232 define i8 @positive_biggershl_ashrexact(i8 %x) {
233 ; CHECK-LABEL: @positive_biggershl_ashrexact(
234 ; CHECK-NEXT: [[RET:%.*]] = shl i8 [[X:%.*]], 3
235 ; CHECK-NEXT: ret i8 [[RET]]
237 %tmp0 = ashr exact i8 %x, 3
238 %ret = shl i8 %tmp0, 6
242 ; ============================================================================ ;
243 ; ashr exact, shl nsw
244 ; ============================================================================ ;
246 define i8 @positive_samevar_shlnsw_ashrexact(i8 %x, i8 %y) {
247 ; CHECK-LABEL: @positive_samevar_shlnsw_ashrexact(
248 ; CHECK-NEXT: ret i8 [[X:%.*]]
250 %tmp0 = ashr exact i8 %x, %y
251 %ret = shl nsw i8 %tmp0, %y
255 define i8 @positive_sameconst_shlnsw_ashrexact(i8 %x) {
256 ; CHECK-LABEL: @positive_sameconst_shlnsw_ashrexact(
257 ; CHECK-NEXT: ret i8 [[X:%.*]]
259 %tmp0 = ashr exact i8 %x, 3
260 %ret = shl nsw i8 %tmp0, 3
264 define i8 @positive_biggerashr_shlnsw_ashrexact(i8 %x) {
265 ; CHECK-LABEL: @positive_biggerashr_shlnsw_ashrexact(
266 ; CHECK-NEXT: [[RET:%.*]] = ashr exact i8 [[X:%.*]], 3
267 ; CHECK-NEXT: ret i8 [[RET]]
269 %tmp0 = ashr exact i8 %x, 6
270 %ret = shl nsw i8 %tmp0, 3
274 define i8 @positive_biggershl_shlnsw_ashrexact(i8 %x) {
275 ; CHECK-LABEL: @positive_biggershl_shlnsw_ashrexact(
276 ; CHECK-NEXT: [[RET:%.*]] = shl nsw i8 [[X:%.*]], 3
277 ; CHECK-NEXT: ret i8 [[RET]]
279 %tmp0 = ashr exact i8 %x, 3
280 %ret = shl nsw i8 %tmp0, 6
284 ; ============================================================================ ;
285 ; ashr exact, shl nuw
286 ; ============================================================================ ;
288 define i8 @positive_samevar_shlnuw_ashrexact(i8 %x, i8 %y) {
289 ; CHECK-LABEL: @positive_samevar_shlnuw_ashrexact(
290 ; CHECK-NEXT: ret i8 [[X:%.*]]
292 %tmp0 = ashr exact i8 %x, %y
293 %ret = shl nuw i8 %tmp0, %y
297 define i8 @positive_sameconst_shlnuw_ashrexact(i8 %x) {
298 ; CHECK-LABEL: @positive_sameconst_shlnuw_ashrexact(
299 ; CHECK-NEXT: ret i8 [[X:%.*]]
301 %tmp0 = ashr exact i8 %x, 3
302 %ret = shl nuw i8 %tmp0, 3
306 define i8 @positive_biggerashr_shlnuw_ashrexact(i8 %x) {
307 ; CHECK-LABEL: @positive_biggerashr_shlnuw_ashrexact(
308 ; CHECK-NEXT: [[RET:%.*]] = ashr exact i8 [[X:%.*]], 3
309 ; CHECK-NEXT: ret i8 [[RET]]
311 %tmp0 = ashr exact i8 %x, 6
312 %ret = shl nuw i8 %tmp0, 3
316 define i8 @positive_biggershl_shlnuw_ashrexact(i8 %x) {
317 ; CHECK-LABEL: @positive_biggershl_shlnuw_ashrexact(
318 ; CHECK-NEXT: [[RET:%.*]] = shl nuw i8 [[X:%.*]], 3
319 ; CHECK-NEXT: ret i8 [[RET]]
321 %tmp0 = ashr exact i8 %x, 3
322 %ret = shl nuw i8 %tmp0, 6
326 ; ============================================================================ ;
327 ; ashr exact, shl nuw nsw
328 ; ============================================================================ ;
330 define i8 @positive_samevar_shlnuwnsw_ashrexact(i8 %x, i8 %y) {
331 ; CHECK-LABEL: @positive_samevar_shlnuwnsw_ashrexact(
332 ; CHECK-NEXT: ret i8 [[X:%.*]]
334 %tmp0 = ashr exact i8 %x, %y
335 %ret = shl nuw nsw i8 %tmp0, %y
339 define i8 @positive_sameconst_shlnuwnsw_ashrexact(i8 %x) {
340 ; CHECK-LABEL: @positive_sameconst_shlnuwnsw_ashrexact(
341 ; CHECK-NEXT: ret i8 [[X:%.*]]
343 %tmp0 = ashr exact i8 %x, 3
344 %ret = shl nuw nsw i8 %tmp0, 3
348 define i8 @positive_biggerashr_shlnuwnsw_ashrexact(i8 %x) {
349 ; CHECK-LABEL: @positive_biggerashr_shlnuwnsw_ashrexact(
350 ; CHECK-NEXT: [[RET:%.*]] = ashr exact i8 [[X:%.*]], 3
351 ; CHECK-NEXT: ret i8 [[RET]]
353 %tmp0 = ashr exact i8 %x, 6
354 %ret = shl nuw nsw i8 %tmp0, 3
358 define i8 @positive_biggershl_shlnuwnsw_ashrexact(i8 %x) {
359 ; CHECK-LABEL: @positive_biggershl_shlnuwnsw_ashrexact(
360 ; CHECK-NEXT: [[RET:%.*]] = shl nuw nsw i8 [[X:%.*]], 3
361 ; CHECK-NEXT: ret i8 [[RET]]
363 %tmp0 = ashr exact i8 %x, 3
364 %ret = shl nuw nsw i8 %tmp0, 6
368 ; ============================================================================ ;
370 ; ============================================================================ ;
372 define <2 x i8> @positive_samevar_vec(<2 x i8> %x, <2 x i8> %y) {
373 ; CHECK-LABEL: @positive_samevar_vec(
374 ; CHECK-NEXT: [[TMP1:%.*]] = shl nsw <2 x i8> <i8 -1, i8 -1>, [[Y:%.*]]
375 ; CHECK-NEXT: [[RET:%.*]] = and <2 x i8> [[TMP1]], [[X:%.*]]
376 ; CHECK-NEXT: ret <2 x i8> [[RET]]
378 %tmp0 = ashr <2 x i8> %x, %y
379 %ret = shl <2 x i8> %tmp0, %y
383 ; ============================================================================ ;
385 ; ============================================================================ ;
387 define <2 x i8> @positive_sameconst_vec(<2 x i8> %x) {
388 ; CHECK-LABEL: @positive_sameconst_vec(
389 ; CHECK-NEXT: [[RET:%.*]] = and <2 x i8> [[X:%.*]], <i8 -8, i8 -8>
390 ; CHECK-NEXT: ret <2 x i8> [[RET]]
392 %tmp0 = ashr <2 x i8> %x, <i8 3, i8 3>
393 %ret = shl <2 x i8> %tmp0, <i8 3, i8 3>
397 define <3 x i8> @positive_sameconst_vec_undef0(<3 x i8> %x) {
398 ; CHECK-LABEL: @positive_sameconst_vec_undef0(
399 ; CHECK-NEXT: [[TMP0:%.*]] = ashr <3 x i8> [[X:%.*]], <i8 3, i8 undef, i8 3>
400 ; CHECK-NEXT: [[RET:%.*]] = shl <3 x i8> [[TMP0]], <i8 3, i8 3, i8 3>
401 ; CHECK-NEXT: ret <3 x i8> [[RET]]
403 %tmp0 = ashr <3 x i8> %x, <i8 3, i8 undef, i8 3>
404 %ret = shl <3 x i8> %tmp0, <i8 3, i8 3, i8 3>
408 define <3 x i8> @positive_sameconst_vec_undef1(<3 x i8> %x) {
409 ; CHECK-LABEL: @positive_sameconst_vec_undef1(
410 ; CHECK-NEXT: [[TMP0:%.*]] = ashr <3 x i8> [[X:%.*]], <i8 3, i8 3, i8 3>
411 ; CHECK-NEXT: [[RET:%.*]] = shl <3 x i8> [[TMP0]], <i8 3, i8 undef, i8 3>
412 ; CHECK-NEXT: ret <3 x i8> [[RET]]
414 %tmp0 = ashr <3 x i8> %x, <i8 3, i8 3, i8 3>
415 %ret = shl <3 x i8> %tmp0, <i8 3, i8 undef, i8 3>
419 define <3 x i8> @positive_sameconst_vec_undef2(<3 x i8> %x) {
420 ; CHECK-LABEL: @positive_sameconst_vec_undef2(
421 ; CHECK-NEXT: [[RET:%.*]] = and <3 x i8> [[X:%.*]], <i8 -8, i8 poison, i8 -8>
422 ; CHECK-NEXT: ret <3 x i8> [[RET]]
424 %tmp0 = ashr <3 x i8> %x, <i8 3, i8 undef, i8 3>
425 %ret = shl <3 x i8> %tmp0, <i8 3, i8 undef, i8 3>
429 define <2 x i8> @positive_biggerashr_vec(<2 x i8> %x) {
430 ; CHECK-LABEL: @positive_biggerashr_vec(
431 ; CHECK-NEXT: [[TMP1:%.*]] = ashr <2 x i8> [[X:%.*]], <i8 3, i8 3>
432 ; CHECK-NEXT: [[RET:%.*]] = and <2 x i8> [[TMP1]], <i8 -8, i8 -8>
433 ; CHECK-NEXT: ret <2 x i8> [[RET]]
435 %tmp0 = ashr <2 x i8> %x, <i8 6, i8 6>
436 %ret = shl <2 x i8> %tmp0, <i8 3, i8 3>
440 define <3 x i8> @positive_biggerashr_vec_undef0(<3 x i8> %x) {
441 ; CHECK-LABEL: @positive_biggerashr_vec_undef0(
442 ; CHECK-NEXT: [[TMP0:%.*]] = ashr <3 x i8> [[X:%.*]], <i8 6, i8 undef, i8 6>
443 ; CHECK-NEXT: [[RET:%.*]] = shl <3 x i8> [[TMP0]], <i8 3, i8 3, i8 3>
444 ; CHECK-NEXT: ret <3 x i8> [[RET]]
446 %tmp0 = ashr <3 x i8> %x, <i8 6, i8 undef, i8 6>
447 %ret = shl <3 x i8> %tmp0, <i8 3, i8 3, i8 3>
451 define <3 x i8> @positive_biggerashr_vec_undef1(<3 x i8> %x) {
452 ; CHECK-LABEL: @positive_biggerashr_vec_undef1(
453 ; CHECK-NEXT: [[TMP0:%.*]] = ashr <3 x i8> [[X:%.*]], <i8 6, i8 6, i8 6>
454 ; CHECK-NEXT: [[RET:%.*]] = shl <3 x i8> [[TMP0]], <i8 3, i8 undef, i8 3>
455 ; CHECK-NEXT: ret <3 x i8> [[RET]]
457 %tmp0 = ashr <3 x i8> %x, <i8 6, i8 6, i8 6>
458 %ret = shl <3 x i8> %tmp0, <i8 3, i8 undef, i8 3>
462 define <3 x i8> @positive_biggerashr_vec_undef2(<3 x i8> %x) {
463 ; CHECK-LABEL: @positive_biggerashr_vec_undef2(
464 ; CHECK-NEXT: [[TMP0:%.*]] = ashr <3 x i8> [[X:%.*]], <i8 6, i8 undef, i8 6>
465 ; CHECK-NEXT: [[RET:%.*]] = shl <3 x i8> [[TMP0]], <i8 3, i8 undef, i8 3>
466 ; CHECK-NEXT: ret <3 x i8> [[RET]]
468 %tmp0 = ashr <3 x i8> %x, <i8 6, i8 undef, i8 6>
469 %ret = shl <3 x i8> %tmp0, <i8 3, i8 undef, i8 3>
473 define <2 x i8> @positive_biggershl_vec(<2 x i8> %x) {
474 ; CHECK-LABEL: @positive_biggershl_vec(
475 ; CHECK-NEXT: [[TMP1:%.*]] = shl <2 x i8> [[X:%.*]], <i8 3, i8 3>
476 ; CHECK-NEXT: [[RET:%.*]] = and <2 x i8> [[TMP1]], <i8 -64, i8 -64>
477 ; CHECK-NEXT: ret <2 x i8> [[RET]]
479 %tmp0 = ashr <2 x i8> %x, <i8 3, i8 3>
480 %ret = shl <2 x i8> %tmp0, <i8 6, i8 6>
484 define <3 x i8> @positive_biggershl_vec_undef0(<3 x i8> %x) {
485 ; CHECK-LABEL: @positive_biggershl_vec_undef0(
486 ; CHECK-NEXT: [[TMP0:%.*]] = ashr <3 x i8> [[X:%.*]], <i8 3, i8 undef, i8 3>
487 ; CHECK-NEXT: [[RET:%.*]] = shl <3 x i8> [[TMP0]], <i8 6, i8 6, i8 6>
488 ; CHECK-NEXT: ret <3 x i8> [[RET]]
490 %tmp0 = ashr <3 x i8> %x, <i8 3, i8 undef, i8 3>
491 %ret = shl <3 x i8> %tmp0, <i8 6, i8 6, i8 6>
495 define <3 x i8> @positive_biggershl_vec_undef1(<3 x i8> %x) {
496 ; CHECK-LABEL: @positive_biggershl_vec_undef1(
497 ; CHECK-NEXT: [[TMP0:%.*]] = ashr <3 x i8> [[X:%.*]], <i8 3, i8 3, i8 3>
498 ; CHECK-NEXT: [[RET:%.*]] = shl <3 x i8> [[TMP0]], <i8 6, i8 undef, i8 6>
499 ; CHECK-NEXT: ret <3 x i8> [[RET]]
501 %tmp0 = ashr <3 x i8> %x, <i8 3, i8 3, i8 3>
502 %ret = shl <3 x i8> %tmp0, <i8 6, i8 undef, i8 6>
506 define <3 x i8> @positive_biggershl_vec_undef2(<3 x i8> %x) {
507 ; CHECK-LABEL: @positive_biggershl_vec_undef2(
508 ; CHECK-NEXT: [[TMP0:%.*]] = ashr <3 x i8> [[X:%.*]], <i8 3, i8 undef, i8 3>
509 ; CHECK-NEXT: [[RET:%.*]] = shl <3 x i8> [[TMP0]], <i8 6, i8 undef, i8 6>
510 ; CHECK-NEXT: ret <3 x i8> [[RET]]
512 %tmp0 = ashr <3 x i8> %x, <i8 3, i8 undef, i8 3>
513 %ret = shl <3 x i8> %tmp0, <i8 6, i8 undef, i8 6>
517 ; ============================================================================ ;
518 ; Positive multi-use tests with constant
519 ; ============================================================================ ;
521 define i8 @positive_sameconst_multiuse(i8 %x) {
522 ; CHECK-LABEL: @positive_sameconst_multiuse(
523 ; CHECK-NEXT: [[TMP0:%.*]] = ashr i8 [[X:%.*]], 3
524 ; CHECK-NEXT: call void @use32(i8 [[TMP0]])
525 ; CHECK-NEXT: [[RET:%.*]] = and i8 [[X]], -8
526 ; CHECK-NEXT: ret i8 [[RET]]
528 %tmp0 = ashr i8 %x, 3
529 call void @use32(i8 %tmp0)
530 %ret = shl i8 %tmp0, 3
534 define i8 @positive_biggerashr_multiuse(i8 %x) {
535 ; CHECK-LABEL: @positive_biggerashr_multiuse(
536 ; CHECK-NEXT: [[TMP0:%.*]] = ashr i8 [[X:%.*]], 6
537 ; CHECK-NEXT: call void @use32(i8 [[TMP0]])
538 ; CHECK-NEXT: [[RET:%.*]] = shl nsw i8 [[TMP0]], 3
539 ; CHECK-NEXT: ret i8 [[RET]]
541 %tmp0 = ashr i8 %x, 6
542 call void @use32(i8 %tmp0)
543 %ret = shl i8 %tmp0, 3
547 define i8 @positive_biggershl_multiuse(i8 %x) {
548 ; CHECK-LABEL: @positive_biggershl_multiuse(
549 ; CHECK-NEXT: [[TMP0:%.*]] = ashr i8 [[X:%.*]], 3
550 ; CHECK-NEXT: call void @use32(i8 [[TMP0]])
551 ; CHECK-NEXT: [[RET:%.*]] = shl i8 [[TMP0]], 6
552 ; CHECK-NEXT: ret i8 [[RET]]
554 %tmp0 = ashr i8 %x, 3
555 call void @use32(i8 %tmp0)
556 %ret = shl i8 %tmp0, 6
560 ; ============================================================================ ;
561 ; Constant Non-Splat Vectors
562 ; ============================================================================ ;
564 define <2 x i8> @positive_biggerashr_vec_nonsplat(<2 x i8> %x) {
565 ; CHECK-LABEL: @positive_biggerashr_vec_nonsplat(
566 ; CHECK-NEXT: [[TMP0:%.*]] = ashr <2 x i8> [[X:%.*]], <i8 3, i8 3>
567 ; CHECK-NEXT: [[RET:%.*]] = shl <2 x i8> [[TMP0]], <i8 3, i8 6>
568 ; CHECK-NEXT: ret <2 x i8> [[RET]]
570 %tmp0 = ashr <2 x i8> %x, <i8 3, i8 3>
571 %ret = shl <2 x i8> %tmp0, <i8 3, i8 6>
575 define <2 x i8> @positive_biggerLashr_vec_nonsplat(<2 x i8> %x) {
576 ; CHECK-LABEL: @positive_biggerLashr_vec_nonsplat(
577 ; CHECK-NEXT: [[TMP0:%.*]] = ashr <2 x i8> [[X:%.*]], <i8 3, i8 6>
578 ; CHECK-NEXT: [[RET:%.*]] = shl <2 x i8> [[TMP0]], <i8 3, i8 3>
579 ; CHECK-NEXT: ret <2 x i8> [[RET]]
581 %tmp0 = ashr <2 x i8> %x, <i8 3, i8 6>
582 %ret = shl <2 x i8> %tmp0, <i8 3, i8 3>
586 ; ============================================================================ ;
587 ; Negative tests. Should not be folded.
588 ; ============================================================================ ;
590 define i8 @negative_twovars(i8 %x, i8 %y, i8 %z) {
591 ; CHECK-LABEL: @negative_twovars(
592 ; CHECK-NEXT: [[TMP0:%.*]] = ashr i8 [[X:%.*]], [[Y:%.*]]
593 ; CHECK-NEXT: [[RET:%.*]] = shl i8 [[TMP0]], [[Z:%.*]]
594 ; CHECK-NEXT: ret i8 [[RET]]
596 %tmp0 = ashr i8 %x, %y
597 %ret = shl i8 %tmp0, %z ; $z, not %y
601 declare void @use32(i8)
604 define i8 @negative_oneuse(i8 %x, i8 %y) {
605 ; CHECK-LABEL: @negative_oneuse(
606 ; CHECK-NEXT: [[TMP0:%.*]] = ashr i8 [[X:%.*]], [[Y:%.*]]
607 ; CHECK-NEXT: call void @use32(i8 [[TMP0]])
608 ; CHECK-NEXT: [[RET:%.*]] = shl i8 [[TMP0]], [[Y]]
609 ; CHECK-NEXT: ret i8 [[RET]]
611 %tmp0 = ashr i8 %x, %y
612 call void @use32(i8 %tmp0)
613 %ret = shl i8 %tmp0, %y