Commit 6c01bf6c7ba7539460fcaeb99fbe1776ba137aa8

Authored by aurel32
1 parent 1fd31ad7

target-ppc: fix fres, fsqrte and remove useless code

- fres and fsqrte should not assign a float32 number to a float64 value.
- fre, fres and fsqrte are checking for cases already taken into account
  by softfloat and softfloat native. Remove those useless tests.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6083 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 10 additions and 57 deletions
target-ppc/op_helper.c
@@ -563,18 +563,6 @@ static always_inline int isden (float64 d) @@ -563,18 +563,6 @@ static always_inline int isden (float64 d)
563 return ((u.ll >> 52) & 0x7FF) == 0; 563 return ((u.ll >> 52) & 0x7FF) == 0;
564 } 564 }
565 565
566 -#ifdef CONFIG_SOFTFLOAT  
567 -static always_inline int isnormal (float64 d)  
568 -{  
569 - CPU_DoubleU u;  
570 -  
571 - u.d = d;  
572 -  
573 - uint32_t exp = (u.ll >> 52) & 0x7FF;  
574 - return ((0 < exp) && (exp < 0x7FF));  
575 -}  
576 -#endif  
577 -  
578 uint32_t helper_compute_fprf (uint64_t arg, uint32_t set_fprf) 566 uint32_t helper_compute_fprf (uint64_t arg, uint32_t set_fprf)
579 { 567 {
580 CPU_DoubleU farg; 568 CPU_DoubleU farg;
@@ -1528,20 +1516,8 @@ uint64_t helper_fre (uint64_t arg) @@ -1528,20 +1516,8 @@ uint64_t helper_fre (uint64_t arg)
1528 } else if (unlikely(float64_is_zero(farg.d))) { 1516 } else if (unlikely(float64_is_zero(farg.d))) {
1529 /* Zero reciprocal */ 1517 /* Zero reciprocal */
1530 farg.ll = float_zero_divide_excp(fone.d, farg.d); 1518 farg.ll = float_zero_divide_excp(fone.d, farg.d);
1531 - } else if (likely(isnormal(farg.d))) {  
1532 - farg.d = float64_div(fone.d, farg.d, &env->fp_status);  
1533 } else { 1519 } else {
1534 - if (farg.ll == 0x8000000000000000ULL) {  
1535 - farg.ll = 0xFFF0000000000000ULL;  
1536 - } else if (farg.ll == 0x0000000000000000ULL) {  
1537 - farg.ll = 0x7FF0000000000000ULL;  
1538 - } else if (float64_is_nan(farg.d)) {  
1539 - farg.ll = 0x7FF8000000000000ULL;  
1540 - } else if (float64_is_neg(farg.d)) {  
1541 - farg.ll = 0x8000000000000000ULL;  
1542 - } else {  
1543 - farg.ll = 0x0000000000000000ULL;  
1544 - } 1520 + farg.d = float64_div(fone.d, farg.d, &env->fp_status);
1545 } 1521 }
1546 return farg.d; 1522 return farg.d;
1547 } 1523 }
@@ -1550,6 +1526,7 @@ uint64_t helper_fre (uint64_t arg) @@ -1550,6 +1526,7 @@ uint64_t helper_fre (uint64_t arg)
1550 uint64_t helper_fres (uint64_t arg) 1526 uint64_t helper_fres (uint64_t arg)
1551 { 1527 {
1552 CPU_DoubleU fone, farg; 1528 CPU_DoubleU fone, farg;
  1529 + float32 f32;
1553 fone.ll = 0x3FF0000000000000ULL; /* 1.0 */ 1530 fone.ll = 0x3FF0000000000000ULL; /* 1.0 */
1554 farg.ll = arg; 1531 farg.ll = arg;
1555 1532
@@ -1559,25 +1536,10 @@ uint64_t helper_fres (uint64_t arg) @@ -1559,25 +1536,10 @@ uint64_t helper_fres (uint64_t arg)
1559 } else if (unlikely(float64_is_zero(farg.d))) { 1536 } else if (unlikely(float64_is_zero(farg.d))) {
1560 /* Zero reciprocal */ 1537 /* Zero reciprocal */
1561 farg.ll = float_zero_divide_excp(fone.d, farg.d); 1538 farg.ll = float_zero_divide_excp(fone.d, farg.d);
1562 - } else if (likely(isnormal(farg.d))) {  
1563 -#if USE_PRECISE_EMULATION  
1564 - farg.d = float64_div(fone.d, farg.d, &env->fp_status);  
1565 - farg.d = float64_to_float32(farg.d, &env->fp_status);  
1566 -#else  
1567 - farg.d = float32_div(fone.d, farg.d, &env->fp_status);  
1568 -#endif  
1569 } else { 1539 } else {
1570 - if (farg.ll == 0x8000000000000000ULL) {  
1571 - farg.ll = 0xFFF0000000000000ULL;  
1572 - } else if (farg.ll == 0x0000000000000000ULL) {  
1573 - farg.ll = 0x7FF0000000000000ULL;  
1574 - } else if (float64_is_nan(farg.d)) {  
1575 - farg.ll = 0x7FF8000000000000ULL;  
1576 - } else if (float64_is_neg(farg.d)) {  
1577 - farg.ll = 0x8000000000000000ULL;  
1578 - } else {  
1579 - farg.ll = 0x0000000000000000ULL;  
1580 - } 1540 + farg.d = float64_div(fone.d, farg.d, &env->fp_status);
  1541 + f32 = float64_to_float32(farg.d, &env->fp_status);
  1542 + farg.d = float32_to_float64(f32, &env->fp_status);
1581 } 1543 }
1582 return farg.ll; 1544 return farg.ll;
1583 } 1545 }
@@ -1586,6 +1548,7 @@ uint64_t helper_fres (uint64_t arg) @@ -1586,6 +1548,7 @@ uint64_t helper_fres (uint64_t arg)
1586 uint64_t helper_frsqrte (uint64_t arg) 1548 uint64_t helper_frsqrte (uint64_t arg)
1587 { 1549 {
1588 CPU_DoubleU fone, farg; 1550 CPU_DoubleU fone, farg;
  1551 + float32 f32;
1589 fone.ll = 0x3FF0000000000000ULL; /* 1.0 */ 1552 fone.ll = 0x3FF0000000000000ULL; /* 1.0 */
1590 farg.ll = arg; 1553 farg.ll = arg;
1591 1554
@@ -1595,21 +1558,11 @@ uint64_t helper_frsqrte (uint64_t arg) @@ -1595,21 +1558,11 @@ uint64_t helper_frsqrte (uint64_t arg)
1595 } else if (unlikely(float64_is_neg(farg.d) && !float64_is_zero(farg.d))) { 1558 } else if (unlikely(float64_is_neg(farg.d) && !float64_is_zero(farg.d))) {
1596 /* Reciprocal square root of a negative nonzero number */ 1559 /* Reciprocal square root of a negative nonzero number */
1597 farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSQRT); 1560 farg.ll = fload_invalid_op_excp(POWERPC_EXCP_FP_VXSQRT);
1598 - } else if (likely(isnormal(farg.d))) {  
1599 - farg.d = float64_sqrt(farg.d, &env->fp_status);  
1600 - farg.d = float32_div(fone.d, farg.d, &env->fp_status);  
1601 } else { 1561 } else {
1602 - if (farg.ll == 0x8000000000000000ULL) {  
1603 - farg.ll = 0xFFF0000000000000ULL;  
1604 - } else if (farg.ll == 0x0000000000000000ULL) {  
1605 - farg.ll = 0x7FF0000000000000ULL;  
1606 - } else if (float64_is_nan(farg.d)) {  
1607 - farg.ll |= 0x000FFFFFFFFFFFFFULL;  
1608 - } else if (float64_is_neg(farg.d)) {  
1609 - farg.ll = 0x7FF8000000000000ULL;  
1610 - } else {  
1611 - farg.ll = 0x0000000000000000ULL;  
1612 - } 1562 + farg.d = float64_sqrt(farg.d, &env->fp_status);
  1563 + farg.d = float64_div(fone.d, farg.d, &env->fp_status);
  1564 + f32 = float64_to_float32(farg.d, &env->fp_status);
  1565 + farg.d = float32_to_float64(f32, &env->fp_status);
1613 } 1566 }
1614 return farg.ll; 1567 return farg.ll;
1615 } 1568 }