@@ -1439,25 +1439,26 @@ IEEEFloat::opStatus IEEEFloat::addOrSubtractSpecials(const IEEEFloat &rhs,
1439
1439
default :
1440
1440
llvm_unreachable (nullptr );
1441
1441
1442
+ case PackCategoriesIntoKey (fcZero, fcNaN):
1443
+ case PackCategoriesIntoKey (fcNormal, fcNaN):
1444
+ case PackCategoriesIntoKey (fcInfinity, fcNaN):
1445
+ assign (rhs);
1446
+ LLVM_FALLTHROUGH;
1442
1447
case PackCategoriesIntoKey (fcNaN, fcZero):
1443
1448
case PackCategoriesIntoKey (fcNaN, fcNormal):
1444
1449
case PackCategoriesIntoKey (fcNaN, fcInfinity):
1445
1450
case PackCategoriesIntoKey (fcNaN, fcNaN):
1451
+ if (isSignaling ()) {
1452
+ makeQuiet ();
1453
+ return opInvalidOp;
1454
+ }
1455
+ return rhs.isSignaling () ? opInvalidOp : opOK;
1456
+
1446
1457
case PackCategoriesIntoKey (fcNormal, fcZero):
1447
1458
case PackCategoriesIntoKey (fcInfinity, fcNormal):
1448
1459
case PackCategoriesIntoKey (fcInfinity, fcZero):
1449
1460
return opOK;
1450
1461
1451
- case PackCategoriesIntoKey (fcZero, fcNaN):
1452
- case PackCategoriesIntoKey (fcNormal, fcNaN):
1453
- case PackCategoriesIntoKey (fcInfinity, fcNaN):
1454
- // We need to be sure to flip the sign here for subtraction because we
1455
- // don't have a separate negate operation so -NaN becomes 0 - NaN here.
1456
- sign = rhs.sign ^ subtract;
1457
- category = fcNaN;
1458
- copySignificand (rhs);
1459
- return opOK;
1460
-
1461
1462
case PackCategoriesIntoKey (fcNormal, fcInfinity):
1462
1463
case PackCategoriesIntoKey (fcZero, fcInfinity):
1463
1464
category = fcInfinity;
@@ -1562,20 +1563,22 @@ IEEEFloat::opStatus IEEEFloat::multiplySpecials(const IEEEFloat &rhs) {
1562
1563
default :
1563
1564
llvm_unreachable (nullptr );
1564
1565
1565
- case PackCategoriesIntoKey (fcNaN, fcZero):
1566
- case PackCategoriesIntoKey (fcNaN, fcNormal):
1567
- case PackCategoriesIntoKey (fcNaN, fcInfinity):
1568
- case PackCategoriesIntoKey (fcNaN, fcNaN):
1569
- sign = false ;
1570
- return opOK;
1571
-
1572
1566
case PackCategoriesIntoKey (fcZero, fcNaN):
1573
1567
case PackCategoriesIntoKey (fcNormal, fcNaN):
1574
1568
case PackCategoriesIntoKey (fcInfinity, fcNaN):
1569
+ assign (rhs);
1575
1570
sign = false ;
1576
- category = fcNaN;
1577
- copySignificand (rhs);
1578
- return opOK;
1571
+ LLVM_FALLTHROUGH;
1572
+ case PackCategoriesIntoKey (fcNaN, fcZero):
1573
+ case PackCategoriesIntoKey (fcNaN, fcNormal):
1574
+ case PackCategoriesIntoKey (fcNaN, fcInfinity):
1575
+ case PackCategoriesIntoKey (fcNaN, fcNaN):
1576
+ sign ^= rhs.sign ; // restore the original sign
1577
+ if (isSignaling ()) {
1578
+ makeQuiet ();
1579
+ return opInvalidOp;
1580
+ }
1581
+ return rhs.isSignaling () ? opInvalidOp : opOK;
1579
1582
1580
1583
case PackCategoriesIntoKey (fcNormal, fcInfinity):
1581
1584
case PackCategoriesIntoKey (fcInfinity, fcNormal):
@@ -1607,15 +1610,20 @@ IEEEFloat::opStatus IEEEFloat::divideSpecials(const IEEEFloat &rhs) {
1607
1610
case PackCategoriesIntoKey (fcZero, fcNaN):
1608
1611
case PackCategoriesIntoKey (fcNormal, fcNaN):
1609
1612
case PackCategoriesIntoKey (fcInfinity, fcNaN):
1610
- category = fcNaN ;
1611
- copySignificand (rhs) ;
1613
+ assign (rhs) ;
1614
+ sign = false ;
1612
1615
LLVM_FALLTHROUGH;
1613
1616
case PackCategoriesIntoKey (fcNaN, fcZero):
1614
1617
case PackCategoriesIntoKey (fcNaN, fcNormal):
1615
1618
case PackCategoriesIntoKey (fcNaN, fcInfinity):
1616
1619
case PackCategoriesIntoKey (fcNaN, fcNaN):
1617
- sign = false ;
1618
- LLVM_FALLTHROUGH;
1620
+ sign ^= rhs.sign ; // restore the original sign
1621
+ if (isSignaling ()) {
1622
+ makeQuiet ();
1623
+ return opInvalidOp;
1624
+ }
1625
+ return rhs.isSignaling () ? opInvalidOp : opOK;
1626
+
1619
1627
case PackCategoriesIntoKey (fcInfinity, fcZero):
1620
1628
case PackCategoriesIntoKey (fcInfinity, fcNormal):
1621
1629
case PackCategoriesIntoKey (fcZero, fcInfinity):
@@ -1645,23 +1653,26 @@ IEEEFloat::opStatus IEEEFloat::modSpecials(const IEEEFloat &rhs) {
1645
1653
default :
1646
1654
llvm_unreachable (nullptr );
1647
1655
1656
+ case PackCategoriesIntoKey (fcZero, fcNaN):
1657
+ case PackCategoriesIntoKey (fcNormal, fcNaN):
1658
+ case PackCategoriesIntoKey (fcInfinity, fcNaN):
1659
+ assign (rhs);
1660
+ LLVM_FALLTHROUGH;
1648
1661
case PackCategoriesIntoKey (fcNaN, fcZero):
1649
1662
case PackCategoriesIntoKey (fcNaN, fcNormal):
1650
1663
case PackCategoriesIntoKey (fcNaN, fcInfinity):
1651
1664
case PackCategoriesIntoKey (fcNaN, fcNaN):
1665
+ if (isSignaling ()) {
1666
+ makeQuiet ();
1667
+ return opInvalidOp;
1668
+ }
1669
+ return rhs.isSignaling () ? opInvalidOp : opOK;
1670
+
1652
1671
case PackCategoriesIntoKey (fcZero, fcInfinity):
1653
1672
case PackCategoriesIntoKey (fcZero, fcNormal):
1654
1673
case PackCategoriesIntoKey (fcNormal, fcInfinity):
1655
1674
return opOK;
1656
1675
1657
- case PackCategoriesIntoKey (fcZero, fcNaN):
1658
- case PackCategoriesIntoKey (fcNormal, fcNaN):
1659
- case PackCategoriesIntoKey (fcInfinity, fcNaN):
1660
- sign = false ;
1661
- category = fcNaN;
1662
- copySignificand (rhs);
1663
- return opOK;
1664
-
1665
1676
case PackCategoriesIntoKey (fcNormal, fcZero):
1666
1677
case PackCategoriesIntoKey (fcInfinity, fcZero):
1667
1678
case PackCategoriesIntoKey (fcInfinity, fcNormal):
0 commit comments