From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52178) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YsEAb-0007jl-Bj for qemu-devel@nongnu.org; Tue, 12 May 2015 13:40:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YsEAZ-0007i7-4q for qemu-devel@nongnu.org; Tue, 12 May 2015 13:40:41 -0400 Received: from mail-qg0-x22b.google.com ([2607:f8b0:400d:c04::22b]:36559) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YsEAZ-0007i2-0P for qemu-devel@nongnu.org; Tue, 12 May 2015 13:40:39 -0400 Received: by qgeb100 with SMTP id b100so8210580qge.3 for ; Tue, 12 May 2015 10:40:38 -0700 (PDT) Received: from anchor.com (50-194-63-110-static.hfc.comcastbusiness.net. [50.194.63.110]) by mx.google.com with ESMTPSA id f4sm13701736qhe.9.2015.05.12.10.40.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 May 2015 10:40:38 -0700 (PDT) Sender: Richard Henderson From: Richard Henderson Date: Tue, 12 May 2015 10:39:39 -0700 Message-Id: <1431452387-20280-10-git-send-email-rth@twiddle.net> In-Reply-To: <1431452387-20280-1-git-send-email-rth@twiddle.net> References: <1431452387-20280-1-git-send-email-rth@twiddle.net> Subject: [Qemu-devel] [PATCH v2 09/17] target-alpha: Fix cvttq vs large integers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 132b5a2..9449c57 100644 --- a/target-alpha/fpu_helper.c +++ b/target-alpha/fpu_helper.c @@ -453,12 +453,12 @@ static uint64_t do_cvttq(CPUAlphaState *env, uint64_t a, int roundmode) 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 = FPCR_IOV | FPCR_INE; - 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 = FPCR_IOV | FPCR_INE; } } else { uint64_t round; -- 2.1.0