From nobody Fri Oct 10 15:45:39 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=1589907159; cv=none; d=zohomail.com; s=zohoarc; b=CV+YOymLbJhC7kUkJV0TlL5s2NYDZFw+/DoFKNKuxdeG4hxg6rjFLcBsGp465X3O4TJTTl6Denrc6T+p9MGFSG1vAu+wR5mJ0bJtVfUJgvrT1UjOURU4PktC1VWRduNt3qMBvZC2F5xbCq3VwVEyjtsirM2JhEoEwTfl0kBUx/s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1589907159; 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=o6Jxwvi61ACAZcFbrA6qJoWgcewD3we7Uj1iEIe0UB4=; b=G2WzzxSjK5vmA9OMeNE9JbxnuY8zHRm3KSriU+p9/AgBA4M2nQcaVc0egGuB2YvoYuFGdm5HUECzj7uwzM3Ky+KCWgJT/yjj4yTM9atYjZDD6g2Q21qC3JmbkWSGo9wXwb9zFb6HFaBHF2pq/nm9GXCSn1zW1jzdsYztP2Z9H2E= 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 1589907159205164.46548345017106; Tue, 19 May 2020 09:52:39 -0700 (PDT) Received: from localhost ([::1]:59948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jb5Tp-0007zi-Pq for importer@patchew.org; Tue, 19 May 2020 12:52:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59666) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jb5RT-0004kR-UN for qemu-devel@nongnu.org; Tue, 19 May 2020 12:50:11 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]:52362) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jb5RR-0006El-IT for qemu-devel@nongnu.org; Tue, 19 May 2020 12:50:11 -0400 Received: by mail-pj1-x1031.google.com with SMTP id a5so1662134pjh.2 for ; Tue, 19 May 2020 09:50:09 -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.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 09:50:06 -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=o6Jxwvi61ACAZcFbrA6qJoWgcewD3we7Uj1iEIe0UB4=; b=bXvqHys/1G+kp8o/GNw+LmBhlDDI3N4i8BLzek7iQWV8lWlZbOz1byjI0knBiet0/3 4xnKIOma40AI5tZqa9aPM292Gpi+oan8SS/nqUQ5Lacy6nvDVGTbJnnn9dW5Ff6ur2w+ U2sPK/1IAfFCrVMoI2QUp/zW10taQpstzsnKX2vP2czVaEh8he3Y2Lv03QooEHZvLVEV NOGSZZYqgnt7AdAiMWoihxdMUMbGQDGhBqyIYTgilJ8ptMxAg8T7LpVMSLSEy97M08Gx +F4sZtOZksdjkGiL0TxCHe63PoAOHV8SSnlZjkvNKkwzhTbvon3SuKVfT/1A3uPTBJKF K+IA== 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=o6Jxwvi61ACAZcFbrA6qJoWgcewD3we7Uj1iEIe0UB4=; b=EoecVgIAdpcvEktFOscC/c5vGgAOsV3PCOWVIFDPQv93hx9Ne1kM8jSkPKXKOMZ55n sR04FrnP0cAc/DyPiY8pyhcoYkqneJdusw2k0MDBv9RsR6vkdZRropg90pUtZ0CjoAz+ MnmPA5j+dy9G7H762T0Y82gZdVAIeeET/8yZJPM8YidTe8OxxjVm7dRR6NVDnT9uJhIC RQaQ91pJNIoKFmfxRyytsXKsbHaJVENTavu4ByRHz2RuLoMo4R25QVqNu5z+NrPfnlH9 7PT+e2CoVAXuVeHF/xzOrJF2ll0syIDdvPH8a8yk/HQSKo/ahDxD88AtCzyFs37e/5V8 w2XQ== X-Gm-Message-State: AOAM531UE1Vitv7Cjy1+s0TPlurZd1IKRQ5MVKl3UgwaRJVvhpyejZvE BzNTYJvXl0oPyoFTai0uAuUNF/g/Y2A= X-Google-Smtp-Source: ABdhPJzMx2b0hfg8/4x+fxEuuWEE/tpzc6sGvCfwzsz4kbgoxCO++eWO3p2M1zgQ0kSz/z9pIDbFpQ== X-Received: by 2002:a17:90a:264c:: with SMTP id l70mr530563pje.18.1589907007576; Tue, 19 May 2020 09:50:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 06/10] softfloat: Inline float32 compare specializations Date: Tue, 19 May 2020 09:49:53 -0700 Message-Id: <20200519164957.26920-7-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::1031; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1031.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 float32 compare specializations with inline functions that call the standard float32_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 | 216 ---------------------------------------- 2 files changed, 41 insertions(+), 224 deletions(-) diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index 7f84235122..4d1af6ab45 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -343,14 +343,6 @@ float32 float32_muladd(float32, float32, float32, int,= float_status *status); float32 float32_sqrt(float32, float_status *status); float32 float32_exp2(float32, float_status *status); float32 float32_log2(float32, float_status *status); -int float32_eq(float32, float32, float_status *status); -int float32_le(float32, float32, float_status *status); -int float32_lt(float32, float32, float_status *status); -int float32_unordered(float32, float32, float_status *status); -int float32_eq_quiet(float32, float32, float_status *status); -int float32_le_quiet(float32, float32, float_status *status); -int float32_lt_quiet(float32, float32, float_status *status); -int float32_unordered_quiet(float32, float32, float_status *status); FloatRelation float32_compare(float32, float32, float_status *status); FloatRelation float32_compare_quiet(float32, float32, float_status *status= ); float32 float32_min(float32, float32, float_status *status); @@ -425,6 +417,47 @@ static inline float32 float32_set_sign(float32 a, int = sign) return make_float32((float32_val(a) & 0x7fffffff) | (sign << 31)); } =20 +static inline bool float32_eq(float32 a, float32 b, float_status *s) +{ + return float32_compare(a, b, s) =3D=3D float_relation_equal; +} + +static inline bool float32_le(float32 a, float32 b, float_status *s) +{ + return float32_compare(a, b, s) <=3D float_relation_equal; +} + +static inline bool float32_lt(float32 a, float32 b, float_status *s) +{ + return float32_compare(a, b, s) < float_relation_equal; +} + +static inline bool float32_unordered(float32 a, float32 b, float_status *s) +{ + return float32_compare(a, b, s) =3D=3D float_relation_unordered; +} + +static inline bool float32_eq_quiet(float32 a, float32 b, float_status *s) +{ + return float32_compare_quiet(a, b, s) =3D=3D float_relation_equal; +} + +static inline bool float32_le_quiet(float32 a, float32 b, float_status *s) +{ + return float32_compare_quiet(a, b, s) <=3D float_relation_equal; +} + +static inline bool float32_lt_quiet(float32 a, float32 b, float_status *s) +{ + return float32_compare_quiet(a, b, s) < float_relation_equal; +} + +static inline bool float32_unordered_quiet(float32 a, float32 b, + float_status *s) +{ + return float32_compare_quiet(a, b, s) =3D=3D float_relation_unordered; +} + #define float32_zero make_float32(0) #define float32_half make_float32(0x3f000000) #define float32_one make_float32(0x3f800000) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 60b9ae5f05..f6bfc40c97 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -4733,222 +4733,6 @@ float32 float32_log2(float32 a, float_status *statu= s) return normalizeRoundAndPackFloat32(zSign, 0x85, zSig, status); } =20 -/*------------------------------------------------------------------------= ---- -| Returns 1 if the single-precision floating-point value `a' is equal 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 float32_eq(float32 a, float32 b, float_status *status) -{ - uint32_t av, bv; - a =3D float32_squash_input_denormal(a, status); - b =3D float32_squash_input_denormal(b, status); - - if ( ( ( extractFloat32Exp( a ) =3D=3D 0xFF ) && extractFloat32Frac= ( a ) ) - || ( ( extractFloat32Exp( b ) =3D=3D 0xFF ) && extractFloat32Frac= ( b ) ) - ) { - float_raise(float_flag_invalid, status); - return 0; - } - av =3D float32_val(a); - bv =3D float32_val(b); - return ( av =3D=3D bv ) || ( (uint32_t) ( ( av | bv )<<1 ) =3D=3D 0 ); -} - -/*------------------------------------------------------------------------= ---- -| Returns 1 if the single-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 perfo= rmed -| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. -*-------------------------------------------------------------------------= ---*/ - -int float32_le(float32 a, float32 b, float_status *status) -{ - bool aSign, bSign; - uint32_t av, bv; - a =3D float32_squash_input_denormal(a, status); - b =3D float32_squash_input_denormal(b, status); - - if ( ( ( extractFloat32Exp( a ) =3D=3D 0xFF ) && extractFloat32Frac= ( a ) ) - || ( ( extractFloat32Exp( b ) =3D=3D 0xFF ) && extractFloat32Frac= ( b ) ) - ) { - float_raise(float_flag_invalid, status); - return 0; - } - aSign =3D extractFloat32Sign( a ); - bSign =3D extractFloat32Sign( b ); - av =3D float32_val(a); - bv =3D float32_val(b); - if ( aSign !=3D bSign ) return aSign || ( (uint32_t) ( ( av | bv )<<1 = ) =3D=3D 0 ); - return ( av =3D=3D bv ) || ( aSign ^ ( av < bv ) ); - -} - -/*------------------------------------------------------------------------= ---- -| Returns 1 if the single-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 performed according -| to the IEC/IEEE Standard for Binary Floating-Point Arithmetic. -*-------------------------------------------------------------------------= ---*/ - -int float32_lt(float32 a, float32 b, float_status *status) -{ - bool aSign, bSign; - uint32_t av, bv; - a =3D float32_squash_input_denormal(a, status); - b =3D float32_squash_input_denormal(b, status); - - if ( ( ( extractFloat32Exp( a ) =3D=3D 0xFF ) && extractFloat32Frac= ( a ) ) - || ( ( extractFloat32Exp( b ) =3D=3D 0xFF ) && extractFloat32Frac= ( b ) ) - ) { - float_raise(float_flag_invalid, status); - return 0; - } - aSign =3D extractFloat32Sign( a ); - bSign =3D extractFloat32Sign( b ); - av =3D float32_val(a); - bv =3D float32_val(b); - if ( aSign !=3D bSign ) return aSign && ( (uint32_t) ( ( av | bv )<<1 = ) !=3D 0 ); - return ( av !=3D bv ) && ( aSign ^ ( av < bv ) ); - -} - -/*------------------------------------------------------------------------= ---- -| Returns 1 if the single-precision floating-point values `a' and `b' cann= ot -| 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 float32_unordered(float32 a, float32 b, float_status *status) -{ - a =3D float32_squash_input_denormal(a, status); - b =3D float32_squash_input_denormal(b, status); - - if ( ( ( extractFloat32Exp( a ) =3D=3D 0xFF ) && extractFloat32Frac= ( a ) ) - || ( ( extractFloat32Exp( b ) =3D=3D 0xFF ) && extractFloat32Frac= ( b ) ) - ) { - float_raise(float_flag_invalid, status); - return 1; - } - return 0; -} - -/*------------------------------------------------------------------------= ---- -| Returns 1 if the single-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/IEEE Standa= rd -| for Binary Floating-Point Arithmetic. -*-------------------------------------------------------------------------= ---*/ - -int float32_eq_quiet(float32 a, float32 b, float_status *status) -{ - a =3D float32_squash_input_denormal(a, status); - b =3D float32_squash_input_denormal(b, status); - - if ( ( ( extractFloat32Exp( a ) =3D=3D 0xFF ) && extractFloat32Frac= ( a ) ) - || ( ( extractFloat32Exp( b ) =3D=3D 0xFF ) && extractFloat32Frac= ( b ) ) - ) { - if (float32_is_signaling_nan(a, status) - || float32_is_signaling_nan(b, status)) { - float_raise(float_flag_invalid, status); - } - return 0; - } - return ( float32_val(a) =3D=3D float32_val(b) ) || - ( (uint32_t) ( ( float32_val(a) | float32_val(b) )<<1 ) =3D=3D= 0 ); -} - -/*------------------------------------------------------------------------= ---- -| Returns 1 if the single-precision floating-point value `a' is less than = or -| equal to the corresponding value `b', and 0 otherwise. Quiet NaNs do not -| cause an exception. Otherwise, the comparison is performed according to= the -| IEC/IEEE Standard for Binary Floating-Point Arithmetic. -*-------------------------------------------------------------------------= ---*/ - -int float32_le_quiet(float32 a, float32 b, float_status *status) -{ - bool aSign, bSign; - uint32_t av, bv; - a =3D float32_squash_input_denormal(a, status); - b =3D float32_squash_input_denormal(b, status); - - if ( ( ( extractFloat32Exp( a ) =3D=3D 0xFF ) && extractFloat32Frac= ( a ) ) - || ( ( extractFloat32Exp( b ) =3D=3D 0xFF ) && extractFloat32Frac= ( b ) ) - ) { - if (float32_is_signaling_nan(a, status) - || float32_is_signaling_nan(b, status)) { - float_raise(float_flag_invalid, status); - } - return 0; - } - aSign =3D extractFloat32Sign( a ); - bSign =3D extractFloat32Sign( b ); - av =3D float32_val(a); - bv =3D float32_val(b); - if ( aSign !=3D bSign ) return aSign || ( (uint32_t) ( ( av | bv )<<1 = ) =3D=3D 0 ); - return ( av =3D=3D bv ) || ( aSign ^ ( av < bv ) ); - -} - -/*------------------------------------------------------------------------= ---- -| Returns 1 if the single-precision floating-point value `a' is less than -| the corresponding value `b', and 0 otherwise. Quiet NaNs do not cause an -| exception. Otherwise, the comparison is performed according to the IEC/= IEEE -| Standard for Binary Floating-Point Arithmetic. -*-------------------------------------------------------------------------= ---*/ - -int float32_lt_quiet(float32 a, float32 b, float_status *status) -{ - bool aSign, bSign; - uint32_t av, bv; - a =3D float32_squash_input_denormal(a, status); - b =3D float32_squash_input_denormal(b, status); - - if ( ( ( extractFloat32Exp( a ) =3D=3D 0xFF ) && extractFloat32Frac= ( a ) ) - || ( ( extractFloat32Exp( b ) =3D=3D 0xFF ) && extractFloat32Frac= ( b ) ) - ) { - if (float32_is_signaling_nan(a, status) - || float32_is_signaling_nan(b, status)) { - float_raise(float_flag_invalid, status); - } - return 0; - } - aSign =3D extractFloat32Sign( a ); - bSign =3D extractFloat32Sign( b ); - av =3D float32_val(a); - bv =3D float32_val(b); - if ( aSign !=3D bSign ) return aSign && ( (uint32_t) ( ( av | bv )<<1 = ) !=3D 0 ); - return ( av !=3D bv ) && ( aSign ^ ( av < bv ) ); - -} - -/*------------------------------------------------------------------------= ---- -| Returns 1 if the single-precision floating-point values `a' and `b' cann= ot -| be compared, and 0 otherwise. Quiet NaNs do not cause an exception. The -| comparison is performed according to the IEC/IEEE Standard for Binary -| Floating-Point Arithmetic. -*-------------------------------------------------------------------------= ---*/ - -int float32_unordered_quiet(float32 a, float32 b, float_status *status) -{ - a =3D float32_squash_input_denormal(a, status); - b =3D float32_squash_input_denormal(b, status); - - if ( ( ( extractFloat32Exp( a ) =3D=3D 0xFF ) && extractFloat32Frac= ( a ) ) - || ( ( extractFloat32Exp( b ) =3D=3D 0xFF ) && extractFloat32Frac= ( b ) ) - ) { - if (float32_is_signaling_nan(a, status) - || float32_is_signaling_nan(b, status)) { - float_raise(float_flag_invalid, status); - } - return 1; - } - return 0; -} - /*------------------------------------------------------------------------= ---- | Returns the result of converting the double-precision floating-point val= ue | `a' to the extended double-precision floating-point format. The convers= ion --=20 2.20.1