@@ -1435,11 +1435,26 @@ define i32 @and31_add_sexts(i1 %x, i1 %y) {
1435
1435
ret i32 %r
1436
1436
}
1437
1437
1438
- ; Negative test - extra use
1439
-
1440
1438
define i32 @lshr_add_use_sexts (i1 %x , i1 %y , ptr %p ) {
1441
1439
; CHECK-LABEL: @lshr_add_use_sexts(
1442
1440
; CHECK-NEXT: [[XS:%.*]] = sext i1 [[X:%.*]] to i32
1441
+ ; CHECK-NEXT: [[YS:%.*]] = sext i1 [[Y:%.*]] to i32
1442
+ ; CHECK-NEXT: store i32 [[YS]], ptr [[P:%.*]], align 4
1443
+ ; CHECK-NEXT: [[SUB:%.*]] = add nsw i32 [[XS]], [[YS]]
1444
+ ; CHECK-NEXT: [[R:%.*]] = lshr i32 [[SUB]], 31
1445
+ ; CHECK-NEXT: ret i32 [[R]]
1446
+ ;
1447
+ %xs = sext i1 %x to i32
1448
+ %ys = sext i1 %y to i32
1449
+ store i32 %ys , ptr %p
1450
+ %sub = add i32 %xs , %ys
1451
+ %r = lshr i32 %sub , 31
1452
+ ret i32 %r
1453
+ }
1454
+
1455
+ define i32 @lshr_add_use_sexts_2 (i1 %x , i1 %y , ptr %p ) {
1456
+ ; CHECK-LABEL: @lshr_add_use_sexts_2(
1457
+ ; CHECK-NEXT: [[XS:%.*]] = sext i1 [[X:%.*]] to i32
1443
1458
; CHECK-NEXT: store i32 [[XS]], ptr [[P:%.*]], align 4
1444
1459
; CHECK-NEXT: [[YS:%.*]] = sext i1 [[Y:%.*]] to i32
1445
1460
; CHECK-NEXT: [[SUB:%.*]] = add nsw i32 [[XS]], [[YS]]
@@ -1456,18 +1471,20 @@ define i32 @lshr_add_use_sexts(i1 %x, i1 %y, ptr %p) {
1456
1471
1457
1472
; Negative test - extra use
1458
1473
1459
- define i32 @lshr_add_use2_sexts (i1 %x , i1 %y , ptr %p ) {
1460
- ; CHECK-LABEL: @lshr_add_use2_sexts(
1474
+ declare void @use_sexts (i32 , i32 )
1475
+
1476
+ define i32 @lshr_add_use_sexts_both (i1 %x , i1 %y ) {
1477
+ ; CHECK-LABEL: @lshr_add_use_sexts_both(
1461
1478
; CHECK-NEXT: [[XS:%.*]] = sext i1 [[X:%.*]] to i32
1462
1479
; CHECK-NEXT: [[YS:%.*]] = sext i1 [[Y:%.*]] to i32
1463
- ; CHECK-NEXT: store i32 [[YS ]], ptr [[P:%.*]], align 4
1480
+ ; CHECK-NEXT: call void @use_sexts( i32 [[XS ]], i32 [[YS]])
1464
1481
; CHECK-NEXT: [[SUB:%.*]] = add nsw i32 [[XS]], [[YS]]
1465
1482
; CHECK-NEXT: [[R:%.*]] = lshr i32 [[SUB]], 31
1466
1483
; CHECK-NEXT: ret i32 [[R]]
1467
1484
;
1468
1485
%xs = sext i1 %x to i32
1469
1486
%ys = sext i1 %y to i32
1470
- store i32 %ys , ptr %p
1487
+ call void @use_sexts ( i32 %xs , i32 %ys )
1471
1488
%sub = add i32 %xs , %ys
1472
1489
%r = lshr i32 %sub , 31
1473
1490
ret i32 %r
0 commit comments