From patchwork Tue Aug 13 12:49:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 171188 Delivered-To: patch@linaro.org Received: by 2002:ac9:5c4b:0:0:0:0:0 with SMTP id r11csp859611ocp; Tue, 13 Aug 2019 05:52:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBllmkxQpscio2SES57hVQOJ7F60km3LDVq7WcXv0DXVLjt+dbY4OylRfVZPJij+fVXQwS X-Received: by 2002:aa7:d48c:: with SMTP id b12mr2148022edr.170.1565700746359; Tue, 13 Aug 2019 05:52:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565700746; cv=none; d=google.com; s=arc-20160816; b=mDWyCqRbHj0OMwSoq1vvOfv9haTEyu6qck59A925+Hd8fk8pgdtUMr44AvmRuV6bpL i0t64eGin63HU1oAdqygSBhxNZxD0ZDv/zswwrq2FHTd1EnvWP2niRy8uZnFi5nkRJxx aLRBRYuzU+9PwsFmZRnap/bIO5bHmVvm0bZEeath465EAnAQrr0BHjglA3gbnD4i7nC/ ECop7jLTDHHFspCc18IjA7cAVPW1+/Q7gdPkAQXeMqZenScftqBZtu5gnuZNZyaiPqVR XYbbIN5cUbeHV9zJWHXXHe7pXSE6pY2xJKK3rMA+cWyVXtehhw3yEndVL934sAUkzPXd oQhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=PJTLOGYfOYJRlE+NNvZ7x6ubINqPg6f5ZRf9gomrPy8=; b=yDS/17TqMCmY+OXE9oBZAQLVuLkDJdk4tB+tUf9K4EOHWU1ZFFhtEr42AIJ/aPDNmC MFEcQNZaVc0pJapt8y3f/787KK1kNUwKe5CVqmwxDKXBFMR1gnYvVsowL+AOQOfwlhLm Hjj18NWXQOG0ZJcLsOCp0UrMFcoOTvIeO0kN6eimFl8JugqEHRlPPeexU5YsSxaiuEqa 3c5iqBbtIFLGshLQEo9PVOIk5PPfFgxmzDkJTW1r/yPvLY+Y+rjZFD3QRkaPXW/fQiVg bqI49HPx1ZBfMnSGWTIfK/Al/O1hodQ/8ou959KdyGJQCDtH6eachkhtVK9UVUQ4/oxu BCbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="e0xDx/S+"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r21si42337726eda.359.2019.08.13.05.52.26 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Aug 2019 05:52:26 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="e0xDx/S+"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:52012 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hxWHp-0006oo-CM for patch@linaro.org; Tue, 13 Aug 2019 08:52:25 -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) 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-Received: by 2002:a7b:c775:: with SMTP id x21mr2969690wmk.97.1565700590465; Tue, 13 Aug 2019 05:49:50 -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) From: =?utf-8?q?Alex_Benn=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 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_Benn=C3=A9e?= , armbru@redhat.com, Aurelien Jarno Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée --- fpu/softfloat.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) -- 2.20.1 Reviewed-by: Richard Henderson 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 |= float_flag_inexact; @@ -3497,7 +3495,7 @@ static int64_t roundAndPackUint64(flag zSign, uint64_t absZ0, ++absZ0; if (absZ0 == 0) { float_raise(float_flag_invalid, status); - return LIT64(0xFFFFFFFFFFFFFFFF); + return UINT64_MAX; } absZ0 &= ~(((uint64_t)(absZ1<<1) == 0) & roundNearestEven); } @@ -5518,9 +5516,9 @@ int64_t floatx80_to_int64(floatx80 a, float_status *status) 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 = 0; } @@ -5561,10 +5559,10 @@ int64_t floatx80_to_int64_round_to_zero(floatx80 a, float_status *status) if ( ( a.high != 0xC03E ) || aSig ) { float_raise(float_flag_invalid, status); if ( ! aSign || ( ( aExp == 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, float_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 |= float_flag_inexact; @@ -6662,9 +6660,9 @@ int64_t float128_to_int64(float128 a, float_status *status) && ( aSig1 || ( aSig0 != 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 == 0x7FFF ) && ( aSig0 | aSig1 ) ) ) { - return LIT64( 0x7FFFFFFFFFFFFFFF ); + return INT64_MAX; } } - return (int64_t) LIT64( 0x8000000000000000 ); + return INT64_MIN; } z = ( 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 |= LIT64(0x0001000000000000); + aSig0 |= UINT64_C(0x0001000000000000); } shiftCount = 0x402F - aExp; if (shiftCount <= 0) { if (0x403E < aExp) { float_raise(float_flag_invalid, status); - return LIT64(0xFFFFFFFFFFFFFFFF); + return UINT64_MAX; } shortShift128Left(aSig0, aSig1, -shiftCount, &aSig0, &aSig1); } else {