diff options
Diffstat (limited to 'include/math-emu/op-common.h')
-rw-r--r-- | include/math-emu/op-common.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/include/math-emu/op-common.h b/include/math-emu/op-common.h index 9696a5e2c437..6bdf8c61d221 100644 --- a/include/math-emu/op-common.h +++ b/include/math-emu/op-common.h | |||
@@ -685,7 +685,7 @@ do { \ | |||
685 | else \ | 685 | else \ |
686 | { \ | 686 | { \ |
687 | r = 0; \ | 687 | r = 0; \ |
688 | if (X##_s) \ | 688 | if (!X##_s) \ |
689 | r = ~r; \ | 689 | r = ~r; \ |
690 | } \ | 690 | } \ |
691 | FP_SET_EXCEPTION(FP_EX_INVALID); \ | 691 | FP_SET_EXCEPTION(FP_EX_INVALID); \ |
@@ -743,12 +743,17 @@ do { \ | |||
743 | } \ | 743 | } \ |
744 | else \ | 744 | else \ |
745 | { \ | 745 | { \ |
746 | int _lz0, _lz1; \ | ||
746 | if (X##_e <= -_FP_WORKBITS - 1) \ | 747 | if (X##_e <= -_FP_WORKBITS - 1) \ |
747 | _FP_FRAC_SET_##wc(X, _FP_MINFRAC_##wc); \ | 748 | _FP_FRAC_SET_##wc(X, _FP_MINFRAC_##wc); \ |
748 | else \ | 749 | else \ |
749 | _FP_FRAC_SRS_##wc(X, _FP_FRACBITS_##fs - 1 - X##_e, \ | 750 | _FP_FRAC_SRS_##wc(X, _FP_FRACBITS_##fs - 1 - X##_e, \ |
750 | _FP_WFRACBITS_##fs); \ | 751 | _FP_WFRACBITS_##fs); \ |
752 | _FP_FRAC_CLZ_##wc(_lz0, X); \ | ||
751 | _FP_ROUND(wc, X); \ | 753 | _FP_ROUND(wc, X); \ |
754 | _FP_FRAC_CLZ_##wc(_lz1, X); \ | ||
755 | if (_lz1 < _lz0) \ | ||
756 | X##_e++; /* For overflow detection. */ \ | ||
752 | _FP_FRAC_SRL_##wc(X, _FP_WORKBITS); \ | 757 | _FP_FRAC_SRL_##wc(X, _FP_WORKBITS); \ |
753 | _FP_FRAC_ASSEMBLE_##wc(r, X, rsize); \ | 758 | _FP_FRAC_ASSEMBLE_##wc(r, X, rsize); \ |
754 | } \ | 759 | } \ |
@@ -762,7 +767,7 @@ do { \ | |||
762 | if (!rsigned) \ | 767 | if (!rsigned) \ |
763 | { \ | 768 | { \ |
764 | r = 0; \ | 769 | r = 0; \ |
765 | if (X##_s) \ | 770 | if (!X##_s) \ |
766 | r = ~r; \ | 771 | r = ~r; \ |
767 | } \ | 772 | } \ |
768 | else if (rsigned != 2) \ | 773 | else if (rsigned != 2) \ |