@@ -10,13 +10,11 @@ declare i8 @llvm.smax.i8(i8, i8)
10
10
11
11
define i32 @t1 (i16 zeroext %x , i32 %y ) {
12
12
; CHECK-LABEL: @t1(
13
- ; CHECK-NEXT: entry:
14
13
; CHECK-NEXT: [[CONV:%.*]] = zext i16 [[X:%.*]] to i32
15
- ; CHECK-NEXT: [[TMP0 :%.*]] = add i32 [[Y:%.*]], 1
16
- ; CHECK-NEXT: [[D1:%.*]] = lshr i32 [[CONV]], [[TMP0 ]]
14
+ ; CHECK-NEXT: [[TMP1 :%.*]] = add i32 [[Y:%.*]], 1
15
+ ; CHECK-NEXT: [[D1:%.*]] = lshr i32 [[CONV]], [[TMP1 ]]
17
16
; CHECK-NEXT: ret i32 [[D1]]
18
17
;
19
- entry:
20
18
%conv = zext i16 %x to i32
21
19
%s = shl i32 2 , %y
22
20
%d = sdiv i32 %conv , %s
@@ -25,13 +23,11 @@ entry:
25
23
26
24
define <2 x i32 > @t1vec (<2 x i16 > %x , <2 x i32 > %y ) {
27
25
; CHECK-LABEL: @t1vec(
28
- ; CHECK-NEXT: entry:
29
26
; CHECK-NEXT: [[CONV:%.*]] = zext <2 x i16> [[X:%.*]] to <2 x i32>
30
- ; CHECK-NEXT: [[TMP0 :%.*]] = add <2 x i32> [[Y:%.*]], <i32 1, i32 1>
31
- ; CHECK-NEXT: [[D1:%.*]] = lshr <2 x i32> [[CONV]], [[TMP0 ]]
27
+ ; CHECK-NEXT: [[TMP1 :%.*]] = add <2 x i32> [[Y:%.*]], <i32 1, i32 1>
28
+ ; CHECK-NEXT: [[D1:%.*]] = lshr <2 x i32> [[CONV]], [[TMP1 ]]
32
29
; CHECK-NEXT: ret <2 x i32> [[D1]]
33
30
;
34
- entry:
35
31
%conv = zext <2 x i16 > %x to <2 x i32 >
36
32
%s = shl <2 x i32 > <i32 2 , i32 2 >, %y
37
33
%d = sdiv <2 x i32 > %conv , %s
@@ -298,3 +294,253 @@ define <2 x i32> @t16(<2 x i32> %x, <2 x i32> %y) {
298
294
%r = udiv <2 x i32 > %shl , %x
299
295
ret <2 x i32 > %r
300
296
}
297
+
298
+ define i5 @sdiv_mul_shl_nsw (i5 %x , i5 %y , i5 %z ) {
299
+ ; CHECK-LABEL: @sdiv_mul_shl_nsw(
300
+ ; CHECK-NEXT: [[M1:%.*]] = mul nsw i5 [[X:%.*]], [[Y:%.*]]
301
+ ; CHECK-NEXT: [[M2:%.*]] = shl nsw i5 [[X]], [[Z:%.*]]
302
+ ; CHECK-NEXT: [[D:%.*]] = sdiv i5 [[M1]], [[M2]]
303
+ ; CHECK-NEXT: ret i5 [[D]]
304
+ ;
305
+ %m1 = mul nsw i5 %x , %y
306
+ %m2 = shl nsw i5 %x , %z
307
+ %d = sdiv i5 %m1 , %m2
308
+ ret i5 %d
309
+ }
310
+
311
+ define i5 @sdiv_mul_shl_nsw_commute1 (i5 %x , i5 %y , i5 %z ) {
312
+ ; CHECK-LABEL: @sdiv_mul_shl_nsw_commute1(
313
+ ; CHECK-NEXT: [[M1:%.*]] = mul nsw i5 [[Y:%.*]], [[X:%.*]]
314
+ ; CHECK-NEXT: [[M2:%.*]] = shl nsw i5 [[X]], [[Z:%.*]]
315
+ ; CHECK-NEXT: [[D:%.*]] = sdiv i5 [[M1]], [[M2]]
316
+ ; CHECK-NEXT: ret i5 [[D]]
317
+ ;
318
+ %m1 = mul nsw i5 %y , %x
319
+ %m2 = shl nsw i5 %x , %z
320
+ %d = sdiv i5 %m1 , %m2
321
+ ret i5 %d
322
+ }
323
+
324
+ define i5 @sdiv_mul_shl_nsw_commute2 (i5 %x , i5 %y , i5 %z ) {
325
+ ; CHECK-LABEL: @sdiv_mul_shl_nsw_commute2(
326
+ ; CHECK-NEXT: [[M1:%.*]] = mul nsw i5 [[X:%.*]], [[Y:%.*]]
327
+ ; CHECK-NEXT: [[M2:%.*]] = shl nsw i5 [[Z:%.*]], [[X]]
328
+ ; CHECK-NEXT: [[D:%.*]] = sdiv i5 [[M1]], [[M2]]
329
+ ; CHECK-NEXT: ret i5 [[D]]
330
+ ;
331
+ %m1 = mul nsw i5 %x , %y
332
+ %m2 = shl nsw i5 %z , %x
333
+ %d = sdiv i5 %m1 , %m2
334
+ ret i5 %d
335
+ }
336
+
337
+ define i8 @sdiv_mul_shl_nsw_use1 (i8 %x , i8 %y , i8 %z ) {
338
+ ; CHECK-LABEL: @sdiv_mul_shl_nsw_use1(
339
+ ; CHECK-NEXT: [[M1:%.*]] = mul nsw i8 [[X:%.*]], [[Y:%.*]]
340
+ ; CHECK-NEXT: call void @use(i8 [[M1]])
341
+ ; CHECK-NEXT: [[M2:%.*]] = shl nsw i8 [[X]], [[Z:%.*]]
342
+ ; CHECK-NEXT: [[D:%.*]] = sdiv i8 [[M1]], [[M2]]
343
+ ; CHECK-NEXT: ret i8 [[D]]
344
+ ;
345
+ %m1 = mul nsw i8 %x , %y
346
+ call void @use (i8 %m1 )
347
+ %m2 = shl nsw i8 %x , %z
348
+ %d = sdiv i8 %m1 , %m2
349
+ ret i8 %d
350
+ }
351
+
352
+ define i8 @sdiv_mul_shl_nsw_use2 (i8 %x , i8 %y , i8 %z ) {
353
+ ; CHECK-LABEL: @sdiv_mul_shl_nsw_use2(
354
+ ; CHECK-NEXT: [[M1:%.*]] = mul nsw i8 [[X:%.*]], [[Y:%.*]]
355
+ ; CHECK-NEXT: [[M2:%.*]] = shl nsw i8 [[X]], [[Z:%.*]]
356
+ ; CHECK-NEXT: call void @use(i8 [[M2]])
357
+ ; CHECK-NEXT: [[D:%.*]] = sdiv i8 [[M1]], [[M2]]
358
+ ; CHECK-NEXT: ret i8 [[D]]
359
+ ;
360
+ %m1 = mul nsw i8 %x , %y
361
+ %m2 = shl nsw i8 %x , %z
362
+ call void @use (i8 %m2 )
363
+ %d = sdiv i8 %m1 , %m2
364
+ ret i8 %d
365
+ }
366
+
367
+ define i8 @sdiv_mul_shl_nsw_use3 (i8 %x , i8 %y , i8 %z ) {
368
+ ; CHECK-LABEL: @sdiv_mul_shl_nsw_use3(
369
+ ; CHECK-NEXT: [[M1:%.*]] = mul nsw i8 [[X:%.*]], [[Y:%.*]]
370
+ ; CHECK-NEXT: call void @use(i8 [[M1]])
371
+ ; CHECK-NEXT: [[M2:%.*]] = shl nsw i8 [[X]], [[Z:%.*]]
372
+ ; CHECK-NEXT: call void @use(i8 [[M2]])
373
+ ; CHECK-NEXT: [[D:%.*]] = sdiv i8 [[M1]], [[M2]]
374
+ ; CHECK-NEXT: ret i8 [[D]]
375
+ ;
376
+ %m1 = mul nsw i8 %x , %y
377
+ call void @use (i8 %m1 )
378
+ %m2 = shl nsw i8 %x , %z
379
+ call void @use (i8 %m2 )
380
+ %d = sdiv i8 %m1 , %m2
381
+ ret i8 %d
382
+ }
383
+
384
+ define i5 @sdiv_shl_mul_nsw (i5 %x , i5 %y , i5 %z ) {
385
+ ; CHECK-LABEL: @sdiv_shl_mul_nsw(
386
+ ; CHECK-NEXT: [[M1:%.*]] = shl nsw i5 [[Z:%.*]], [[X:%.*]]
387
+ ; CHECK-NEXT: [[M2:%.*]] = mul nsw i5 [[X]], [[Y:%.*]]
388
+ ; CHECK-NEXT: [[D:%.*]] = sdiv i5 [[M1]], [[M2]]
389
+ ; CHECK-NEXT: ret i5 [[D]]
390
+ ;
391
+ %m1 = shl nsw i5 %z , %x
392
+ %m2 = mul nsw i5 %x , %y
393
+ %d = sdiv i5 %m1 , %m2
394
+ ret i5 %d
395
+ }
396
+
397
+ define i5 @sdiv_mul_shl_missing_nsw1 (i5 %x , i5 %y , i5 %z ) {
398
+ ; CHECK-LABEL: @sdiv_mul_shl_missing_nsw1(
399
+ ; CHECK-NEXT: [[M1:%.*]] = mul nsw i5 [[X:%.*]], [[Y:%.*]]
400
+ ; CHECK-NEXT: [[M2:%.*]] = shl nuw i5 [[Y]], [[Z:%.*]]
401
+ ; CHECK-NEXT: [[D:%.*]] = sdiv i5 [[M1]], [[M2]]
402
+ ; CHECK-NEXT: ret i5 [[D]]
403
+ ;
404
+ %m1 = mul nsw i5 %x , %y
405
+ %m2 = shl nuw i5 %y , %z
406
+ %d = sdiv i5 %m1 , %m2
407
+ ret i5 %d
408
+ }
409
+
410
+ define i5 @sdiv_mul_shl_missing_nsw2 (i5 %x , i5 %y , i5 %z ) {
411
+ ; CHECK-LABEL: @sdiv_mul_shl_missing_nsw2(
412
+ ; CHECK-NEXT: [[M1:%.*]] = mul nuw i5 [[X:%.*]], [[Y:%.*]]
413
+ ; CHECK-NEXT: [[M2:%.*]] = shl nsw i5 [[Y]], [[Z:%.*]]
414
+ ; CHECK-NEXT: [[D:%.*]] = sdiv i5 [[M1]], [[M2]]
415
+ ; CHECK-NEXT: ret i5 [[D]]
416
+ ;
417
+ %m1 = mul nuw i5 %x , %y
418
+ %m2 = shl nsw i5 %y , %z
419
+ %d = sdiv i5 %m1 , %m2
420
+ ret i5 %d
421
+ }
422
+
423
+ define i5 @udiv_mul_shl_nuw (i5 %x , i5 %y , i5 %z ) {
424
+ ; CHECK-LABEL: @udiv_mul_shl_nuw(
425
+ ; CHECK-NEXT: [[M1:%.*]] = mul nuw i5 [[X:%.*]], [[Y:%.*]]
426
+ ; CHECK-NEXT: [[M2:%.*]] = shl nuw i5 [[X]], [[Z:%.*]]
427
+ ; CHECK-NEXT: [[D:%.*]] = udiv i5 [[M1]], [[M2]]
428
+ ; CHECK-NEXT: ret i5 [[D]]
429
+ ;
430
+ %m1 = mul nuw i5 %x , %y
431
+ %m2 = shl nuw i5 %x , %z
432
+ %d = udiv i5 %m1 , %m2
433
+ ret i5 %d
434
+ }
435
+
436
+ define i5 @udiv_mul_shl_nuw_commute1 (i5 %x , i5 %y , i5 %z ) {
437
+ ; CHECK-LABEL: @udiv_mul_shl_nuw_commute1(
438
+ ; CHECK-NEXT: [[M1:%.*]] = mul nuw i5 [[Y:%.*]], [[X:%.*]]
439
+ ; CHECK-NEXT: [[M2:%.*]] = shl nuw i5 [[X]], [[Z:%.*]]
440
+ ; CHECK-NEXT: [[D:%.*]] = udiv i5 [[M1]], [[M2]]
441
+ ; CHECK-NEXT: ret i5 [[D]]
442
+ ;
443
+ %m1 = mul nuw i5 %y , %x
444
+ %m2 = shl nuw i5 %x , %z
445
+ %d = udiv i5 %m1 , %m2
446
+ ret i5 %d
447
+ }
448
+
449
+ define i5 @udiv_mul_shl_nuw_commute2 (i5 %x , i5 %y , i5 %z ) {
450
+ ; CHECK-LABEL: @udiv_mul_shl_nuw_commute2(
451
+ ; CHECK-NEXT: [[M1:%.*]] = mul nuw i5 [[X:%.*]], [[Y:%.*]]
452
+ ; CHECK-NEXT: [[M2:%.*]] = shl nuw i5 [[Z:%.*]], [[X]]
453
+ ; CHECK-NEXT: [[D:%.*]] = udiv i5 [[M1]], [[M2]]
454
+ ; CHECK-NEXT: ret i5 [[D]]
455
+ ;
456
+ %m1 = mul nuw i5 %x , %y
457
+ %m2 = shl nuw i5 %z , %x
458
+ %d = udiv i5 %m1 , %m2
459
+ ret i5 %d
460
+ }
461
+
462
+ define i8 @udiv_mul_shl_nsw_use1 (i8 %x , i8 %y , i8 %z ) {
463
+ ; CHECK-LABEL: @udiv_mul_shl_nsw_use1(
464
+ ; CHECK-NEXT: [[M1:%.*]] = mul nuw i8 [[X:%.*]], [[Y:%.*]]
465
+ ; CHECK-NEXT: call void @use(i8 [[M1]])
466
+ ; CHECK-NEXT: [[M2:%.*]] = shl nuw i8 [[X]], [[Z:%.*]]
467
+ ; CHECK-NEXT: [[D:%.*]] = udiv i8 [[M1]], [[M2]]
468
+ ; CHECK-NEXT: ret i8 [[D]]
469
+ ;
470
+ %m1 = mul nuw i8 %x , %y
471
+ call void @use (i8 %m1 )
472
+ %m2 = shl nuw i8 %x , %z
473
+ %d = udiv i8 %m1 , %m2
474
+ ret i8 %d
475
+ }
476
+
477
+ define i8 @udiv_mul_shl_nsw_use2 (i8 %x , i8 %y , i8 %z ) {
478
+ ; CHECK-LABEL: @udiv_mul_shl_nsw_use2(
479
+ ; CHECK-NEXT: [[M1:%.*]] = mul nuw i8 [[X:%.*]], [[Y:%.*]]
480
+ ; CHECK-NEXT: [[M2:%.*]] = shl nuw i8 [[X]], [[Z:%.*]]
481
+ ; CHECK-NEXT: call void @use(i8 [[M2]])
482
+ ; CHECK-NEXT: [[D:%.*]] = udiv i8 [[M1]], [[M2]]
483
+ ; CHECK-NEXT: ret i8 [[D]]
484
+ ;
485
+ %m1 = mul nuw i8 %x , %y
486
+ %m2 = shl nuw i8 %x , %z
487
+ call void @use (i8 %m2 )
488
+ %d = udiv i8 %m1 , %m2
489
+ ret i8 %d
490
+ }
491
+
492
+ define i8 @udiv_mul_shl_nsw_use3 (i8 %x , i8 %y , i8 %z ) {
493
+ ; CHECK-LABEL: @udiv_mul_shl_nsw_use3(
494
+ ; CHECK-NEXT: [[M1:%.*]] = mul nuw i8 [[X:%.*]], [[Y:%.*]]
495
+ ; CHECK-NEXT: call void @use(i8 [[M1]])
496
+ ; CHECK-NEXT: [[M2:%.*]] = shl nuw i8 [[X]], [[Z:%.*]]
497
+ ; CHECK-NEXT: call void @use(i8 [[M2]])
498
+ ; CHECK-NEXT: [[D:%.*]] = udiv i8 [[M1]], [[M2]]
499
+ ; CHECK-NEXT: ret i8 [[D]]
500
+ ;
501
+ %m1 = mul nuw i8 %x , %y
502
+ call void @use (i8 %m1 )
503
+ %m2 = shl nuw i8 %x , %z
504
+ call void @use (i8 %m2 )
505
+ %d = udiv i8 %m1 , %m2
506
+ ret i8 %d
507
+ }
508
+
509
+ define i5 @udiv_shl_mul_nuw (i5 %x , i5 %y , i5 %z ) {
510
+ ; CHECK-LABEL: @udiv_shl_mul_nuw(
511
+ ; CHECK-NEXT: [[M1:%.*]] = shl nuw i5 [[Z:%.*]], [[X:%.*]]
512
+ ; CHECK-NEXT: [[M2:%.*]] = mul nuw i5 [[X]], [[Y:%.*]]
513
+ ; CHECK-NEXT: [[D:%.*]] = udiv i5 [[M1]], [[M2]]
514
+ ; CHECK-NEXT: ret i5 [[D]]
515
+ ;
516
+ %m1 = shl nuw i5 %z , %x
517
+ %m2 = mul nuw i5 %x , %y
518
+ %d = udiv i5 %m1 , %m2
519
+ ret i5 %d
520
+ }
521
+
522
+ define i5 @udiv_mul_shl_missing_nsw1 (i5 %x , i5 %y , i5 %z ) {
523
+ ; CHECK-LABEL: @udiv_mul_shl_missing_nsw1(
524
+ ; CHECK-NEXT: [[M1:%.*]] = mul nsw i5 [[X:%.*]], [[Y:%.*]]
525
+ ; CHECK-NEXT: [[M2:%.*]] = shl nuw i5 [[Y]], [[Z:%.*]]
526
+ ; CHECK-NEXT: [[D:%.*]] = udiv i5 [[M1]], [[M2]]
527
+ ; CHECK-NEXT: ret i5 [[D]]
528
+ ;
529
+ %m1 = mul nsw i5 %x , %y
530
+ %m2 = shl nuw i5 %y , %z
531
+ %d = udiv i5 %m1 , %m2
532
+ ret i5 %d
533
+ }
534
+
535
+ define i5 @udiv_mul_shl_missing_nsw2 (i5 %x , i5 %y , i5 %z ) {
536
+ ; CHECK-LABEL: @udiv_mul_shl_missing_nsw2(
537
+ ; CHECK-NEXT: [[M1:%.*]] = mul nuw i5 [[X:%.*]], [[Y:%.*]]
538
+ ; CHECK-NEXT: [[M2:%.*]] = shl nsw i5 [[Y]], [[Z:%.*]]
539
+ ; CHECK-NEXT: [[D:%.*]] = udiv i5 [[M1]], [[M2]]
540
+ ; CHECK-NEXT: ret i5 [[D]]
541
+ ;
542
+ %m1 = mul nuw i5 %x , %y
543
+ %m2 = shl nsw i5 %y , %z
544
+ %d = udiv i5 %m1 , %m2
545
+ ret i5 %d
546
+ }
0 commit comments