From patchwork Tue May 12 17:39:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 471468 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 7879B1400B7 for ; Wed, 13 May 2015 03:47:34 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=pRMelzU2; dkim-atps=neutral Received: from localhost ([::1]:44270 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YsEHE-0002jC-O3 for incoming@patchwork.ozlabs.org; Tue, 12 May 2015 13:47:32 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=3pC7nVsYXVtozDBu89hCZ3flPFR+hBm/2Ww2eLUS4WU=; b=pRMelzU2gbXjsOaPKkEs1dB64VukO1XygeHOd4rqs/qHX0B8B4KcPYzniCnNoZklWd VewYwvaHG6cbP6ULpVDMXZc6ZaEBqh3zNDZDFrxjLU84LZiabxD7URP2jRcnh9jteOab v5agyZyBhHYkhupE46V4iVxiL3OT/GNNM1vhBBiBXd8RgVbI9vVOo7TI/d4ZaWeQrUGB 6/TIHmLVUR47Co5r3XRcSoA20qI8kTSS0QC22eCmA5gH4Tgw3Nr0xbyZ2veFF28Ved2n OaecR0vvdrVvCY0k/tdCpvRd5dkQx4httpXugkRh7SnB5txdj90WHuAsF+GZp/iAKO2m Iw7A== X-Received: by 10.55.31.168 with SMTP id n40mr35910536qkh.56.1431452438692; 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) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 12 May 2015 10:39:39 -0700 Message-Id: <1431452387-20280-10-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1431452387-20280-1-git-send-email-rth@twiddle.net> References: <1431452387-20280-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c04::22b Subject: [Qemu-devel] [PATCH v2 09/17] target-alpha: Fix cvttq vs large integers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@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;