From patchwork Wed Dec 11 16:20:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 849176 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:2c4:b0:385:e875:8a9e with SMTP id o4csp415315wry; Wed, 11 Dec 2024 08:24:11 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUWPATbejNKwGxQ+uPQGnjkVpb+R/dOqAnk9Yzr90GlnIGEuU6szI5K0wIMocOMf5ZwMWni4Q==@linaro.org X-Google-Smtp-Source: AGHT+IE9uRReoVM4iD3HZiwSAm+AXr5JTVF+wHeEyKXH7QHp6JSy9/F4qFmINLM4HO8y9CtYkaAU X-Received: by 2002:a05:620a:2402:b0:7b6:d241:3f0b with SMTP id af79cd13be357-7b6ebc5e2a4mr536208485a.14.1733934251359; Wed, 11 Dec 2024 08:24:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733934251; cv=none; d=google.com; s=arc-20240605; b=B0nruW2i0A57Bu2wAJDZb4aH9znarNxElotaEtI9J7Tr/glsq21Wc9WAQXKBpbxnnu QunHdLn+6SgvgbP6KmxhbnuwcVqPxQ62yIn54BUdJs83tmQwTJAZJCUPL6unmDydM1Ih w1WDs9kidOsnMzDYaCC733OY+IEuvUHo9AtmzgWXX9Xkb3RKcLFejuJMnEDZbo88s6h7 Db8z6qWm2F03Th48lZwX/dhZSLkHHFJ6XImhSRA1CgHQi8yZnDP1t1QMNz0RkJ4t1u4r H4RQP/ZuzwbaiCrFRl0xEGYXAUAf7tPNUWShHExB53NLl6SXXhOZKH80RBimVoXQ5btg QeCA== 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=E85lj8XRhj/Fk3RQPB/aLYeRqkABA8VMdndxVbT9joA=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=EqHPK3YBbDL9lRgBk4lE3ce0ahkorgsRnCYg6rEQBs5oeNgftnnhTf1EP/8fcfP1K1 qMR4KoA/QlXJeRoMRWUj8jcRZHxNs1m1ujp/7Sv2MCjPf7KDsvWloeI/eqs2JWdPuLpI s3B7PsiHfnZXBUjyzrZxxyLfY5HSLfBW9yhiXwX/oRodA7HFO8OOB86ZRvnLmBYLRU97 IyBCjDrV6ILHmn4IzfgVaoHWtO4mmko+NPs3U0lyJuQkwm9RnnWRqLKYem7eVyzt+mbr ItsJZV5Kip8rMAMMghY41pu6c12Q0ADzlRXfYbvvTq5IIkPIEeDsgH/16bRtGaaHq/DV XgyA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="mqD6/oj+"; 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 af79cd13be357-7b6efdddb68si91757885a.6.2024.12.11.08.24.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 11 Dec 2024 08:24: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="mqD6/oj+"; 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 1tLPSy-0002EY-EM; Wed, 11 Dec 2024 11:21:36 -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 1tLPSp-0001XS-A2 for qemu-devel@nongnu.org; Wed, 11 Dec 2024 11:21:27 -0500 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tLPSn-0007ux-GR for qemu-devel@nongnu.org; Wed, 11 Dec 2024 11:21:27 -0500 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-436202dd7f6so6285435e9.0 for ; Wed, 11 Dec 2024 08:21:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733934084; x=1734538884; 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=E85lj8XRhj/Fk3RQPB/aLYeRqkABA8VMdndxVbT9joA=; b=mqD6/oj+XSZNoVUCkC0+isFlnMbSzIcX+c+HNJlL8hBXVYC0OWGB3mD0RtDlXvrnUL PsjFX6O9A37As22gLkvN/tAfYY0nZFczVnRD72ZBA0f6iQDY5qXJ1GhXgLaJd6SN3yYx G29NxsLkit/3Rro/JjbydmEfY2hX9xvZ0avEZeeBVyeLe647FaKrFOBaQAU3fo8PZ9j0 vWNFo7ept3+UxuDMzae9QDGWrYk96kgwm7ikaY0vpBPkRaO2l1b2q5B7jDuxgFHRCkO1 Yfn4QUV5X2rhZYpBAJ2a6RB9lo+rzMe2RihwFczWSUSdvdEFvXCisG0T/xNzLXnujRei /myA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733934084; x=1734538884; 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=E85lj8XRhj/Fk3RQPB/aLYeRqkABA8VMdndxVbT9joA=; b=H8eF4aueI66PEiBXrpPls2I7V7I8LOXF22y3snvKBQKq7kLX9UxCikGWtfFJv4rwBU y3vBVzXuBovzcesRTc+2tbUxQCmyWzQo1pxXMGiYEgk5kCMgmvHZlG3kNHcfcByz0dD1 yRXKmrsnNHdneoTcfPAgQ9YDmOUvVApA/a8TCiH1E79lt9+u4e2jLchTC4Xii4tcD9M6 pD+JfCfJ3tTUAb/l4T0NtI6QGsVW1vNI0FRAxd8HhAIbHtU+50/JqW9EPLE3O+rAJowq ziMPwAz7HkzJ4J5n7twdsNUU7JwuLogLuWkIAxb675bPquFloaNq2ltBtxJvkuCdK2Il 7e+A== X-Gm-Message-State: AOJu0YyNTEm7agtE70uY967UkJ4p/gT+NJ+7Aumv0zfi5nCryEy9TR97 nfZPfUvHGccAge3sUP+9lVmM1v78pH/znYPbjbyGH0Yi7l1wHfZJVjhYeQEVPWkusj8xCrWplVL a X-Gm-Gg: ASbGncseOvAVUw//tbOpsqJ1lOkfuWYheTALBOC8E656AfVvM1FEaYoLAhWfWSBoB1J hePme0SGqpI9Zi3GoByF6a+HoKaZCwQSyvRY6sSJhvv1oJeezToVtHAG8EGkdJ3vAm6Xc/r26nD NJ9ac7PTrgcnDWDJsDEongzIpluGj9iztYPRLOujYeuBj2t38hHRx9q4aKt88Pf1jU3bpDeCFo/ ygv+NW5nRvo9d6ij/8UWmU/B0u/kLsQheT7nG7lmHUKeZtKHL06n2SoDPng X-Received: by 2002:a05:600c:4e50:b0:431:5df7:b310 with SMTP id 5b1f17b1804b1-43622832e88mr2983255e9.8.1733934084148; Wed, 11 Dec 2024 08:21:24 -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.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2024 08:21:23 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 70/72] softfloat: Replace WHICH with RET in parts_pick_nan Date: Wed, 11 Dec 2024 16:20:02 +0000 Message-Id: <20241211162004.2795499-71-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::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.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 Replace the "index" selecting between A and B with a result variable of the proper type. This improves clarity within the function. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Message-id: 20241203203949.483774-12-richard.henderson@linaro.org Signed-off-by: Peter Maydell --- fpu/softfloat-parts.c.inc | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc index abe24aeaa00..ba8de7be76e 100644 --- a/fpu/softfloat-parts.c.inc +++ b/fpu/softfloat-parts.c.inc @@ -40,7 +40,8 @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b, float_status *s) { bool have_snan = false; - int cmp, which; + FloatPartsN *ret; + int cmp; if (is_snan(a->cls) || is_snan(b->cls)) { float_raise(float_flag_invalid | float_flag_invalid_snan, s); @@ -55,21 +56,21 @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b, switch (s->float_2nan_prop_rule) { case float_2nan_prop_s_ab: if (have_snan) { - which = is_snan(a->cls) ? 0 : 1; + ret = is_snan(a->cls) ? a : b; break; } /* fall through */ case float_2nan_prop_ab: - which = is_nan(a->cls) ? 0 : 1; + ret = is_nan(a->cls) ? a : b; break; case float_2nan_prop_s_ba: if (have_snan) { - which = is_snan(b->cls) ? 1 : 0; + ret = is_snan(b->cls) ? b : a; break; } /* fall through */ case float_2nan_prop_ba: - which = is_nan(b->cls) ? 1 : 0; + ret = is_nan(b->cls) ? b : a; break; case float_2nan_prop_x87: /* @@ -85,35 +86,32 @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b, */ if (is_snan(a->cls)) { if (!is_snan(b->cls)) { - which = is_qnan(b->cls) ? 1 : 0; + ret = is_qnan(b->cls) ? b : a; break; } } else if (is_qnan(a->cls)) { if (is_snan(b->cls) || !is_qnan(b->cls)) { - which = 0; + ret = a; break; } } else { - which = 1; + ret = b; break; } cmp = frac_cmp(a, b); if (cmp == 0) { cmp = a->sign < b->sign; } - which = cmp > 0 ? 0 : 1; + ret = cmp > 0 ? a : b; break; default: g_assert_not_reached(); } - if (which) { - a = b; + if (is_snan(ret->cls)) { + parts_silence_nan(ret, s); } - if (is_snan(a->cls)) { - parts_silence_nan(a, s); - } - return a; + return ret; } static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b,