From patchwork Wed Dec 11 16:19:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 849221 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:2c4:b0:385:e875:8a9e with SMTP id o4csp417459wry; Wed, 11 Dec 2024 08:28:12 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXn2SRZCiBwhUh/oknrHRfF+c8486tS1yET5y7Q1vwofzWEJg1s8Vx4FI0CH8FWB8mNd8LTLw==@linaro.org X-Google-Smtp-Source: AGHT+IFATH2fqqUR1ff4Z0YXqQCoix+V1u7IfCBPzGQel6wp83yh8FwRox19cjSvXQfJAzaoz1KT X-Received: by 2002:a05:6214:5190:b0:6d4:4100:75a1 with SMTP id 6a1803df08f44-6d934be0752mr53139686d6.39.1733934491888; Wed, 11 Dec 2024 08:28:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733934491; cv=none; d=google.com; s=arc-20240605; b=OWBDyZ1f9pgdBE9sAzjrcSJPAjmzqwRq41I5Mw04bMC4x1DpLn0XJbHjXY9zwEdLjT 6VXU7ZoMbWWbs952CDDnx+KcCjF8WARyJbEg3kcGeBifGWS96/QRDByLbnYzlqtujxO2 1pWtcisQ8bvfpWBf8gYk0j5Ibs1owcQBDq8R/Zq6qlx0wNn6or0fN3mKh5/v+gAUmyO/ c/Xlb22FPNJAsIkEc3cgu/mS2UF0lUgkuiKADGHsF7WSgo90cDmtyF+60lyRF6n+KQWW gXPqfANvYnuBdtD2T0nV/DbFbU07bdH7tuPRf4hfwJqfd1swUmtfnJ8PibQ9EAka0r4U aDtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=D00DSruytulbxjjJ4e78+Qdhi69cDsAe2XaYdtO6NTo=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=hRzIFdvG0AmEqgiSReDDa7g5Me7BjIUfZ4jXm6t6Tm99wnj10YwyJ4uGFX8VlH37m5 J5wX0OlgabrZ5GwcJBJL2JA9YctP9l92cyngHIsbZkKBYK8RRrwwmge70xBhI92g6szk njw4tLGKMuRVhevi6WAWo6aii3PRIdpmy50g+FDFO+2oj8maELUu3gvj86PkFCv+oMen XbU9dFcKXarGEkqIjJUCnJd1ksSC7YMaGK8ADdovQv1d3Vt4KcbJ5/b9WnUTGOrSPGQ8 6ICzbI3dDVoowLselXgHBKP1mGe/69cel+9vRRw92BLc0yZmFum1xURZpgzyaNN/8OAV Lc4Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a1xpGjNl; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6d8da67f579si164244666d6.33.2024.12.11.08.28.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Dec 2024 08:28:11 -0800 (PST) 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=pass header.i=@linaro.org header.s=google header.b=a1xpGjNl; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tLPSq-0001eg-Qu; Wed, 11 Dec 2024 11:21:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tLPSj-0001KO-Pi for qemu-devel@nongnu.org; Wed, 11 Dec 2024 11:21:22 -0500 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tLPSf-0007sy-R6 for qemu-devel@nongnu.org; Wed, 11 Dec 2024 11:21:20 -0500 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4361dc6322fso5906855e9.3 for ; Wed, 11 Dec 2024 08:21:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733934076; x=1734538876; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=D00DSruytulbxjjJ4e78+Qdhi69cDsAe2XaYdtO6NTo=; b=a1xpGjNlSG5xouRdtwNQ5CKigMBpMpaOvgWTe1gWlcNe0dPfGJjYizSTFXL5/QKa52 wQhJ2/yfWy9II3X8WXj6kPYI/8vkhE1/wk1J5Q42Y57M+9P4WT5EU4VSq7864lYQogSW xNoXCwf1hhWjEm9LVWGEfjaqDn5LJyAiqZk3XwxrKbkOVKanE4fQ7mf1Buemce+hdKep BO9YANPoMsjcWMZ12JrcYHqiCQycUF9TWDFD+d3dhHbpFFwHn+CmybZz9r86PNNVvJLr pAvsKi5XOLwihy5VdLjoSx05SGlInIfGSAjAOWSzNKYN/NBSlTNUG3M3WkhK1UckB2vw 9Fbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733934076; x=1734538876; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D00DSruytulbxjjJ4e78+Qdhi69cDsAe2XaYdtO6NTo=; b=nXyizC3SOPEvaTbPOwBSYaITcyerRcCf+qavOZGWH+YnXx0odO2v88SvzLoNs2Zo3A InVBGYNy0eODTjFTNJ2x+6GjgMKm9iP0eNenU9rDD6/dRdTatOKSvVHqYZKme88EcSg1 +Poa50EQPpx2C0uNGZWsbXx/WfpxjHQqnfNmW/vaMZ9ZNz1qO3CmGV4f5gFrBGNd6DqE 9gSgEp4esF7kYktXecgNXJ07TH2zbF5HsvpkfYMJuPiKHQOiH3avk12E1ks9OccZ8UKq 0ceJICaCc+w34AOAE6o18iwBDMP9tDhfT9GmfgvmOLZQkQyYfIIAF7UM0RcF0egBCfTW tA/w== X-Gm-Message-State: AOJu0YzHdKoISzq8IFKdXh/Wc58Huc6awyci6KXKICKkFCD08jvSaeXZ hMTkt+IhxlHMHcmoOWvoxdb7EipjSk/IbuNe+t3+ZUJ8vH04gos0cXrhrH8ZY7xagvdv+6vvXX8 E X-Gm-Gg: ASbGncv1X4mOs/Zv/sbuV8UPWnjA57+XRtCwmQAPdzI9urwDbUqJFnKSBwoAz6gmyt1 gE2ye712tssQM50jVht0qKKfLkIGqIkJ7z8fGSO31s9OT9l/0DMh0Y3ceBxcYW2m5Lk6sbgeQVK fzEjbU10MXCGJHqXBBfI1NdgUdTdTc5sKjKJ7wmA7ykeqUTa22c26bddCa4KNmgpXVOIcxPiu5C 6tCK46QgUfDxpFBiOBJQv3FBJ0PLZoYHOMD5TqBWRO0eNNFXQIEl5pRIRDu X-Received: by 2002:a05:600c:5108:b0:434:a4fe:cd71 with SMTP id 5b1f17b1804b1-4361c35d6b9mr28382815e9.12.1733934075760; Wed, 11 Dec 2024 08:21:15 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-434f4dfdcdfsm121460595e9.39.2024.12.11.08.21.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 08:21:15 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 61/72] softfloat: Inline pickNaNMulAdd Date: Wed, 11 Dec 2024 16:19:53 +0000 Message-Id: <20241211162004.2795499-62-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241211162004.2795499-1-peter.maydell@linaro.org> References: <20241211162004.2795499-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x330.google.com 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_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Richard Henderson Inline pickNaNMulAdd into its only caller. This makes one assert redundant with the immediately preceding IF. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-id: 20241203203949.483774-3-richard.henderson@linaro.org [PMM: keep comment from old code in new location] Signed-off-by: Peter Maydell --- fpu/softfloat-parts.c.inc | 41 +++++++++++++++++++++++++- fpu/softfloat-specialize.c.inc | 54 ---------------------------------- 2 files changed, 40 insertions(+), 55 deletions(-) diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc index 655b7d9da51..c1a97c35b20 100644 --- a/fpu/softfloat-parts.c.inc +++ b/fpu/softfloat-parts.c.inc @@ -79,9 +79,48 @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, } if (s->default_nan_mode) { + /* + * We guarantee not to require the target to tell us how to + * pick a NaN if we're always returning the default NaN. + * But if we're not in default-NaN mode then the target must + * specify. + */ which = 3; + } else if (infzero) { + /* + * Inf * 0 + NaN -- some implementations return the + * default NaN here, and some return the input NaN. + */ + switch (s->float_infzeronan_rule) { + case float_infzeronan_dnan_never: + which = 2; + break; + case float_infzeronan_dnan_always: + which = 3; + break; + case float_infzeronan_dnan_if_qnan: + which = is_qnan(c->cls) ? 3 : 2; + break; + default: + g_assert_not_reached(); + } } else { - which = pickNaNMulAdd(a->cls, b->cls, c->cls, infzero, have_snan, s); + FloatClass cls[3] = { a->cls, b->cls, c->cls }; + Float3NaNPropRule rule = s->float_3nan_prop_rule; + + assert(rule != float_3nan_prop_none); + if (have_snan && (rule & R_3NAN_SNAN_MASK)) { + /* We have at least one SNaN input and should prefer it */ + do { + which = rule & R_3NAN_1ST_MASK; + rule >>= R_3NAN_1ST_LENGTH; + } while (!is_snan(cls[which])); + } else { + do { + which = rule & R_3NAN_1ST_MASK; + rule >>= R_3NAN_1ST_LENGTH; + } while (!is_nan(cls[which])); + } } if (which == 3) { diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc index e075c47889a..f26458eaa31 100644 --- a/fpu/softfloat-specialize.c.inc +++ b/fpu/softfloat-specialize.c.inc @@ -448,60 +448,6 @@ static int pickNaN(FloatClass a_cls, FloatClass b_cls, } } -/*---------------------------------------------------------------------------- -| Select which NaN to propagate for a three-input operation. -| For the moment we assume that no CPU needs the 'larger significand' -| information. -| Return values : 0 : a; 1 : b; 2 : c; 3 : default-NaN -*----------------------------------------------------------------------------*/ -static int pickNaNMulAdd(FloatClass a_cls, FloatClass b_cls, FloatClass c_cls, - bool infzero, bool have_snan, float_status *status) -{ - FloatClass cls[3] = { a_cls, b_cls, c_cls }; - Float3NaNPropRule rule = status->float_3nan_prop_rule; - int which; - - /* - * We guarantee not to require the target to tell us how to - * pick a NaN if we're always returning the default NaN. - * But if we're not in default-NaN mode then the target must - * specify. - */ - assert(!status->default_nan_mode); - - if (infzero) { - /* - * Inf * 0 + NaN -- some implementations return the default NaN here, - * and some return the input NaN. - */ - switch (status->float_infzeronan_rule) { - case float_infzeronan_dnan_never: - return 2; - case float_infzeronan_dnan_always: - return 3; - case float_infzeronan_dnan_if_qnan: - return is_qnan(c_cls) ? 3 : 2; - default: - g_assert_not_reached(); - } - } - - assert(rule != float_3nan_prop_none); - if (have_snan && (rule & R_3NAN_SNAN_MASK)) { - /* We have at least one SNaN input and should prefer it */ - do { - which = rule & R_3NAN_1ST_MASK; - rule >>= R_3NAN_1ST_LENGTH; - } while (!is_snan(cls[which])); - } else { - do { - which = rule & R_3NAN_1ST_MASK; - rule >>= R_3NAN_1ST_LENGTH; - } while (!is_nan(cls[which])); - } - return which; -} - /*---------------------------------------------------------------------------- | Returns 1 if the double-precision floating-point value `a' is a quiet | NaN; otherwise returns 0.