From patchwork Tue Dec 3 20:39:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 846980 Delivered-To: patch@linaro.org Received: by 2002:a5d:44cd:0:b0:385:e875:8a9e with SMTP id z13csp715410wrr; Tue, 3 Dec 2024 12:42:12 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV4zRvjJHN7Tut6DdXU2QmsfgwNR8dEXMa5+e4bcnQtjstImtKqW/BOJpE+PJ1qMK2NqhgisQ==@linaro.org X-Google-Smtp-Source: AGHT+IGXai4/+VCGNPQ8ulXXoycU5C9hWNb9FhNuqK6LziB3yUCxPOeZs4rked9Oq6rf0ogXHRdl X-Received: by 2002:a05:6358:d39c:b0:1c5:e2eb:5aad with SMTP id e5c5f4694b2df-1caeac02f27mr443623655d.20.1733258532420; Tue, 03 Dec 2024 12:42:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733258532; cv=none; d=google.com; s=arc-20240605; b=eU+19dJA7g2JTQxPunse1IgWC6BElr9TbnadHZq3yhX7D0LUir/SjfuCvbMoklcyQQ 8srDVC7vbKUYzGdWRzfpLAEZgFYRqhCusjofFD1NRU51hz4+3zCbmubCuku+vHeBbHUM q3jJKLkMB9cAyPqnCB3Wln5cSKMuXA0ffKHnJO2/8BHfmje89pPQAN3Bu2dbb1QmDt/u lkL+8CF62vpKTZIt7uw9LwUvFtaIxlbY3lIHimB1yk5JyDfXt2cyfmpZszMToBQg4XFk +H2SxN0oUi0mXtVe/fzChoDW4C1EEqbbRVB4iHdk2t0G05/gtfKw++ejqS8+gfyzX4LK K0kw== 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=aNUIjgqbw5Yl+6hPFOkjdIaMwRXN7nsIkH0qHur7LqI=; fh=UQCixiNfr28ZOrfhmxiGPA65dFhly8CmRsnoYC6xI9k=; b=gBE4uaRWoDT48QJIaEtgsoUl7eG+3Yu0Pqmr2cQj2C88t+RcVlSLEIf77P2vE6F0qZ 8+7LvyW2HccGDnwDRVS44FyAbp5talTcxVzcZZ0FpVv2aMfTPpTxbaOYnFkuJs5EcoHm 1h862V44d3HM4h5EQVxH+Ql2RqW9j2WOYbRmK7WE1rJ5dSfEcfiuH3rmT1GqaiWy5xTl yWhrxKeVUJXdz86SOnOS1/m/0+QvlZzWGPsScMdVr0laQ/7+dVwV99OFt/VEzMiOzk2L Rc9TyTqTby4hsClVK+I6fc0MxsFeeBFj7jPvuVl/yKSJSdzLpHkN4omquswth0iFLK3O l6fQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=osQNGHP1; 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 d75a77b69052e-466c4109afdsi150950611cf.255.2024.12.03.12.42.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Dec 2024 12:42:12 -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=osQNGHP1; 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 1tIZh3-0001bs-F4; Tue, 03 Dec 2024 15:40:25 -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 1tIZgf-0001Po-32 for qemu-devel@nongnu.org; Tue, 03 Dec 2024 15:40:02 -0500 Received: from mail-oa1-x2a.google.com ([2001:4860:4864:20::2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tIZgc-0003BT-VO for qemu-devel@nongnu.org; Tue, 03 Dec 2024 15:40:00 -0500 Received: by mail-oa1-x2a.google.com with SMTP id 586e51a60fabf-29e49376462so2206942fac.0 for ; Tue, 03 Dec 2024 12:39:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733258398; x=1733863198; 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=aNUIjgqbw5Yl+6hPFOkjdIaMwRXN7nsIkH0qHur7LqI=; b=osQNGHP1tQbA03jHTs7rku97oeX9dhZ9myMEh2ClP2UM7pWugVaY0svFWKs6Vcf+vO rpQKZyVRFgYj6Grs978oEJyYzNB9js74t6g/NnH1KtE5d7ktpXfqF4GGH7V6/42gIvL6 ZocgMg/ZwUrIBpTL8TCViEIAcgxDHzdCpQM+D8puUqM5ScgS3bxG0cm4yd32Et9Wt5AP OKceN0UL5FYDzH6iNo4HxF/Aj+EuI/B1ed87XGNZ9sOamvPTPellJZaV8xwcdFe2eHfp O/rBtfrIqKiRj1Iyk1LVOQpNZZJMT56V8pX41LuPzryxdNyfGuyL/lLud+BE3Jy/qOKI 0S9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733258398; x=1733863198; 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=aNUIjgqbw5Yl+6hPFOkjdIaMwRXN7nsIkH0qHur7LqI=; b=ahz7rJjFZ40UFoKyjmZbA1qNPdXJ2A/mB5Rk+deK7FsYdgkeEt5N+OvoykHjFu1e5o ue0c6p8vNJKp66DODIA7v7p3TlbRyNHm1X6opLhpL/+AwT7JsOKISWL30Y/65P8+fr63 K9h6Et9m6Fwwo8rtzqdUQrS5Xl3u2WXZ9rYWiMUNq23XCTDD2PL9/TUMaGawpZio+7zZ KmvIrjmt1aIiooJSeqsunhAcdRW4yyq6DqBVR5amsuoh74nJ7YoEQj9LcbmUkmiMM6ix 4LnMj+4WwLKFqV1OTbI4s49jkwltpHOeZxLZ6SLYCXO6NqeKfvMF91CRcPZoJOJ29EQg guEw== X-Gm-Message-State: AOJu0YwVI9OuXqnqdjoEey2hCuenoVwQ/wODVhXJSyswZluaKnJ6645K oAuxyFqvzfyCQGjnBRy1j2VOfnoLk0bHb37WL++9WW0Ykt7ss+vwVYyKMivIOJ3zfJIQTpehcpS z4bc= X-Gm-Gg: ASbGncucbk87/NOMrLFmgSgMTBxtAKLqQUBgB8gDWe4ZgDSAiT0ZdpVnA3ngXbsLNct uGpK37QCDnKDX2gQy5vdet9z2j5AxpfVbrPy+//zIlbriw1e5KaLogZBWTr8qXvBN1DhJYyHDVe LnOe/Qxb7g00+3WBKpMIu3egr8Wt6LEEnLVojtp9Tw7f+z1OwzHld7xokzECh+sIChcrgQ0ufVo OJv2RCyKZcYymN/O4bSugpcDpii1XSrX+vCh90QtxN0MWBDIlNWNYoQc1n1mLbjbdO27mRX9slm hdAgLPuDTjSgcnQLwUJ82n4L9DC88kL3xXqs X-Received: by 2002:a05:6870:1644:b0:29d:c624:7cc4 with SMTP id 586e51a60fabf-29e8853ef9emr4671927fac.6.1733258397757; Tue, 03 Dec 2024 12:39:57 -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.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 12:39:57 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Subject: [PATCH 07/11] softfloat: Use parts_pick_nan in propagateFloatx80NaN Date: Tue, 3 Dec 2024 14:39:44 -0600 Message-ID: <20241203203949.483774-8-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::2a; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2a.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 Unpacking and repacking the parts may be slightly more work than we did before, but we get to reuse more code. For a code path handling exceptional values, this is an improvement. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- fpu/softfloat.c | 43 +++++-------------------------------------- 1 file changed, 5 insertions(+), 38 deletions(-) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 6ba1cfd32a..8de8d5f342 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -4928,48 +4928,15 @@ void normalizeFloatx80Subnormal(uint64_t aSig, int32_t *zExpPtr, floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b, float_status *status) { - bool aIsLargerSignificand; - FloatClass a_cls, b_cls; + FloatParts128 pa, pb, *pr; - /* This is not complete, but is good enough for pickNaN. */ - a_cls = (!floatx80_is_any_nan(a) - ? float_class_normal - : floatx80_is_signaling_nan(a, status) - ? float_class_snan - : float_class_qnan); - b_cls = (!floatx80_is_any_nan(b) - ? float_class_normal - : floatx80_is_signaling_nan(b, status) - ? float_class_snan - : float_class_qnan); - - if (is_snan(a_cls) || is_snan(b_cls)) { - float_raise(float_flag_invalid, status); - } - - if (status->default_nan_mode) { + if (!floatx80_unpack_canonical(&pa, a, status) || + !floatx80_unpack_canonical(&pb, b, status)) { return floatx80_default_nan(status); } - if (a.low < b.low) { - aIsLargerSignificand = 0; - } else if (b.low < a.low) { - aIsLargerSignificand = 1; - } else { - aIsLargerSignificand = (a.high < b.high) ? 1 : 0; - } - - if (pickNaN(a_cls, b_cls, aIsLargerSignificand, status)) { - if (is_snan(b_cls)) { - return floatx80_silence_nan(b, status); - } - return b; - } else { - if (is_snan(a_cls)) { - return floatx80_silence_nan(a, status); - } - return a; - } + pr = parts_pick_nan(&pa, &pb, status); + return floatx80_round_pack_canonical(pr, status); } /*----------------------------------------------------------------------------