[InstCombine] Signed saturation patterns
[llvm-core.git] / test / Transforms / InstCombine / apint-shift.ll
blob495d9d6d8b25c991b7ffce0bddb2e909d9b29edf
1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
4 define i55 @test6(i55 %A) {
5 ; CHECK-LABEL: @test6(
6 ; CHECK-NEXT:    [[C:%.*]] = mul i55 [[A:%.*]], 6
7 ; CHECK-NEXT:    ret i55 [[C]]
9   %B = shl i55 %A, 1
10   %C = mul i55 %B, 3
11   ret i55 %C
14 ; (X * C2) << C1 --> X * (C2 << C1)
16 define i55 @test6a(i55 %A) {
17 ; CHECK-LABEL: @test6a(
18 ; CHECK-NEXT:    [[C:%.*]] = mul i55 [[A:%.*]], 6
19 ; CHECK-NEXT:    ret i55 [[C]]
21   %B = mul i55 %A, 3
22   %C = shl i55 %B, 1
23   ret i55 %C
26 ; (X * C2) << C1 --> X * (C2 << C1)
28 define <2 x i55> @test6a_vec(<2 x i55> %A) {
29 ; CHECK-LABEL: @test6a_vec(
30 ; CHECK-NEXT:    [[C:%.*]] = mul <2 x i55> [[A:%.*]], <i55 6, i55 48>
31 ; CHECK-NEXT:    ret <2 x i55> [[C]]
33   %B = mul <2 x i55> %A, <i55 3, i55 12>
34   %C = shl <2 x i55> %B, <i55 1, i55 2>
35   ret <2 x i55> %C
38 define i29 @test7(i8 %X) {
39 ; CHECK-LABEL: @test7(
40 ; CHECK-NEXT:    ret i29 -1
42   %A = zext i8 %X to i29
43   %B = ashr i29 -1, %A
44   ret i29 %B
47 define i7 @test8(i7 %A) {
48 ; CHECK-LABEL: @test8(
49 ; CHECK-NEXT:    ret i7 0
51   %B = shl i7 %A, 4
52   %C = shl i7 %B, 3
53   ret i7 %C
56 define i17 @test9(i17 %A) {
57 ; CHECK-LABEL: @test9(
58 ; CHECK-NEXT:    [[B:%.*]] = and i17 [[A:%.*]], 1
59 ; CHECK-NEXT:    ret i17 [[B]]
61   %B = shl i17 %A, 16
62   %C = lshr i17 %B, 16
63   ret i17 %C
66 ; shl (lshr X, C), C --> and X, C'
68 define i19 @test10(i19 %X) {
69 ; CHECK-LABEL: @test10(
70 ; CHECK-NEXT:    [[SH1:%.*]] = and i19 [[X:%.*]], -262144
71 ; CHECK-NEXT:    ret i19 [[SH1]]
73   %sh1 = lshr i19 %X, 18
74   %sh2 = shl i19 %sh1, 18
75   ret i19 %sh2
78 ; Two right shifts in the same direction:
79 ; lshr (lshr X, C1), C2 --> lshr X, C1 + C2
81 define <2 x i19> @lshr_lshr_splat_vec(<2 x i19> %X) {
82 ; CHECK-LABEL: @lshr_lshr_splat_vec(
83 ; CHECK-NEXT:    [[SH1:%.*]] = lshr <2 x i19> [[X:%.*]], <i19 5, i19 5>
84 ; CHECK-NEXT:    ret <2 x i19> [[SH1]]
86   %sh1 = lshr <2 x i19> %X, <i19 3, i19 3>
87   %sh2 = lshr <2 x i19> %sh1, <i19 2, i19 2>
88   ret <2 x i19> %sh2
91 define i9 @multiuse_lshr_lshr(i9 %x) {
92 ; CHECK-LABEL: @multiuse_lshr_lshr(
93 ; CHECK-NEXT:    [[SH1:%.*]] = lshr i9 [[X:%.*]], 2
94 ; CHECK-NEXT:    [[SH2:%.*]] = lshr i9 [[X]], 5
95 ; CHECK-NEXT:    [[MUL:%.*]] = mul i9 [[SH1]], [[SH2]]
96 ; CHECK-NEXT:    ret i9 [[MUL]]
98   %sh1 = lshr i9 %x, 2
99   %sh2 = lshr i9 %sh1, 3
100   %mul = mul i9 %sh1, %sh2
101   ret i9 %mul
104 define <2 x i9> @multiuse_lshr_lshr_splat(<2 x i9> %x) {
105 ; CHECK-LABEL: @multiuse_lshr_lshr_splat(
106 ; CHECK-NEXT:    [[SH1:%.*]] = lshr <2 x i9> [[X:%.*]], <i9 2, i9 2>
107 ; CHECK-NEXT:    [[SH2:%.*]] = lshr <2 x i9> [[X]], <i9 5, i9 5>
108 ; CHECK-NEXT:    [[MUL:%.*]] = mul <2 x i9> [[SH1]], [[SH2]]
109 ; CHECK-NEXT:    ret <2 x i9> [[MUL]]
111   %sh1 = lshr <2 x i9> %x, <i9 2, i9 2>
112   %sh2 = lshr <2 x i9> %sh1, <i9 3, i9 3>
113   %mul = mul <2 x i9> %sh1, %sh2
114   ret <2 x i9> %mul
117 ; Two left shifts in the same direction:
118 ; shl (shl X, C1), C2 -->  shl X, C1 + C2
120 define <2 x i19> @shl_shl_splat_vec(<2 x i19> %X) {
121 ; CHECK-LABEL: @shl_shl_splat_vec(
122 ; CHECK-NEXT:    [[SH1:%.*]] = shl <2 x i19> [[X:%.*]], <i19 5, i19 5>
123 ; CHECK-NEXT:    ret <2 x i19> [[SH1]]
125   %sh1 = shl <2 x i19> %X, <i19 3, i19 3>
126   %sh2 = shl <2 x i19> %sh1, <i19 2, i19 2>
127   ret <2 x i19> %sh2
130 define i42 @multiuse_shl_shl(i42 %x) {
131 ; CHECK-LABEL: @multiuse_shl_shl(
132 ; CHECK-NEXT:    [[SH1:%.*]] = shl i42 [[X:%.*]], 8
133 ; CHECK-NEXT:    [[SH2:%.*]] = shl i42 [[X]], 17
134 ; CHECK-NEXT:    [[MUL:%.*]] = mul i42 [[SH1]], [[SH2]]
135 ; CHECK-NEXT:    ret i42 [[MUL]]
137   %sh1 = shl i42 %x, 8
138   %sh2 = shl i42 %sh1, 9
139   %mul = mul i42 %sh1, %sh2
140   ret i42 %mul
143 define <2 x i42> @multiuse_shl_shl_splat(<2 x i42> %x) {
144 ; CHECK-LABEL: @multiuse_shl_shl_splat(
145 ; CHECK-NEXT:    [[SH1:%.*]] = shl <2 x i42> [[X:%.*]], <i42 8, i42 8>
146 ; CHECK-NEXT:    [[SH2:%.*]] = shl <2 x i42> [[X]], <i42 17, i42 17>
147 ; CHECK-NEXT:    [[MUL:%.*]] = mul <2 x i42> [[SH1]], [[SH2]]
148 ; CHECK-NEXT:    ret <2 x i42> [[MUL]]
150   %sh1 = shl <2 x i42> %x, <i42 8, i42 8>
151   %sh2 = shl <2 x i42> %sh1, <i42 9, i42 9>
152   %mul = mul <2 x i42> %sh1, %sh2
153   ret <2 x i42> %mul
156 ; Equal shift amounts in opposite directions become bitwise 'and':
157 ; lshr (shl X, C), C --> and X, C'
159 define <2 x i19> @eq_shl_lshr_splat_vec(<2 x i19> %X) {
160 ; CHECK-LABEL: @eq_shl_lshr_splat_vec(
161 ; CHECK-NEXT:    [[SH1:%.*]] = and <2 x i19> [[X:%.*]], <i19 65535, i19 65535>
162 ; CHECK-NEXT:    ret <2 x i19> [[SH1]]
164   %sh1 = shl <2 x i19> %X, <i19 3, i19 3>
165   %sh2 = lshr <2 x i19> %sh1, <i19 3, i19 3>
166   ret <2 x i19> %sh2
169 ; Equal shift amounts in opposite directions become bitwise 'and':
170 ; shl (lshr X, C), C --> and X, C'
172 define <2 x i19> @eq_lshr_shl_splat_vec(<2 x i19> %X) {
173 ; CHECK-LABEL: @eq_lshr_shl_splat_vec(
174 ; CHECK-NEXT:    [[SH1:%.*]] = and <2 x i19> [[X:%.*]], <i19 -8, i19 -8>
175 ; CHECK-NEXT:    ret <2 x i19> [[SH1]]
177   %sh1 = lshr <2 x i19> %X, <i19 3, i19 3>
178   %sh2 = shl <2 x i19> %sh1, <i19 3, i19 3>
179   ret <2 x i19> %sh2
182 ; In general, we would need an 'and' for this transform, but the masked-off bits are known zero.
183 ; shl (lshr X, C1), C2 --> lshr X, C1 - C2
185 define <2 x i7> @lshr_shl_splat_vec(<2 x i7> %X) {
186 ; CHECK-LABEL: @lshr_shl_splat_vec(
187 ; CHECK-NEXT:    [[MUL:%.*]] = mul <2 x i7> [[X:%.*]], <i7 -8, i7 -8>
188 ; CHECK-NEXT:    [[SH1:%.*]] = lshr exact <2 x i7> [[MUL]], <i7 1, i7 1>
189 ; CHECK-NEXT:    ret <2 x i7> [[SH1]]
191   %mul = mul <2 x i7> %X, <i7 -8, i7 -8>
192   %sh1 = lshr exact <2 x i7> %mul, <i7 3, i7 3>
193   %sh2 = shl nuw nsw <2 x i7> %sh1, <i7 2, i7 2>
194   ret <2 x i7> %sh2
197 ; In general, we would need an 'and' for this transform, but the masked-off bits are known zero.
198 ; lshr (shl X, C1), C2 -->  shl X, C1 - C2
200 define <2 x i7> @shl_lshr_splat_vec(<2 x i7> %X) {
201 ; CHECK-LABEL: @shl_lshr_splat_vec(
202 ; CHECK-NEXT:    [[DIV:%.*]] = udiv <2 x i7> [[X:%.*]], <i7 9, i7 9>
203 ; CHECK-NEXT:    [[SH1:%.*]] = shl nuw nsw <2 x i7> [[DIV]], <i7 1, i7 1>
204 ; CHECK-NEXT:    ret <2 x i7> [[SH1]]
206   %div = udiv <2 x i7> %X, <i7 9, i7 9>
207   %sh1 = shl nuw <2 x i7> %div, <i7 3, i7 3>
208   %sh2 = lshr exact <2 x i7> %sh1, <i7 2, i7 2>
209   ret <2 x i7> %sh2
212 ; Don't hide the shl from scalar evolution. DAGCombine will get it.
214 define i23 @test11(i23 %x) {
215 ; CHECK-LABEL: @test11(
216 ; CHECK-NEXT:    [[A:%.*]] = mul i23 [[X:%.*]], 3
217 ; CHECK-NEXT:    [[B:%.*]] = lshr i23 [[A]], 11
218 ; CHECK-NEXT:    [[C:%.*]] = shl i23 [[B]], 12
219 ; CHECK-NEXT:    ret i23 [[C]]
221   %a = mul i23 %x, 3
222   %b = lshr i23 %a, 11
223   %c = shl i23 %b, 12
224   ret i23 %c
227 ; shl (ashr X, C), C --> and X, C'
229 define i47 @test12(i47 %X) {
230 ; CHECK-LABEL: @test12(
231 ; CHECK-NEXT:    [[TMP1:%.*]] = and i47 [[X:%.*]], -256
232 ; CHECK-NEXT:    ret i47 [[TMP1]]
234   %sh1 = ashr i47 %X, 8
235   %sh2 = shl i47 %sh1, 8
236   ret i47 %sh2
239 define <2 x i47> @test12_splat_vec(<2 x i47> %X) {
240 ; CHECK-LABEL: @test12_splat_vec(
241 ; CHECK-NEXT:    [[TMP1:%.*]] = and <2 x i47> [[X:%.*]], <i47 -256, i47 -256>
242 ; CHECK-NEXT:    ret <2 x i47> [[TMP1]]
244   %sh1 = ashr <2 x i47> %X, <i47 8, i47 8>
245   %sh2 = shl <2 x i47> %sh1, <i47 8, i47 8>
246   ret <2 x i47> %sh2
249 ; Don't hide the shl from scalar evolution. DAGCombine will get it.
251 define i18 @test13(i18 %x) {
252 ; CHECK-LABEL: @test13(
253 ; CHECK-NEXT:    [[A:%.*]] = mul i18 [[X:%.*]], 3
254 ; CHECK-NEXT:    [[TMP1:%.*]] = lshr i18 [[A]], 8
255 ; CHECK-NEXT:    [[C:%.*]] = shl i18 [[TMP1]], 9
256 ; CHECK-NEXT:    ret i18 [[C]]
258   %a = mul i18 %x, 3
259   %b = ashr i18 %a, 8
260   %c = shl i18 %b, 9
261   ret i18 %c
264 define i35 @test14(i35 %A) {
265 ; CHECK-LABEL: @test14(
266 ; CHECK-NEXT:    [[B:%.*]] = and i35 [[A:%.*]], -19760
267 ; CHECK-NEXT:    [[C:%.*]] = or i35 [[B]], 19744
268 ; CHECK-NEXT:    ret i35 [[C]]
270   %B = lshr i35 %A, 4
271   %C = or i35 %B, 1234
272   %D = shl i35 %C, 4
273   ret i35 %D
276 define i79 @test14a(i79 %A) {
277 ; CHECK-LABEL: @test14a(
278 ; CHECK-NEXT:    [[C:%.*]] = and i79 [[A:%.*]], 77
279 ; CHECK-NEXT:    ret i79 [[C]]
281   %B = shl i79 %A, 4
282   %C = and i79 %B, 1234
283   %D = lshr i79 %C, 4
284   ret i79 %D
287 define i45 @test15(i1 %C) {
288 ; CHECK-LABEL: @test15(
289 ; CHECK-NEXT:    [[A:%.*]] = select i1 [[C:%.*]], i45 12, i45 4
290 ; CHECK-NEXT:    ret i45 [[A]]
292   %A = select i1 %C, i45 3, i45 1
293   %V = shl i45 %A, 2
294   ret i45 %V
297 define i53 @test15a(i1 %X) {
298 ; CHECK-LABEL: @test15a(
299 ; CHECK-NEXT:    [[V:%.*]] = select i1 [[X:%.*]], i53 512, i53 128
300 ; CHECK-NEXT:    ret i53 [[V]]
302   %A = select i1 %X, i8 3, i8 1
303   %B = zext i8 %A to i53
304   %V = shl i53 64, %B
305   ret i53 %V
308 define i1 @test16(i84 %X) {
309 ; CHECK-LABEL: @test16(
310 ; CHECK-NEXT:    [[AND:%.*]] = and i84 [[X:%.*]], 16
311 ; CHECK-NEXT:    [[CMP:%.*]] = icmp ne i84 [[AND]], 0
312 ; CHECK-NEXT:    ret i1 [[CMP]]
314   %shr = ashr i84 %X, 4
315   %and = and i84 %shr, 1
316   %cmp = icmp ne i84 %and, 0
317   ret i1 %cmp
320 define <2 x i1> @test16vec(<2 x i84> %X) {
321 ; CHECK-LABEL: @test16vec(
322 ; CHECK-NEXT:    [[TMP1:%.*]] = and <2 x i84> [[X:%.*]], <i84 16, i84 16>
323 ; CHECK-NEXT:    [[CMP:%.*]] = icmp ne <2 x i84> [[TMP1]], zeroinitializer
324 ; CHECK-NEXT:    ret <2 x i1> [[CMP]]
326   %shr = ashr <2 x i84> %X, <i84 4, i84 4>
327   %and = and <2 x i84> %shr, <i84 1, i84 1>
328   %cmp = icmp ne <2 x i84> %and, zeroinitializer
329   ret <2 x i1> %cmp
332 define i1 @test17(i106 %A) {
333 ; CHECK-LABEL: @test17(
334 ; CHECK-NEXT:    [[B_MASK:%.*]] = and i106 [[A:%.*]], -8
335 ; CHECK-NEXT:    [[C:%.*]] = icmp eq i106 [[B_MASK]], 9872
336 ; CHECK-NEXT:    ret i1 [[C]]
338   %B = lshr i106 %A, 3
339   %C = icmp eq i106 %B, 1234
340   ret i1 %C
343 define <2 x i1> @test17vec(<2 x i106> %A) {
344 ; CHECK-LABEL: @test17vec(
345 ; CHECK-NEXT:    [[B_MASK:%.*]] = and <2 x i106> [[A:%.*]], <i106 -8, i106 -8>
346 ; CHECK-NEXT:    [[C:%.*]] = icmp eq <2 x i106> [[B_MASK]], <i106 9872, i106 9872>
347 ; CHECK-NEXT:    ret <2 x i1> [[C]]
349   %B = lshr <2 x i106> %A, <i106 3, i106 3>
350   %C = icmp eq <2 x i106> %B, <i106 1234, i106 1234>
351   ret <2 x i1> %C
354 define i1 @test18(i11 %A) {
355 ; CHECK-LABEL: @test18(
356 ; CHECK-NEXT:    ret i1 false
358   %B = lshr i11 %A, 10
359   %C = icmp eq i11 %B, 123
360   ret i1 %C
363 define i1 @test19(i37 %A) {
364 ; CHECK-LABEL: @test19(
365 ; CHECK-NEXT:    [[C:%.*]] = icmp ult i37 [[A:%.*]], 4
366 ; CHECK-NEXT:    ret i1 [[C]]
368   %B = ashr i37 %A, 2
369   %C = icmp eq i37 %B, 0
370   ret i1 %C
373 define <2 x i1> @test19vec(<2 x i37> %A) {
374 ; CHECK-LABEL: @test19vec(
375 ; CHECK-NEXT:    [[C:%.*]] = icmp ult <2 x i37> [[A:%.*]], <i37 4, i37 4>
376 ; CHECK-NEXT:    ret <2 x i1> [[C]]
378   %B = ashr <2 x i37> %A, <i37 2, i37 2>
379   %C = icmp eq <2 x i37> %B, zeroinitializer
380   ret <2 x i1> %C
383 define i1 @test19a(i39 %A) {
384 ; CHECK-LABEL: @test19a(
385 ; CHECK-NEXT:    [[C:%.*]] = icmp ugt i39 [[A:%.*]], -5
386 ; CHECK-NEXT:    ret i1 [[C]]
388   %B = ashr i39 %A, 2
389   %C = icmp eq i39 %B, -1
390   ret i1 %C
393 define <2 x i1> @test19a_vec(<2 x i39> %A) {
394 ; CHECK-LABEL: @test19a_vec(
395 ; CHECK-NEXT:    [[C:%.*]] = icmp ugt <2 x i39> [[A:%.*]], <i39 -5, i39 -5>
396 ; CHECK-NEXT:    ret <2 x i1> [[C]]
398   %B = ashr <2 x i39> %A, <i39 2, i39 2>
399   %C = icmp eq <2 x i39> %B, <i39 -1, i39 -1>
400   ret <2 x i1> %C
403 define i1 @test20(i13 %A) {
404 ; CHECK-LABEL: @test20(
405 ; CHECK-NEXT:    ret i1 false
407   %B = ashr i13 %A, 12
408   %C = icmp eq i13 %B, 123
409   ret i1 %C
412 define i1 @test21(i12 %A) {
413 ; CHECK-LABEL: @test21(
414 ; CHECK-NEXT:    [[B_MASK:%.*]] = and i12 [[A:%.*]], 63
415 ; CHECK-NEXT:    [[C:%.*]] = icmp eq i12 [[B_MASK]], 62
416 ; CHECK-NEXT:    ret i1 [[C]]
418   %B = shl i12 %A, 6
419   %C = icmp eq i12 %B, -128
420   ret i1 %C
423 define i1 @test22(i14 %A) {
424 ; CHECK-LABEL: @test22(
425 ; CHECK-NEXT:    [[B_MASK:%.*]] = and i14 [[A:%.*]], 127
426 ; CHECK-NEXT:    [[C:%.*]] = icmp eq i14 [[B_MASK]], 0
427 ; CHECK-NEXT:    ret i1 [[C]]
429   %B = shl i14 %A, 7
430   %C = icmp eq i14 %B, 0
431   ret i1 %C
434 define i11 @test23(i44 %A) {
435 ; CHECK-LABEL: @test23(
436 ; CHECK-NEXT:    [[D:%.*]] = trunc i44 [[A:%.*]] to i11
437 ; CHECK-NEXT:    ret i11 [[D]]
439   %B = shl i44 %A, 33
440   %C = ashr i44 %B, 33
441   %D = trunc i44 %C to i11
442   ret i11 %D
445 ; Fold lshr (shl X, C), C -> and X, C' regardless of the number of uses of the shl.
447 define i44 @shl_lshr_eq_amt_multi_use(i44 %A) {
448 ; CHECK-LABEL: @shl_lshr_eq_amt_multi_use(
449 ; CHECK-NEXT:    [[B:%.*]] = shl i44 [[A:%.*]], 33
450 ; CHECK-NEXT:    [[C:%.*]] = and i44 [[A]], 2047
451 ; CHECK-NEXT:    [[D:%.*]] = or i44 [[B]], [[C]]
452 ; CHECK-NEXT:    ret i44 [[D]]
454   %B = shl i44 %A, 33
455   %C = lshr i44 %B, 33
456   %D = add i44 %B, %C
457   ret i44 %D
460 ; Fold vector lshr (shl X, C), C -> and X, C' regardless of the number of uses of the shl.
462 define <2 x i44> @shl_lshr_eq_amt_multi_use_splat_vec(<2 x i44> %A) {
463 ; CHECK-LABEL: @shl_lshr_eq_amt_multi_use_splat_vec(
464 ; CHECK-NEXT:    [[B:%.*]] = shl <2 x i44> [[A:%.*]], <i44 33, i44 33>
465 ; CHECK-NEXT:    [[C:%.*]] = and <2 x i44> [[A]], <i44 2047, i44 2047>
466 ; CHECK-NEXT:    [[D:%.*]] = or <2 x i44> [[B]], [[C]]
467 ; CHECK-NEXT:    ret <2 x i44> [[D]]
469   %B = shl <2 x i44> %A, <i44 33, i44 33>
470   %C = lshr <2 x i44> %B, <i44 33, i44 33>
471   %D = add <2 x i44> %B, %C
472   ret <2 x i44> %D
475 ; Fold shl (lshr X, C), C -> and X, C' regardless of the number of uses of the lshr.
477 define i43 @lshr_shl_eq_amt_multi_use(i43 %A) {
478 ; CHECK-LABEL: @lshr_shl_eq_amt_multi_use(
479 ; CHECK-NEXT:    [[B:%.*]] = lshr i43 [[A:%.*]], 23
480 ; CHECK-NEXT:    [[C:%.*]] = and i43 [[A]], -8388608
481 ; CHECK-NEXT:    [[D:%.*]] = mul i43 [[B]], [[C]]
482 ; CHECK-NEXT:    ret i43 [[D]]
484   %B = lshr i43 %A, 23
485   %C = shl i43 %B, 23
486   %D = mul i43 %B, %C
487   ret i43 %D
490 ; Fold vector shl (lshr X, C), C -> and X, C' regardless of the number of uses of the lshr.
492 define <2 x i43> @lshr_shl_eq_amt_multi_use_splat_vec(<2 x i43> %A) {
493 ; CHECK-LABEL: @lshr_shl_eq_amt_multi_use_splat_vec(
494 ; CHECK-NEXT:    [[B:%.*]] = lshr <2 x i43> [[A:%.*]], <i43 23, i43 23>
495 ; CHECK-NEXT:    [[C:%.*]] = and <2 x i43> [[A]], <i43 -8388608, i43 -8388608>
496 ; CHECK-NEXT:    [[D:%.*]] = mul <2 x i43> [[B]], [[C]]
497 ; CHECK-NEXT:    ret <2 x i43> [[D]]
499   %B = lshr <2 x i43> %A, <i43 23, i43 23>
500   %C = shl <2 x i43> %B, <i43 23, i43 23>
501   %D = mul <2 x i43> %B, %C
502   ret <2 x i43> %D
505 define i37 @test25(i37 %tmp.2, i37 %AA) {
506 ; CHECK-LABEL: @test25(
507 ; CHECK-NEXT:    [[TMP_3:%.*]] = and i37 [[TMP_2:%.*]], -131072
508 ; CHECK-NEXT:    [[X2:%.*]] = add i37 [[TMP_3]], [[AA:%.*]]
509 ; CHECK-NEXT:    [[TMP_6:%.*]] = and i37 [[X2]], -131072
510 ; CHECK-NEXT:    ret i37 [[TMP_6]]
512   %x = lshr i37 %AA, 17
513   %tmp.3 = lshr i37 %tmp.2, 17
514   %tmp.5 = add i37 %tmp.3, %x
515   %tmp.6 = shl i37 %tmp.5, 17
516   ret i37 %tmp.6
519 define i40 @test26(i40 %A) {
520 ; CHECK-LABEL: @test26(
521 ; CHECK-NEXT:    [[B:%.*]] = and i40 [[A:%.*]], -2
522 ; CHECK-NEXT:    ret i40 [[B]]
524   %B = lshr i40 %A, 1
525   %C = bitcast i40 %B to i40
526   %D = shl i40 %C, 1
527   ret i40 %D
530 ; OSS-Fuzz #9880
531 ; https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9880
532 define i177 @ossfuzz_9880(i177 %X) {
533 ; CHECK-LABEL: @ossfuzz_9880(
534 ; CHECK-NEXT:    [[A:%.*]] = alloca i177, align 8
535 ; CHECK-NEXT:    [[L1:%.*]] = load i177, i177* [[A]], align 8
536 ; CHECK-NEXT:    [[TMP1:%.*]] = icmp eq i177 [[L1]], 0
537 ; CHECK-NEXT:    [[B1:%.*]] = zext i1 [[TMP1]] to i177
538 ; CHECK-NEXT:    ret i177 [[B1]]
540   %A = alloca i177
541   %L1 = load i177, i177* %A
542   %B = or i177 0, -1
543   %B5 = udiv i177 %L1, %B
544   %B4 = add i177 %B5, %B
545   %B2 = add i177 %B, %B4
546   %B6 = mul i177 %B5, %B2
547   %B20 = shl i177 %L1, %B6
548   %B14 = sub i177 %B20, %B5
549   %B1 = udiv i177 %B14, %B6
550   ret i177 %B1