From patchwork Mon Aug 19 12:17:00 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: 171616 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp2944999ily; Mon, 19 Aug 2019 06:00:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqy+dYNUZE77JSSaS7JNCjboZTMWCcywacxrOxWuvZw9KkyiuCD5Slr/3lsjwRkam3x3w49W X-Received: by 2002:a50:f412:: with SMTP id r18mr25380722edm.47.1566219648836; Mon, 19 Aug 2019 06:00:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566219648; cv=none; d=google.com; s=arc-20160816; b=RG/v2Js9cQYvXCeE4T18loYSn+vLkxooxB7zUQI4RL2rop52vTKS+bEvlxxDSYvuc3 LURKEp23CCc3J+6bYjhgVxh9DPOkH2G2MLly0inY99i/vhcQnJFStjjv5pUGxXigQG87 4MKkevvea4kBoGnNo6JJQZteY6zCcllwOumFPT9C300ytDlwKSXz1lwicacQJheeFLpo bXMFqaoDqXiMuPNe3h2nBAdRtYayQYMazZaw5wrhCBlD3Ampds6ZMAAom3Dwr+x0BwE7 A7kCmEt3x+uhjmQyTRWTNK5vTdR65mkkTkJgSXeTH+y7A9XB+gRE3/IAD1xKwACYl3es m6Sg== 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=k3UlDFsnQKhnBccuJpDIK9/bUicL4SPZmPjZKiFlMRI=; b=iP+40C7w4k970aSTd4skekHBa1Z6xnwFzgR+Wr/khF7YLegR0FTu7++ms5H5Ufu2CR ICw2wYVX+cObAWkJ/R0vayuu/12tjPPeiWfrsrUR5Vtgzn8sRjFgNH/RX+FjdQdV+yoO Eb0SNUcX6YsaVELIe8Cdv9jrEXuG+QpXY+x58T/hG9CPaLNz5VZWU83P5oFCDbYgWNvU 9+8/WDeCCFWHyTmFZBy5jAazb1pe8FkyvWqF1cUdFTNV+UhkLeoqsx/+OCQxewJzYIer CrgR61nloLNnCaLv9cQyWpafmTdJw2JuVc3+4iRVtRy6P8TKn2nNOnwH51CXzsELdfZQ E0kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GsmkgQV9; 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 y56si8170792edd.71.2019.08.19.06.00.48 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 19 Aug 2019 06:00:48 -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=GsmkgQV9; 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]:49812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzhHC-0005B6-TO for patch@linaro.org; Mon, 19 Aug 2019 09:00:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37857) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzgbG-000389-K2 for qemu-devel@nongnu.org; Mon, 19 Aug 2019 08:17:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzgbE-0007ER-9S for qemu-devel@nongnu.org; Mon, 19 Aug 2019 08:17:26 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:41874) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hzgbE-00078B-1a for qemu-devel@nongnu.org; Mon, 19 Aug 2019 08:17:24 -0400 Received: by mail-wr1-x444.google.com with SMTP id j16so8477483wrr.8 for ; Mon, 19 Aug 2019 05:17:14 -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=k3UlDFsnQKhnBccuJpDIK9/bUicL4SPZmPjZKiFlMRI=; b=GsmkgQV9cB9i6VvsW3N6TAByakFsP5lq6ktrMwG8mEv8ZnSk8oIHGLhRF7txUwDuUL pN79IVGXIiPfaLrJi9+3ZjM57X6ib3uMCBjd5MjbUmlmlQGp4i79Ki8SVAavCNV2u5tl 4FJYDUOGVnvH3QeRD6W7J8dP2wuitbLXEvFBN2kJJaEvqOSDzHkF3EL/1g2UK5HMwsCC yqn+PPUKSIyFR9Za79SIN/AmZzywTlJeh3dnTRMdE9lWQ7AqIkKuBVDrDLmc/+2o05XQ hBTjPH+jJW0x+rLGv5RFT8hqUqfjt4d5hfQ75aRs0JVA15gk/S18ACz0C8fWl37K3ESM vQxw== 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=k3UlDFsnQKhnBccuJpDIK9/bUicL4SPZmPjZKiFlMRI=; b=KAx6QHWU2WN6EQInLUn1Z986RZl1gQVFkYPn/d8cmk7aVd9yam0I/rsEXwFam8H+Bv SqOr+6WYXrTZdFa2VC+W0+mwavaFkuCpkoIW+fXQrnJ3m0bt+Z/sV5Ik1HuM7XIgeAEV +uH9GciJMiEZX7eBC2/ru+gV+CaUUPbx3q6atKr2Tc9gA/7CcWEB/WzTiEl1aA4YMzEq m/Zfvgn7Oc84d0AHcpp4nZLo9zQGiP7n4C7zcFTXKnzOlxF82YMzvEmYR+4e/kOv2SOx gmm/Z8L8VH55fwwO34nkTkLmWEOQ1clumjELs7LBTVnZW/wlvBKm10l1ZIBEJPFZ56N4 1K6Q== X-Gm-Message-State: APjAAAWnNMBTmfMb463/JUDovDQ42q0VWqarsOuouFh2peJIEasHE45F uUAYPaFigLyfp74nufw8hN+si4MBo2E= X-Received: by 2002:a5d:6392:: with SMTP id p18mr28364860wru.330.1566217033041; Mon, 19 Aug 2019 05:17:13 -0700 (PDT) Received: from zen.linaroharston ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id a19sm48058356wra.2.2019.08.19.05.17.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2019 05:17:11 -0700 (PDT) Received: from zen.linaroharston. (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 2DB101FF90; Mon, 19 Aug 2019 13:17:10 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Mon, 19 Aug 2019 13:17:00 +0100 Message-Id: <20190819121709.31597-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190819121709.31597-1-alex.bennee@linaro.org> References: <20190819121709.31597-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::444 Subject: [Qemu-devel] [PULL 03/12] 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: Richard Henderson , =?utf-8?q?Alex_Benn?= =?utf-8?b?w6ll?= , qemu-devel@nongnu.org, 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 Reviewed-by: Richard Henderson -- 2.20.1 diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 53855892b9f..d2cdf4a4a3b 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -3384,7 +3384,7 @@ static int32_t roundAndPackInt32(flag zSign, uint64_t absZ, float_status *status if ( zSign ) z = - z; if ( ( absZ>>32 ) || ( z && ( ( z < 0 ) ^ zSign ) ) ) { float_raise(float_flag_invalid, status); - return zSign ? (int32_t) 0x80000000 : 0x7FFFFFFF; + return zSign ? INT32_MIN : INT32_MAX; } if (roundBits) { status->float_exception_flags |= float_flag_inexact; @@ -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 {