From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37632) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4uc3-0003Id-Fw for qemu-devel@nongnu.org; Wed, 09 Jul 2014 12:21:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X4uby-0005HF-Fx for qemu-devel@nongnu.org; Wed, 09 Jul 2014 12:20:55 -0400 Received: from mail-pa0-x230.google.com ([2607:f8b0:400e:c03::230]:53437) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4uby-0005H1-An for qemu-devel@nongnu.org; Wed, 09 Jul 2014 12:20:50 -0400 Received: by mail-pa0-f48.google.com with SMTP id et14so9456495pad.21 for ; Wed, 09 Jul 2014 09:20:49 -0700 (PDT) Sender: Richard Henderson From: Richard Henderson Date: Wed, 9 Jul 2014 09:20:23 -0700 Message-Id: <1404922834-28169-8-git-send-email-rth@twiddle.net> In-Reply-To: <1404922834-28169-1-git-send-email-rth@twiddle.net> References: <1404922834-28169-1-git-send-email-rth@twiddle.net> Subject: [Qemu-devel] [PULL 07/18] target-alpha: Fix cvttq vs large integers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, viro@ZenIV.linux.org.uk The range +- 2**63 - 2**64 was returning the wrong truncated result. We also incorrectly signaled overflow for -2**63. Reported-by: Al Viro Signed-off-by: Richard Henderson --- target-alpha/fpu_helper.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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; -- 1.9.3