@@ -1462,3 +1462,131 @@ define i1 @exactly_one_set_signbit_wrong_pred(i8 %x, i8 %y) {
1462
1462
%r = icmp sgt i8 %xsign , %yposz
1463
1463
ret i1 %r
1464
1464
}
1465
+
1466
+ define i1 @exactly_one_set_signbit_signed (i8 %x , i8 %y ) {
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]]
1472
+ ; CHECK-NEXT: ret i1 [[R]]
1473
+ ;
1474
+ %xsign = ashr i8 %x , 7
1475
+ %ypos = icmp sgt i8 %y , -1
1476
+ %yposz = sext i1 %ypos to i8
1477
+ %r = icmp eq i8 %xsign , %yposz
1478
+ ret i1 %r
1479
+ }
1480
+
1481
+ define i1 @exactly_one_set_signbit_use1_signed (i8 %x , i8 %y ) {
1482
+ ; CHECK-LABEL: @exactly_one_set_signbit_use1_signed(
1483
+ ; CHECK-NEXT: [[XSIGN:%.*]] = ashr i8 [[X:%.*]], 7
1484
+ ; 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]]
1488
+ ; CHECK-NEXT: ret i1 [[R]]
1489
+ ;
1490
+ %xsign = ashr i8 %x , 7
1491
+ call void @use (i8 %xsign )
1492
+ %ypos = icmp sgt i8 %y , -1
1493
+ %yposz = sext i1 %ypos to i8
1494
+ %r = icmp eq i8 %xsign , %yposz
1495
+ ret i1 %r
1496
+ }
1497
+
1498
+ define <2 x i1 > @same_signbit_signed (<2 x i8 > %x , <2 x i8 > %y ) {
1499
+ ; 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]]
1504
+ ; CHECK-NEXT: ret <2 x i1> [[R]]
1505
+ ;
1506
+ %xsign = ashr <2 x i8 > %x , <i8 7 , i8 7 >
1507
+ %ypos = icmp sgt <2 x i8 > %y , <i8 -1 , i8 -1 >
1508
+ %yposz = sext <2 x i1 > %ypos to <2 x i8 >
1509
+ %r = icmp ne <2 x i8 > %xsign , %yposz
1510
+ ret <2 x i1 > %r
1511
+ }
1512
+
1513
+ define i1 @same_signbit_use2_signed (i8 %x , i8 %y ) {
1514
+ ; CHECK-LABEL: @same_signbit_use2_signed(
1515
+ ; CHECK-NEXT: [[XSIGN:%.*]] = ashr i8 [[X:%.*]], 7
1516
+ ; CHECK-NEXT: [[YPOS:%.*]] = icmp sgt i8 [[Y:%.*]], -1
1517
+ ; CHECK-NEXT: [[YPOSZ:%.*]] = sext i1 [[YPOS]] to i8
1518
+ ; CHECK-NEXT: call void @use(i8 [[YPOSZ]])
1519
+ ; CHECK-NEXT: [[R:%.*]] = icmp ne i8 [[XSIGN]], [[YPOSZ]]
1520
+ ; CHECK-NEXT: ret i1 [[R]]
1521
+ ;
1522
+ %xsign = ashr i8 %x , 7
1523
+ %ypos = icmp sgt i8 %y , -1
1524
+ %yposz = sext i1 %ypos to i8
1525
+ call void @use (i8 %yposz )
1526
+ %r = icmp ne i8 %xsign , %yposz
1527
+ ret i1 %r
1528
+ }
1529
+
1530
+ define i1 @same_signbit_use3_signed (i8 %x , i8 %y ) {
1531
+ ; CHECK-LABEL: @same_signbit_use3_signed(
1532
+ ; CHECK-NEXT: [[XSIGN:%.*]] = ashr i8 [[X:%.*]], 7
1533
+ ; CHECK-NEXT: call void @use(i8 [[XSIGN]])
1534
+ ; CHECK-NEXT: [[YPOS:%.*]] = icmp sgt i8 [[Y:%.*]], -1
1535
+ ; CHECK-NEXT: [[YPOSZ:%.*]] = sext i1 [[YPOS]] to i8
1536
+ ; CHECK-NEXT: call void @use(i8 [[YPOSZ]])
1537
+ ; CHECK-NEXT: [[R:%.*]] = icmp ne i8 [[XSIGN]], [[YPOSZ]]
1538
+ ; CHECK-NEXT: ret i1 [[R]]
1539
+ ;
1540
+ %xsign = ashr i8 %x , 7
1541
+ call void @use (i8 %xsign )
1542
+ %ypos = icmp sgt i8 %y , -1
1543
+ %yposz = sext i1 %ypos to i8
1544
+ call void @use (i8 %yposz )
1545
+ %r = icmp ne i8 %xsign , %yposz
1546
+ ret i1 %r
1547
+ }
1548
+
1549
+ define <2 x i1 > @same_signbit_poison_elts_signed (<2 x i8 > %x , <2 x i8 > %y ) {
1550
+ ; 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]]
1555
+ ; CHECK-NEXT: ret <2 x i1> [[R]]
1556
+ ;
1557
+ %xsign = ashr <2 x i8 > %x , <i8 7 , i8 poison>
1558
+ %ypos = icmp sgt <2 x i8 > %y , <i8 -1 , i8 poison>
1559
+ %yposz = sext <2 x i1 > %ypos to <2 x i8 >
1560
+ %r = icmp ne <2 x i8 > %xsign , %yposz
1561
+ ret <2 x i1 > %r
1562
+ }
1563
+
1564
+ define i1 @same_signbit_wrong_type_signed (i8 %x , i32 %y ) {
1565
+ ; CHECK-LABEL: @same_signbit_wrong_type_signed(
1566
+ ; CHECK-NEXT: [[XSIGN:%.*]] = ashr i8 [[X:%.*]], 7
1567
+ ; CHECK-NEXT: [[YPOS:%.*]] = icmp sgt i32 [[Y:%.*]], -1
1568
+ ; CHECK-NEXT: [[YPOSZ:%.*]] = sext i1 [[YPOS]] to i8
1569
+ ; CHECK-NEXT: [[R:%.*]] = icmp ne i8 [[XSIGN]], [[YPOSZ]]
1570
+ ; CHECK-NEXT: ret i1 [[R]]
1571
+ ;
1572
+ %xsign = ashr i8 %x , 7
1573
+ %ypos = icmp sgt i32 %y , -1
1574
+ %yposz = sext i1 %ypos to i8
1575
+ %r = icmp ne i8 %xsign , %yposz
1576
+ ret i1 %r
1577
+ }
1578
+
1579
+ define i1 @exactly_one_set_signbit_wrong_shamt_signed (i8 %x , i8 %y ) {
1580
+ ; CHECK-LABEL: @exactly_one_set_signbit_wrong_shamt_signed(
1581
+ ; CHECK-NEXT: [[XSIGN:%.*]] = ashr i8 [[X:%.*]], 6
1582
+ ; CHECK-NEXT: [[YPOS:%.*]] = icmp sgt i8 [[Y:%.*]], -1
1583
+ ; CHECK-NEXT: [[YPOSZ:%.*]] = sext i1 [[YPOS]] to i8
1584
+ ; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[XSIGN]], [[YPOSZ]]
1585
+ ; CHECK-NEXT: ret i1 [[R]]
1586
+ ;
1587
+ %xsign = ashr i8 %x , 6
1588
+ %ypos = icmp sgt i8 %y , -1
1589
+ %yposz = sext i1 %ypos to i8
1590
+ %r = icmp eq i8 %xsign , %yposz
1591
+ ret i1 %r
1592
+ }
0 commit comments