From nobody Mon Feb 9 20:31:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1565700775; cv=none; d=zoho.com; s=zohoarc; b=Uw/5dqDQHytYW8eUPM7RR+pfK/GO+/aUGo4A5Khfa2I8NXaD6XsZjijmS0G80cViutI1rNoTXwpzkA/KfP+92g+Lew7gIHyPPovlLjXukResWRwN4hupx01Pjt2f6mBLcM062zrQl1wp4brkMpimFa7uer7DTesA04lYN52Q/6M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565700775; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=PJTLOGYfOYJRlE+NNvZ7x6ubINqPg6f5ZRf9gomrPy8=; b=BTHZy8+LUUQ5DDatNsfOavhn2H04k13ZStEF3zME0K9CFHj328TLKh28WK0fZLMDl+X4H0zFDvdDcWINqmFNJfXO6KdLov4SpVEYdZ+DjCC8t1XETDA5FOSpDOCiORUmVxMEFysph4LKlfn9ADUuDitGmwfIX8uPMKY0JHYXZ3I= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1565700775923667.1803027679076; Tue, 13 Aug 2019 05:52:55 -0700 (PDT) Received: from localhost ([::1]:52018 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxWIJ-00080F-21 for importer@patchew.org; Tue, 13 Aug 2019 08:52:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53573) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxWFM-0002Gt-Vb for qemu-devel@nongnu.org; Tue, 13 Aug 2019 08:49:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hxWFL-0000fe-Ni for qemu-devel@nongnu.org; Tue, 13 Aug 2019 08:49:52 -0400 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]:51772) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hxWFL-0000eT-H7 for qemu-devel@nongnu.org; Tue, 13 Aug 2019 08:49:51 -0400 Received: by mail-wm1-x344.google.com with SMTP id 207so1397940wma.1 for ; Tue, 13 Aug 2019 05:49:51 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id i66sm1256285wmg.2.2019.08.13.05.49.47 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 13 Aug 2019 05:49:48 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 427931FF91; Tue, 13 Aug 2019 13:49:47 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PJTLOGYfOYJRlE+NNvZ7x6ubINqPg6f5ZRf9gomrPy8=; b=e0xDx/S+M8brLECdnB1pGQzGyowZzrKXfBiHHQMR/euElwOc3rAXwocxnoOf2MtGIl P/IXiYqyB7ou1CcgYtIVPfLof/BwfxnTWZBdIW/PpHiPe4o5VclQtpaPwqSval3dIDX7 7VW7AzIX7pU+H9hgFVKOwHX6MGegdk7nxHW2CNImzwfCs7MZ5SbQv7UlTR3VL+qQqcJZ qp2+g+tVcyywKYnHYCd5zym6T1sjA+uPwuN0Z9YGmA/r5Iy9QKJNEIaLvbmo/yQbcGY/ DwetfURFOs0Cw74owqWVRb3SgJvvh0dolNwYiwjBBmHU16+XihbApxxrNf/QTJ7A5EIE XXdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PJTLOGYfOYJRlE+NNvZ7x6ubINqPg6f5ZRf9gomrPy8=; b=URV47GowgMJfAml0QI1n5CmhJ+k03W8BumsyxaCLXwIqGUT/gZumdj1RV/HlZS0qxS PLjfyTWqTaqUrYMIFB21ZM0AxfCPlGfWGRMVytATxAsHvDXFQe2d2KQ2XFWy8T1JG5DN 4WHVkmk2huurD2LQ+FHVtytJzmITGl04WaheO1cTQe2J3PmtJFx1gLSQISDIxAnERMZq oyynQJvJYYvaP0B/SXAkc0Xo9Ouj1/A+066R0W1631xfAC3qkv4YLO3qWWO6r1UzDS2Y lfGdzC+yajBl4aW52IZTOeW0Z+9G6nczgH4nYHw5IYobdN+gar0iu44XAcAKddoG659R mEpQ== X-Gm-Message-State: APjAAAVsGD84sLtRsBHsB1+NydVmFVX1VJueZttUI0kK7dTJGBsl5w8/ DtnEaymZ5R8qCaoC4GrMxAk5yw== X-Google-Smtp-Source: APXvYqw6t3Ci5VubDx2993pPUOgES3uKBlsnW5r44hT64j2wxxD8dWth5ADtGPzS2nMRPvY4Mt1XRw== X-Received: by 2002:a7b:c775:: with SMTP id x21mr2969690wmk.97.1565700590465; Tue, 13 Aug 2019 05:49:50 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Tue, 13 Aug 2019 13:49:37 +0100 Message-Id: <20190813124946.25322-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190813124946.25322-1-alex.bennee@linaro.org> References: <20190813124946.25322-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::344 Subject: [Qemu-devel] [PATCH v3 04/13] fpu: use min/max values from stdint.h for integral overflow X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , armbru@redhat.com, Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Remove some more use of LIT64 while making the meaning more clear. We also avoid the need of casts as the results by definition fit into the return type. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Richard Henderson --- fpu/softfloat.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 9e57b7b5933..a1e1e9a8559 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -3444,9 +3444,7 @@ static int64_t roundAndPackInt64(flag zSign, uint64_t= absZ0, uint64_t absZ1, if ( z && ( ( z < 0 ) ^ zSign ) ) { overflow: float_raise(float_flag_invalid, status); - return - zSign ? (int64_t) LIT64( 0x8000000000000000 ) - : LIT64( 0x7FFFFFFFFFFFFFFF ); + return zSign ? INT64_MIN : INT64_MAX; } if (absZ1) { status->float_exception_flags |=3D float_flag_inexact; @@ -3497,7 +3495,7 @@ static int64_t roundAndPackUint64(flag zSign, uint64_= t absZ0, ++absZ0; if (absZ0 =3D=3D 0) { float_raise(float_flag_invalid, status); - return LIT64(0xFFFFFFFFFFFFFFFF); + return UINT64_MAX; } absZ0 &=3D ~(((uint64_t)(absZ1<<1) =3D=3D 0) & roundNearestEven); } @@ -5518,9 +5516,9 @@ int64_t floatx80_to_int64(floatx80 a, float_status *s= tatus) if ( shiftCount ) { float_raise(float_flag_invalid, status); if (!aSign || floatx80_is_any_nan(a)) { - return LIT64( 0x7FFFFFFFFFFFFFFF ); + return INT64_MAX; } - return (int64_t) LIT64( 0x8000000000000000 ); + return INT64_MIN; } aSigExtra =3D 0; } @@ -5561,10 +5559,10 @@ int64_t floatx80_to_int64_round_to_zero(floatx80 a,= float_status *status) if ( ( a.high !=3D 0xC03E ) || aSig ) { float_raise(float_flag_invalid, status); if ( ! aSign || ( ( aExp =3D=3D 0x7FFF ) && aSig ) ) { - return LIT64( 0x7FFFFFFFFFFFFFFF ); + return INT64_MAX; } } - return (int64_t) LIT64( 0x8000000000000000 ); + return INT64_MIN; } else if ( aExp < 0x3FFF ) { if (aExp | aSig) { @@ -6623,7 +6621,7 @@ int32_t float128_to_int32_round_to_zero(float128 a, f= loat_status *status) if ( ( z < 0 ) ^ aSign ) { invalid: float_raise(float_flag_invalid, status); - return aSign ? (int32_t) 0x80000000 : 0x7FFFFFFF; + return aSign ? INT32_MIN : INT32_MAX; } if ( ( aSig0<float_exception_flags |=3D float_flag_inexact; @@ -6662,9 +6660,9 @@ int64_t float128_to_int64(float128 a, float_status *s= tatus) && ( aSig1 || ( aSig0 !=3D LIT64( 0x0001000000000000= ) ) ) ) ) { - return LIT64( 0x7FFFFFFFFFFFFFFF ); + return INT64_MAX; } - return (int64_t) LIT64( 0x8000000000000000 ); + return INT64_MIN; } shortShift128Left( aSig0, aSig1, - shiftCount, &aSig0, &aSig1 ); } @@ -6710,10 +6708,10 @@ int64_t float128_to_int64_round_to_zero(float128 a,= float_status *status) else { float_raise(float_flag_invalid, status); if ( ! aSign || ( ( aExp =3D=3D 0x7FFF ) && ( aSig0 | aSig= 1 ) ) ) { - return LIT64( 0x7FFFFFFFFFFFFFFF ); + return INT64_MAX; } } - return (int64_t) LIT64( 0x8000000000000000 ); + return INT64_MIN; } z =3D ( aSig0<>( ( - shiftCount ) & 63 ) ); if ( (uint64_t) ( aSig1< 0x3FFE)) { float_raise(float_flag_invalid, status); if (float128_is_any_nan(a)) { - return LIT64(0xFFFFFFFFFFFFFFFF); + return UINT64_MAX; } else { return 0; } } if (aExp) { - aSig0 |=3D LIT64(0x0001000000000000); + aSig0 |=3D UINT64_C(0x0001000000000000); } shiftCount =3D 0x402F - aExp; if (shiftCount <=3D 0) { if (0x403E < aExp) { float_raise(float_flag_invalid, status); - return LIT64(0xFFFFFFFFFFFFFFFF); + return UINT64_MAX; } shortShift128Left(aSig0, aSig1, -shiftCount, &aSig0, &aSig1); } else { --=20 2.20.1