diff mbox

[PULL,07/18] target-alpha: Fix cvttq vs large integers

Message ID 1404922834-28169-8-git-send-email-rth@twiddle.net
State New
Headers show

Commit Message

Richard Henderson July 9, 2014, 4:20 p.m. UTC
The range +- 2**63 - 2**64 was returning the wrong truncated
result.  We also incorrectly signaled overflow for -2**63.

Reported-by: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 target-alpha/fpu_helper.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/target-alpha/fpu_helper.c b/target-alpha/fpu_helper.c
index 19f3ebc..2b6c96b 100644
--- a/target-alpha/fpu_helper.c
+++ b/target-alpha/fpu_helper.c
@@ -721,12 +721,12 @@  static inline uint64_t inline_cvttq(CPUAlphaState *env, uint64_t a,
         if (shift >= 0) {
             /* In this case the number is so large that we must shift
                the fraction left.  There is no rounding to do.  */
-            exc = float_flag_int_overflow | float_flag_inexact;
-            if (shift < 63) {
+            if (shift < 64) {
                 ret = frac << shift;
-                if ((ret >> shift) == frac) {
-                    exc = 0;
-                }
+            }
+            /* Check for overflow.  Note the special case of -0x1p63.  */
+            if (shift >= 11 && a != 0xC3E0000000000000ull) {
+                exc = float_flag_int_overflow | float_flag_inexact;
             }
         } else {
             uint64_t round;