@@ -1465,10 +1465,8 @@ define i1 @exactly_one_set_signbit_wrong_pred(i8 %x, i8 %y) {
1465
1465
1466
1466
define i1 @exactly_one_set_signbit_signed (i8 %x , i8 %y ) {
1467
1467
; CHECK-LABEL: @exactly_one_set_signbit_signed(
1468
- ; CHECK-NEXT: [[XSIGN:%.*]] = ashr i8 [[X:%.*]], 7
1469
- ; CHECK-NEXT: [[YPOS:%.*]] = icmp sgt i8 [[Y:%.*]], -1
1470
- ; CHECK-NEXT: [[YPOSZ:%.*]] = sext i1 [[YPOS]] to i8
1471
- ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[XSIGN]], [[YPOSZ]]
1468
+ ; CHECK-NEXT: [[XOR_SIGNBITS:%.*]] = xor i8 [[X:%.*]], [[Y:%.*]]
1469
+ ; CHECK-NEXT: [[R:%.*]] = icmp slt i8 [[XOR_SIGNBITS]], 0
1472
1470
; CHECK-NEXT: ret i1 [[R]]
1473
1471
;
1474
1472
%xsign = ashr i8 %x , 7
@@ -1482,9 +1480,8 @@ define i1 @exactly_one_set_signbit_use1_signed(i8 %x, i8 %y) {
1482
1480
; CHECK-LABEL: @exactly_one_set_signbit_use1_signed(
1483
1481
; CHECK-NEXT: [[XSIGN:%.*]] = ashr i8 [[X:%.*]], 7
1484
1482
; CHECK-NEXT: call void @use(i8 [[XSIGN]])
1485
- ; CHECK-NEXT: [[YPOS:%.*]] = icmp sgt i8 [[Y:%.*]], -1
1486
- ; CHECK-NEXT: [[YPOSZ:%.*]] = sext i1 [[YPOS]] to i8
1487
- ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[XSIGN]], [[YPOSZ]]
1483
+ ; CHECK-NEXT: [[XOR_SIGNBITS:%.*]] = xor i8 [[X]], [[Y:%.*]]
1484
+ ; CHECK-NEXT: [[R:%.*]] = icmp slt i8 [[XOR_SIGNBITS]], 0
1488
1485
; CHECK-NEXT: ret i1 [[R]]
1489
1486
;
1490
1487
%xsign = ashr i8 %x , 7
@@ -1497,10 +1494,8 @@ define i1 @exactly_one_set_signbit_use1_signed(i8 %x, i8 %y) {
1497
1494
1498
1495
define <2 x i1 > @same_signbit_signed (<2 x i8 > %x , <2 x i8 > %y ) {
1499
1496
; CHECK-LABEL: @same_signbit_signed(
1500
- ; CHECK-NEXT: [[XSIGN:%.*]] = ashr <2 x i8> [[X:%.*]], <i8 7, i8 7>
1501
- ; CHECK-NEXT: [[YPOS:%.*]] = icmp sgt <2 x i8> [[Y:%.*]], <i8 -1, i8 -1>
1502
- ; CHECK-NEXT: [[YPOSZ:%.*]] = sext <2 x i1> [[YPOS]] to <2 x i8>
1503
- ; CHECK-NEXT: [[R:%.*]] = icmp ne <2 x i8> [[XSIGN]], [[YPOSZ]]
1497
+ ; CHECK-NEXT: [[XOR_SIGNBITS:%.*]] = xor <2 x i8> [[X:%.*]], [[Y:%.*]]
1498
+ ; CHECK-NEXT: [[R:%.*]] = icmp sgt <2 x i8> [[XOR_SIGNBITS]], <i8 -1, i8 -1>
1504
1499
; CHECK-NEXT: ret <2 x i1> [[R]]
1505
1500
;
1506
1501
%xsign = ashr <2 x i8 > %x , <i8 7 , i8 7 >
@@ -1512,11 +1507,11 @@ define <2 x i1> @same_signbit_signed(<2 x i8> %x, <2 x i8> %y) {
1512
1507
1513
1508
define i1 @same_signbit_use2_signed (i8 %x , i8 %y ) {
1514
1509
; CHECK-LABEL: @same_signbit_use2_signed(
1515
- ; CHECK-NEXT: [[XSIGN:%.*]] = ashr i8 [[X:%.*]], 7
1516
1510
; CHECK-NEXT: [[YPOS:%.*]] = icmp sgt i8 [[Y:%.*]], -1
1517
1511
; CHECK-NEXT: [[YPOSZ:%.*]] = sext i1 [[YPOS]] to i8
1518
1512
; CHECK-NEXT: call void @use(i8 [[YPOSZ]])
1519
- ; CHECK-NEXT: [[R:%.*]] = icmp ne i8 [[XSIGN]], [[YPOSZ]]
1513
+ ; CHECK-NEXT: [[XOR_SIGNBITS:%.*]] = xor i8 [[X:%.*]], [[Y]]
1514
+ ; CHECK-NEXT: [[R:%.*]] = icmp sgt i8 [[XOR_SIGNBITS]], -1
1520
1515
; CHECK-NEXT: ret i1 [[R]]
1521
1516
;
1522
1517
%xsign = ashr i8 %x , 7
@@ -1527,6 +1522,8 @@ define i1 @same_signbit_use2_signed(i8 %x, i8 %y) {
1527
1522
ret i1 %r
1528
1523
}
1529
1524
1525
+ ; negative test
1526
+
1530
1527
define i1 @same_signbit_use3_signed (i8 %x , i8 %y ) {
1531
1528
; CHECK-LABEL: @same_signbit_use3_signed(
1532
1529
; CHECK-NEXT: [[XSIGN:%.*]] = ashr i8 [[X:%.*]], 7
@@ -1548,10 +1545,8 @@ define i1 @same_signbit_use3_signed(i8 %x, i8 %y) {
1548
1545
1549
1546
define <2 x i1 > @same_signbit_poison_elts_signed (<2 x i8 > %x , <2 x i8 > %y ) {
1550
1547
; CHECK-LABEL: @same_signbit_poison_elts_signed(
1551
- ; CHECK-NEXT: [[XSIGN:%.*]] = ashr <2 x i8> [[X:%.*]], <i8 7, i8 poison>
1552
- ; CHECK-NEXT: [[YPOS:%.*]] = icmp sgt <2 x i8> [[Y:%.*]], <i8 -1, i8 poison>
1553
- ; CHECK-NEXT: [[YPOSZ:%.*]] = sext <2 x i1> [[YPOS]] to <2 x i8>
1554
- ; CHECK-NEXT: [[R:%.*]] = icmp ne <2 x i8> [[XSIGN]], [[YPOSZ]]
1548
+ ; CHECK-NEXT: [[XOR_SIGNBITS:%.*]] = xor <2 x i8> [[X:%.*]], [[Y:%.*]]
1549
+ ; CHECK-NEXT: [[R:%.*]] = icmp sgt <2 x i8> [[XOR_SIGNBITS]], <i8 -1, i8 -1>
1555
1550
; CHECK-NEXT: ret <2 x i1> [[R]]
1556
1551
;
1557
1552
%xsign = ashr <2 x i8 > %x , <i8 7 , i8 poison>
@@ -1561,6 +1556,8 @@ define <2 x i1> @same_signbit_poison_elts_signed(<2 x i8> %x, <2 x i8> %y) {
1561
1556
ret <2 x i1 > %r
1562
1557
}
1563
1558
1559
+ ; negative test
1560
+
1564
1561
define i1 @same_signbit_wrong_type_signed (i8 %x , i32 %y ) {
1565
1562
; CHECK-LABEL: @same_signbit_wrong_type_signed(
1566
1563
; CHECK-NEXT: [[XSIGN:%.*]] = ashr i8 [[X:%.*]], 7
@@ -1576,6 +1573,8 @@ define i1 @same_signbit_wrong_type_signed(i8 %x, i32 %y) {
1576
1573
ret i1 %r
1577
1574
}
1578
1575
1576
+ ; negative test
1577
+
1579
1578
define i1 @exactly_one_set_signbit_wrong_shamt_signed (i8 %x , i8 %y ) {
1580
1579
; CHECK-LABEL: @exactly_one_set_signbit_wrong_shamt_signed(
1581
1580
; CHECK-NEXT: [[XSIGN:%.*]] = ashr i8 [[X:%.*]], 6
0 commit comments