From patchwork Tue Dec 3 20:39:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 846983 Delivered-To: patch@linaro.org Received: by 2002:a5d:44cd:0:b0:385:e875:8a9e with SMTP id z13csp715466wrr; Tue, 3 Dec 2024 12:42:24 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXAiKuukwONeJmcYd1obWiDofGE18oTQqJJF9OGX1kuSf6KRQxvjXs1LBm44jFpxE7YDQxkZg==@linaro.org X-Google-Smtp-Source: AGHT+IGUjEt1gcwu8L31wXLUnGMkiWRzUO7uwggslvyy+eGd3nBVLrsdt+6iqjz3i6XKdZGlOGIu X-Received: by 2002:a05:6214:c82:b0:6cb:d4e6:2507 with SMTP id 6a1803df08f44-6d8b738ae51mr61865926d6.22.1733258544215; Tue, 03 Dec 2024 12:42:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733258544; cv=none; d=google.com; s=arc-20240605; b=fXFZZYYM9s1WbfeocQbLTEv3FAn9sLGNpnVubcEId3q7fH7dWMN6nWPqkLrDbzxjpg QoUI6FFDjnHOKarfbwTqSYkskeT3Mw2RN7cVSwpLYVlEEmxkqcfFNc/+j24YFKy27SeX pQtG2tXaV36twwj1a9AFYBgllwmAgUhSxsu1otDmroIPtswJZuRHlLkyV68H2S70zZRj f6m/boE6etuBOLl+bQDZF2u9ojuatISnNFb1nCjDj3wRlMQYmXaDeG0L2+PgzxHrqcLT 0xFq4FhQfbkVbYjkdqMCr1qhqCjcYWi2TLivhR4f8fUdw778mXrFPvxrPKEd/BffxpZv 9+Yg== 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:cc:to :from:dkim-signature; bh=65/XNqGZ6VyYj6rTQSJdOtQFVcZddgAeG+CbEFdXJAI=; fh=UQCixiNfr28ZOrfhmxiGPA65dFhly8CmRsnoYC6xI9k=; b=LeBOixtFL27EaAUrvk+Q8MemIsk1nUyLk+818QHsASEbBJp9QH7gI7AJyYrtkCledx R74ZlIJxtZ1KTV3FMJkrwAISU/7tlJyGQgawMebRZw8Hz9+4NnpzHpMypOclGDyE2l6o zXyAE5EkTlOSEYBkK5XgEoOTujuLjxeL7PQz0Iij9dS8RwW/ydRojm/0PGE8oHsgXxG7 OCefaGINOX5Mq/DTyXD0GGM50TwfFEWULZPYl1zX/A0OegVMqX/3bcBvBrcOsRBN84te PgTuUB9ObNBfJaKZk4+EGho+VfpdvxLBkaeQdG92YoHjOA7JYBXaj+1qp57AxhbPquhF aU2A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Kix3gkYb; 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-6d88ee27a4esi102145046d6.386.2024.12.03.12.42.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Dec 2024 12:42:24 -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=Kix3gkYb; 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 1tIZgu-0001Yb-1e; Tue, 03 Dec 2024 15:40:16 -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 1tIZgb-0001Ko-Q0 for qemu-devel@nongnu.org; Tue, 03 Dec 2024 15:39:57 -0500 Received: from mail-oa1-x2e.google.com ([2001:4860:4864:20::2e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tIZgZ-0003AX-M0 for qemu-devel@nongnu.org; Tue, 03 Dec 2024 15:39:57 -0500 Received: by mail-oa1-x2e.google.com with SMTP id 586e51a60fabf-27b7a1480bdso2774599fac.2 for ; Tue, 03 Dec 2024 12:39:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733258393; x=1733863193; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=65/XNqGZ6VyYj6rTQSJdOtQFVcZddgAeG+CbEFdXJAI=; b=Kix3gkYbq+x93L9YAiQeXSK5emG2+IlSaUQ43X+E/y9+JO83VAZ2cdik22C7pJEC6G Mo+35IPs5mIFSmvY4GZ+IgW1OHio5r0rp0pJHeskot0PAxkSN+MpOQ5ufhy3fgvnQY1G 2hH9LdooY1LgCMTmrHUEA8qoz3dC2hRRM+E+wonhm8AvDvNe9AxAao/f7UpYI32fcUUr 2IfTW56LM36bZoqbEl8cw1M50WL5iO8D4jRrUXfwpubWsErincB8D1tH0fY3YkiirvEg 7CVWJC3N4FrCst2PbMsrpp/955419Vt8TBA+N5HcAWMuVjnEVIe3xNWH8Z4Jp2BkOYFA IYYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733258393; x=1733863193; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=65/XNqGZ6VyYj6rTQSJdOtQFVcZddgAeG+CbEFdXJAI=; b=PeWD84dtaCFRrDocsiwjqBPoQ4Q8jMXYIFijuouNDnIMHCVXHkCbFKQW/cPOfJjKEJ ObZqfDYw5YcYjSEAWM+LUgbogTrKhCnISuHrig5E2H0UUNEGuNqfOoirUWzAF5RXS0dJ nDyp9f//V0vWfL/T2ahcMxZSFvTcPkWsgzpPKDOMZGgHrIB+c2rr8ukqZmNlBxCDaaV7 ZZegwctE1Ue576orYddX0SlSuzdN6LbQuDCo4ftELDOp6fjAOOekDWZFIXsb3Ixdbccc wzwdto0XMT6Q6Dt1aUuYHbtV6DN9dj1ho14TaLICFKwguTyV6Ztb7iD8MwiQw8ErpfFg iH+g== X-Gm-Message-State: AOJu0YxCYR148TGxL7if7J66P7xiz34e6GYY0Jq5PF2gQD3YUNiCAJUV WEQddbv1Qa6GYxveWRvRU2EHaRFBjRoDgVxkPsIrmBEQnbvlEZqmfiqMQlH7kV3u+FASvXsn7zQ 04gQ= X-Gm-Gg: ASbGnctM5RbySmeDe702j7MgpsgVbXg0nV/594wCE+kMssFBKWE8UCycRVBOy+rnMyT sQ0crIt5QBdEYrfA1U88AGL1FkLcU2Ywly6o8MqMWrJXc6v/9TYMWVZpHzkXE+od2EAtpT6b5NA cc5ymog5cTustnTYoOnqACD5tqJ3r7j7BAk+J2jgKYCHGmTjvUKnJy2C+Rhbofb5EMjmr0Sh5F8 /3vuTBz/P/jGlVcTh7pJmBUkTmqy4O7iHz+ZyHX5SRsdEfs75m/wq4qY3EXP9gdu63MbDMnxRTg fsU1VXbL6jS5TSTU+i25WKlZWjSCmflpjB3e X-Received: by 2002:a05:6870:3913:b0:29e:5e83:150e with SMTP id 586e51a60fabf-29e88885e8fmr3919454fac.27.1733258393185; Tue, 03 Dec 2024 12:39:53 -0800 (PST) Received: from localhost.localdomain (fixed-187-189-51-143.totalplay.net. [187.189.51.143]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-29e3ae09f25sm2684018fac.49.2024.12.03.12.39.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 12:39:52 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Subject: [PATCH 02/11] softfloat: Inline pickNaNMulAdd Date: Tue, 3 Dec 2024 14:39:39 -0600 Message-ID: <20241203203949.483774-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241203203949.483774-1-richard.henderson@linaro.org> References: <20241203203949.483774-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2001:4860:4864:20::2e; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2e.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 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é --- fpu/softfloat-parts.c.inc | 35 +++++++++++++++++++++- fpu/softfloat-specialize.c.inc | 54 ---------------------------------- 2 files changed, 34 insertions(+), 55 deletions(-) diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc index 655b7d9da5..f5c6b21fee 100644 --- a/fpu/softfloat-parts.c.inc +++ b/fpu/softfloat-parts.c.inc @@ -80,8 +80,41 @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, if (s->default_nan_mode) { 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 e075c47889..f26458eaa3 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.