@@ -360,24 +360,12 @@ define <3 x i14> @mul_splat_fold_vec(<3 x i14> %x) {
360
360
ret <3 x i14 > %t
361
361
}
362
362
363
- ; Negative tests
364
-
365
- define i32 @mul_times_3_div_2 (i32 %x ) {
366
- ; CHECK-LABEL: @mul_times_3_div_2(
367
- ; CHECK-NEXT: [[MUL:%.*]] = mul nuw nsw i32 [[X:%.*]], 3
368
- ; CHECK-NEXT: [[RES:%.*]] = lshr i32 [[MUL]], 1
369
- ; CHECK-NEXT: ret i32 [[RES]]
370
- ;
371
- %mul = mul nsw nuw i32 %x , 3
372
- %res = lshr i32 %mul , 1
373
- ret i32 %res
374
- }
363
+ ; Negative test
375
364
376
365
define i32 @shl_add_lshr (i32 %x , i32 %c , i32 %y ) {
377
366
; CHECK-LABEL: @shl_add_lshr(
378
- ; CHECK-NEXT: [[SHL:%.*]] = shl nuw i32 [[X:%.*]], [[C:%.*]]
379
- ; CHECK-NEXT: [[ADD:%.*]] = add nuw nsw i32 [[SHL]], [[Y:%.*]]
380
- ; CHECK-NEXT: [[LSHR:%.*]] = lshr exact i32 [[ADD]], [[C]]
367
+ ; CHECK-NEXT: [[TMP1:%.*]] = lshr exact i32 [[Y:%.*]], [[C:%.*]]
368
+ ; CHECK-NEXT: [[LSHR:%.*]] = add nuw nsw i32 [[TMP1]], [[X:%.*]]
381
369
; CHECK-NEXT: ret i32 [[LSHR]]
382
370
;
383
371
%shl = shl nuw i32 %x , %c
@@ -386,40 +374,7 @@ define i32 @shl_add_lshr(i32 %x, i32 %c, i32 %y) {
386
374
ret i32 %lshr
387
375
}
388
376
389
- define i32 @lshr_mul_times_3_div_2_nuw (i32 %0 ) {
390
- ; CHECK-LABEL: @lshr_mul_times_3_div_2_nuw(
391
- ; CHECK-NEXT: [[TMP2:%.*]] = lshr i32 [[TMP0:%.*]], 1
392
- ; CHECK-NEXT: [[LSHR:%.*]] = add nuw nsw i32 [[TMP2]], [[TMP0]]
393
- ; CHECK-NEXT: ret i32 [[LSHR]]
394
- ;
395
- %mul = mul nuw i32 %0 , 3
396
- %lshr = lshr i32 %mul , 1
397
- ret i32 %lshr
398
- }
399
-
400
- define i32 @lshr_mul_times_3_div_2_nsw (i32 %0 ) {
401
- ; CHECK-LABEL: @lshr_mul_times_3_div_2_nsw(
402
- ; CHECK-NEXT: [[MUL:%.*]] = mul nsw i32 [[TMP0:%.*]], 3
403
- ; CHECK-NEXT: [[LSHR:%.*]] = lshr i32 [[MUL]], 1
404
- ; CHECK-NEXT: ret i32 [[LSHR]]
405
- ;
406
- %mul = mul nsw i32 %0 , 3
407
- %lshr = lshr i32 %mul , 1
408
- ret i32 %lshr
409
- }
410
-
411
- ; Negative tests
412
-
413
- define i32 @mul_times_3_div_2_no_flag (i32 %x ) {
414
- ; CHECK-LABEL: @mul_times_3_div_2_no_flag(
415
- ; CHECK-NEXT: [[MUL:%.*]] = mul i32 [[X:%.*]], 3
416
- ; CHECK-NEXT: [[LSHR:%.*]] = lshr i32 [[MUL]], 1
417
- ; CHECK-NEXT: ret i32 [[LSHR]]
418
- ;
419
- %mul = mul i32 %x , 3
420
- %lshr = lshr i32 %mul , 1
421
- ret i32 %lshr
422
- }
377
+ ; Negative test
423
378
424
379
define i32 @shl_add_lshr_neg (i32 %x , i32 %y , i32 %z ) {
425
380
; CHECK-LABEL: @shl_add_lshr_neg(
@@ -445,6 +400,8 @@ define i32 @mul_splat_fold_wrong_mul_const(i32 %x) {
445
400
ret i32 %t
446
401
}
447
402
403
+ ; Negative test
404
+
448
405
define i32 @shl_add_lshr_multiuse (i32 %x , i32 %y , i32 %z ) {
449
406
; CHECK-LABEL: @shl_add_lshr_multiuse(
450
407
; CHECK-NEXT: [[SHL:%.*]] = shl nuw i32 [[X:%.*]], [[Y:%.*]]
@@ -460,19 +417,6 @@ define i32 @shl_add_lshr_multiuse(i32 %x, i32 %y, i32 %z) {
460
417
ret i32 %res
461
418
}
462
419
463
- define i32 @mul_times_3_div_2_multiuse (i32 %x ) {
464
- ; CHECK-LABEL: @mul_times_3_div_2_multiuse(
465
- ; CHECK-NEXT: [[MUL:%.*]] = mul nuw i32 [[X:%.*]], 3
466
- ; CHECK-NEXT: [[RES:%.*]] = lshr i32 [[MUL]], 1
467
- ; CHECK-NEXT: call void @use(i32 [[MUL]])
468
- ; CHECK-NEXT: ret i32 [[RES]]
469
- ;
470
- %mul = mul nuw i32 %x , 3
471
- %res = lshr i32 %mul , 1
472
- call void @use (i32 %mul )
473
- ret i32 %res
474
- }
475
-
476
420
define i32 @mul_splat_fold_wrong_lshr_const (i32 %x ) {
477
421
; CHECK-LABEL: @mul_splat_fold_wrong_lshr_const(
478
422
; CHECK-NEXT: [[M:%.*]] = mul nuw i32 [[X:%.*]], 65537
@@ -484,6 +428,8 @@ define i32 @mul_splat_fold_wrong_lshr_const(i32 %x) {
484
428
ret i32 %t
485
429
}
486
430
431
+ ; Negative test
432
+
487
433
define i32 @mul_splat_fold_no_nuw (i32 %x ) {
488
434
; CHECK-LABEL: @mul_splat_fold_no_nuw(
489
435
; CHECK-NEXT: [[M:%.*]] = mul nsw i32 [[X:%.*]], 65537
0 commit comments