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