From nobody Fri Oct 10 15:41:04 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1589907416; cv=none; d=zohomail.com; s=zohoarc; b=JcqKCWFqxGsZ1bkzt96CV0ATfs9/NrtCb94RV30OcDcGO9y0QpndIlMEXCbzef6WX+3Muq1roqtsopUPh7ZGN4U4gpBXRwXOfaBh+HOX60cm6pf4nYcMUyeqLmJGf8AdeG0NAReRFnU7RMHvWjmbBEYvi1xGptHr9D6/Jy1Roi8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589907416; 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; bh=kNlqzG9j9TNbuizhAMOReFcBx2wA4AcU7iptAzdhd4c=; b=dwBubxrIKEoMztPbnd0DM6Jx4n9h+qDtlcbzUCx5ibaY+Y6a+w517d/mnJrH1u45pMFoNsg9dRKm6keVi6M6y9Ifo9pKmn4g8Ml/CxSYdEnuXJrKFW+Txg+w/nofh4ipJVR7JrtP7DEN8Z2iKIcdDcc3npIGbAB5yRMVQa1pUWc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass 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 1589907416677333.2267699870257; Tue, 19 May 2020 09:56:56 -0700 (PDT) Received: from localhost ([::1]:49278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jb5Xy-00082m-CP for importer@patchew.org; Tue, 19 May 2020 12:56:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59708) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jb5RZ-0004u4-A0 for qemu-devel@nongnu.org; Tue, 19 May 2020 12:50:17 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]:44701) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jb5RX-0006Gr-NY for qemu-devel@nongnu.org; Tue, 19 May 2020 12:50:16 -0400 Received: by mail-pf1-x42a.google.com with SMTP id x13so165388pfn.11 for ; Tue, 19 May 2020 09:50:15 -0700 (PDT) Received: from localhost.localdomain (174-21-143-238.tukw.qwest.net. [174.21.143.238]) by smtp.gmail.com with ESMTPSA id gx21sm96685pjb.47.2020.05.19.09.50.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 09:50:11 -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=kNlqzG9j9TNbuizhAMOReFcBx2wA4AcU7iptAzdhd4c=; b=K9XThOdM2qki0p4eSKo/TjWK5i8llR2a9Ik4dUYJwsWw+AIgLok7BweL6v8VPq47Oz 7y11dF9bMu3b/N1lgbJ7mSFdiIMjNJye6i8dDgtaV4ikhyxoz0xowMPj8wSOKK9MexA4 7F3o559dNvzDXcniJQPq3zeceCi8yAqf5ml1fxXqOudp0uYoRxf6resV6PcldM+nco/r Hox9KrMmOG6OCEu8YK+cmlviPvZQsSErWCjHZ7Sl3ecrKv136dipmR/HYp47T8MUkLb9 AYpxnHU+f1BSpsRBRojwKYNm8endMDspXCJdrTE7aEbA5KF/4K2o7u4bS25v2n0y23Fr LAag== 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=kNlqzG9j9TNbuizhAMOReFcBx2wA4AcU7iptAzdhd4c=; b=frpWmT5Hwshx80NId2mcR/R+SCMZJKmDKmAdUhiJbB/1pUNtIoinaDx/WUL8KlSleH //OEoQMX2qUcqfeVoeXG+Q1fL5cznB99AHRfvsP+zp2lsUgXJSI7DAhYfI2H+QxdXDSy 48C0RcVygux6Anr0xyDW/Ug+pd+Iq3lFMoyD5zM6z//C5UGLFmE9zCKHHpppNxMaUnew k9JkFc6FTNLTSuJJDFbO/SJhMo3YcZKv140d5+2QVBT2SNUeSUHE1nSJpgF44LJjENsX WavUHC+h8cL9EzOZBLXuMzhpOhCevdIVb1LmjYisHQUnmPmyeHddktJCdeA0fE+/ZOE+ m42g== X-Gm-Message-State: AOAM530UmfQA7v8fqhpwp2ADdcicxSVsYL/k09/4V6rcd2RxQKb1GjRM ucXZC44AAkTY3IvY56Nr7hHVkmLqYZs= X-Google-Smtp-Source: ABdhPJzUWQYIYbUz1o9avLHgbIWcVPUTkSg9kHlL4lgXGmhAO3ZWcY/ODQBJ+hH2WJ3i9yzqqbwLwA== X-Received: by 2002:a63:da50:: with SMTP id l16mr127810pgj.198.1589907013552; Tue, 19 May 2020 09:50:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 09/10] softfloat: Inline floatx80 compare specializations Date: Tue, 19 May 2020 09:49:56 -0700 Message-Id: <20200519164957.26920-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200519164957.26920-1-richard.henderson@linaro.org> References: <20200519164957.26920-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2607:f8b0:4864:20::42a; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42a.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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@linaro.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @linaro.org) Replace the floatx80 compare specializations with inline functions that call the standard floatx80_compare{,_quiet} functions. Use bool as the return type. Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Richard Henderson --- include/fpu/softfloat.h | 49 ++++++-- fpu/softfloat.c | 257 ---------------------------------------- 2 files changed, 41 insertions(+), 265 deletions(-) diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index cfb3cda46b..37217d9b9b 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -689,14 +689,6 @@ floatx80 floatx80_mul(floatx80, floatx80, float_status= *status); floatx80 floatx80_div(floatx80, floatx80, float_status *status); floatx80 floatx80_rem(floatx80, floatx80, float_status *status); floatx80 floatx80_sqrt(floatx80, float_status *status); -int floatx80_eq(floatx80, floatx80, float_status *status); -int floatx80_le(floatx80, floatx80, float_status *status); -int floatx80_lt(floatx80, floatx80, float_status *status); -int floatx80_unordered(floatx80, floatx80, float_status *status); -int floatx80_eq_quiet(floatx80, floatx80, float_status *status); -int floatx80_le_quiet(floatx80, floatx80, float_status *status); -int floatx80_lt_quiet(floatx80, floatx80, float_status *status); -int floatx80_unordered_quiet(floatx80, floatx80, float_status *status); FloatRelation floatx80_compare(floatx80, floatx80, float_status *status); FloatRelation floatx80_compare_quiet(floatx80, floatx80, float_status *sta= tus); int floatx80_is_quiet_nan(floatx80, float_status *status); @@ -746,6 +738,47 @@ static inline int floatx80_is_any_nan(floatx80 a) return ((a.high & 0x7fff) =3D=3D 0x7fff) && (a.low<<1); } =20 +static inline bool floatx80_eq(floatx80 a, floatx80 b, float_status *s) +{ + return floatx80_compare(a, b, s) =3D=3D float_relation_equal; +} + +static inline bool floatx80_le(floatx80 a, floatx80 b, float_status *s) +{ + return floatx80_compare(a, b, s) <=3D float_relation_equal; +} + +static inline bool floatx80_lt(floatx80 a, floatx80 b, float_status *s) +{ + return floatx80_compare(a, b, s) < float_relation_equal; +} + +static inline bool floatx80_unordered(floatx80 a, floatx80 b, float_status= *s) +{ + return floatx80_compare(a, b, s) =3D=3D float_relation_unordered; +} + +static inline bool floatx80_eq_quiet(floatx80 a, floatx80 b, float_status = *s) +{ + return floatx80_compare_quiet(a, b, s) =3D=3D float_relation_equal; +} + +static inline bool floatx80_le_quiet(floatx80 a, floatx80 b, float_status = *s) +{ + return floatx80_compare_quiet(a, b, s) <=3D float_relation_equal; +} + +static inline bool floatx80_lt_quiet(floatx80 a, floatx80 b, float_status = *s) +{ + return floatx80_compare_quiet(a, b, s) < float_relation_equal; +} + +static inline bool floatx80_unordered_quiet(floatx80 a, floatx80 b, + float_status *s) +{ + return floatx80_compare_quiet(a, b, s) =3D=3D float_relation_unordered; +} + /*------------------------------------------------------------------------= ---- | Return whether the given value is an invalid floatx80 encoding. | Invalid floatx80 encodings arise when the integer bit is not set, but diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 4567dda112..6c8f2d597a 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -5849,263 +5849,6 @@ floatx80 floatx80_sqrt(floatx80 a, float_status *st= atus) 0, zExp, zSig0, zSig1, status); } =20 -/*------------------------------------------------------------------------= ---- -| Returns 1 if the extended double-precision floating-point value `a' is e= qual -| to the corresponding value `b', and 0 otherwise. The invalid exception = is -| raised if either operand is a NaN. Otherwise, the comparison is perform= ed -| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. -*-------------------------------------------------------------------------= ---*/ - -int floatx80_eq(floatx80 a, floatx80 b, float_status *status) -{ - - if (floatx80_invalid_encoding(a) || floatx80_invalid_encoding(b) - || (extractFloatx80Exp(a) =3D=3D 0x7FFF - && (uint64_t) (extractFloatx80Frac(a) << 1)) - || (extractFloatx80Exp(b) =3D=3D 0x7FFF - && (uint64_t) (extractFloatx80Frac(b) << 1)) - ) { - float_raise(float_flag_invalid, status); - return 0; - } - return - ( a.low =3D=3D b.low ) - && ( ( a.high =3D=3D b.high ) - || ( ( a.low =3D=3D 0 ) - && ( (uint16_t) ( ( a.high | b.high )<<1 ) =3D=3D 0 ) ) - ); - -} - -/*------------------------------------------------------------------------= ---- -| Returns 1 if the extended double-precision floating-point value `a' is -| less than or equal to the corresponding value `b', and 0 otherwise. The -| invalid exception is raised if either operand is a NaN. The comparison = is -| performed according to the IEC/IEEE Standard for Binary Floating-Point -| Arithmetic. -*-------------------------------------------------------------------------= ---*/ - -int floatx80_le(floatx80 a, floatx80 b, float_status *status) -{ - bool aSign, bSign; - - if (floatx80_invalid_encoding(a) || floatx80_invalid_encoding(b) - || (extractFloatx80Exp(a) =3D=3D 0x7FFF - && (uint64_t) (extractFloatx80Frac(a) << 1)) - || (extractFloatx80Exp(b) =3D=3D 0x7FFF - && (uint64_t) (extractFloatx80Frac(b) << 1)) - ) { - float_raise(float_flag_invalid, status); - return 0; - } - aSign =3D extractFloatx80Sign( a ); - bSign =3D extractFloatx80Sign( b ); - if ( aSign !=3D bSign ) { - return - aSign - || ( ( ( (uint16_t) ( ( a.high | b.high )<<1 ) ) | a.low | = b.low ) - =3D=3D 0 ); - } - return - aSign ? le128( b.high, b.low, a.high, a.low ) - : le128( a.high, a.low, b.high, b.low ); - -} - -/*------------------------------------------------------------------------= ---- -| Returns 1 if the extended double-precision floating-point value `a' is -| less than the corresponding value `b', and 0 otherwise. The invalid -| exception is raised if either operand is a NaN. The comparison is perfo= rmed -| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. -*-------------------------------------------------------------------------= ---*/ - -int floatx80_lt(floatx80 a, floatx80 b, float_status *status) -{ - bool aSign, bSign; - - if (floatx80_invalid_encoding(a) || floatx80_invalid_encoding(b) - || (extractFloatx80Exp(a) =3D=3D 0x7FFF - && (uint64_t) (extractFloatx80Frac(a) << 1)) - || (extractFloatx80Exp(b) =3D=3D 0x7FFF - && (uint64_t) (extractFloatx80Frac(b) << 1)) - ) { - float_raise(float_flag_invalid, status); - return 0; - } - aSign =3D extractFloatx80Sign( a ); - bSign =3D extractFloatx80Sign( b ); - if ( aSign !=3D bSign ) { - return - aSign - && ( ( ( (uint16_t) ( ( a.high | b.high )<<1 ) ) | a.low | = b.low ) - !=3D 0 ); - } - return - aSign ? lt128( b.high, b.low, a.high, a.low ) - : lt128( a.high, a.low, b.high, b.low ); - -} - -/*------------------------------------------------------------------------= ---- -| Returns 1 if the extended double-precision floating-point values `a' and= `b' -| cannot be compared, and 0 otherwise. The invalid exception is raised if -| either operand is a NaN. The comparison is performed according to the -| IEC/IEEE Standard for Binary Floating-Point Arithmetic. -*-------------------------------------------------------------------------= ---*/ -int floatx80_unordered(floatx80 a, floatx80 b, float_status *status) -{ - if (floatx80_invalid_encoding(a) || floatx80_invalid_encoding(b) - || (extractFloatx80Exp(a) =3D=3D 0x7FFF - && (uint64_t) (extractFloatx80Frac(a) << 1)) - || (extractFloatx80Exp(b) =3D=3D 0x7FFF - && (uint64_t) (extractFloatx80Frac(b) << 1)) - ) { - float_raise(float_flag_invalid, status); - return 1; - } - return 0; -} - -/*------------------------------------------------------------------------= ---- -| Returns 1 if the extended double-precision floating-point value `a' is -| equal to the corresponding value `b', and 0 otherwise. Quiet NaNs do not -| cause an exception. The comparison is performed according to the IEC/IE= EE -| Standard for Binary Floating-Point Arithmetic. -*-------------------------------------------------------------------------= ---*/ - -int floatx80_eq_quiet(floatx80 a, floatx80 b, float_status *status) -{ - - if (floatx80_invalid_encoding(a) || floatx80_invalid_encoding(b)) { - float_raise(float_flag_invalid, status); - return 0; - } - if ( ( ( extractFloatx80Exp( a ) =3D=3D 0x7FFF ) - && (uint64_t) ( extractFloatx80Frac( a )<<1 ) ) - || ( ( extractFloatx80Exp( b ) =3D=3D 0x7FFF ) - && (uint64_t) ( extractFloatx80Frac( b )<<1 ) ) - ) { - if (floatx80_is_signaling_nan(a, status) - || floatx80_is_signaling_nan(b, status)) { - float_raise(float_flag_invalid, status); - } - return 0; - } - return - ( a.low =3D=3D b.low ) - && ( ( a.high =3D=3D b.high ) - || ( ( a.low =3D=3D 0 ) - && ( (uint16_t) ( ( a.high | b.high )<<1 ) =3D=3D 0 ) ) - ); - -} - -/*------------------------------------------------------------------------= ---- -| Returns 1 if the extended double-precision floating-point value `a' is l= ess -| than or equal to the corresponding value `b', and 0 otherwise. Quiet Na= Ns -| do not cause an exception. Otherwise, the comparison is performed accor= ding -| to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. -*-------------------------------------------------------------------------= ---*/ - -int floatx80_le_quiet(floatx80 a, floatx80 b, float_status *status) -{ - bool aSign, bSign; - - if (floatx80_invalid_encoding(a) || floatx80_invalid_encoding(b)) { - float_raise(float_flag_invalid, status); - return 0; - } - if ( ( ( extractFloatx80Exp( a ) =3D=3D 0x7FFF ) - && (uint64_t) ( extractFloatx80Frac( a )<<1 ) ) - || ( ( extractFloatx80Exp( b ) =3D=3D 0x7FFF ) - && (uint64_t) ( extractFloatx80Frac( b )<<1 ) ) - ) { - if (floatx80_is_signaling_nan(a, status) - || floatx80_is_signaling_nan(b, status)) { - float_raise(float_flag_invalid, status); - } - return 0; - } - aSign =3D extractFloatx80Sign( a ); - bSign =3D extractFloatx80Sign( b ); - if ( aSign !=3D bSign ) { - return - aSign - || ( ( ( (uint16_t) ( ( a.high | b.high )<<1 ) ) | a.low | = b.low ) - =3D=3D 0 ); - } - return - aSign ? le128( b.high, b.low, a.high, a.low ) - : le128( a.high, a.low, b.high, b.low ); - -} - -/*------------------------------------------------------------------------= ---- -| Returns 1 if the extended double-precision floating-point value `a' is l= ess -| than the corresponding value `b', and 0 otherwise. Quiet NaNs do not ca= use -| an exception. Otherwise, the comparison is performed according to the -| IEC/IEEE Standard for Binary Floating-Point Arithmetic. -*-------------------------------------------------------------------------= ---*/ - -int floatx80_lt_quiet(floatx80 a, floatx80 b, float_status *status) -{ - bool aSign, bSign; - - if (floatx80_invalid_encoding(a) || floatx80_invalid_encoding(b)) { - float_raise(float_flag_invalid, status); - return 0; - } - if ( ( ( extractFloatx80Exp( a ) =3D=3D 0x7FFF ) - && (uint64_t) ( extractFloatx80Frac( a )<<1 ) ) - || ( ( extractFloatx80Exp( b ) =3D=3D 0x7FFF ) - && (uint64_t) ( extractFloatx80Frac( b )<<1 ) ) - ) { - if (floatx80_is_signaling_nan(a, status) - || floatx80_is_signaling_nan(b, status)) { - float_raise(float_flag_invalid, status); - } - return 0; - } - aSign =3D extractFloatx80Sign( a ); - bSign =3D extractFloatx80Sign( b ); - if ( aSign !=3D bSign ) { - return - aSign - && ( ( ( (uint16_t) ( ( a.high | b.high )<<1 ) ) | a.low | = b.low ) - !=3D 0 ); - } - return - aSign ? lt128( b.high, b.low, a.high, a.low ) - : lt128( a.high, a.low, b.high, b.low ); - -} - -/*------------------------------------------------------------------------= ---- -| Returns 1 if the extended double-precision floating-point values `a' and= `b' -| cannot be compared, and 0 otherwise. Quiet NaNs do not cause an excepti= on. -| The comparison is performed according to the IEC/IEEE Standard for Binary -| Floating-Point Arithmetic. -*-------------------------------------------------------------------------= ---*/ -int floatx80_unordered_quiet(floatx80 a, floatx80 b, float_status *status) -{ - if (floatx80_invalid_encoding(a) || floatx80_invalid_encoding(b)) { - float_raise(float_flag_invalid, status); - return 1; - } - if ( ( ( extractFloatx80Exp( a ) =3D=3D 0x7FFF ) - && (uint64_t) ( extractFloatx80Frac( a )<<1 ) ) - || ( ( extractFloatx80Exp( b ) =3D=3D 0x7FFF ) - && (uint64_t) ( extractFloatx80Frac( b )<<1 ) ) - ) { - if (floatx80_is_signaling_nan(a, status) - || floatx80_is_signaling_nan(b, status)) { - float_raise(float_flag_invalid, status); - } - return 1; - } - return 0; -} - /*------------------------------------------------------------------------= ---- | Returns the result of converting the quadruple-precision floating-point | value `a' to the 32-bit two's complement integer format. The conversion --=20 2.20.1