From patchwork Tue Dec 3 20:39:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 846975 Delivered-To: patch@linaro.org Received: by 2002:a5d:44cd:0:b0:385:e875:8a9e with SMTP id z13csp714970wrr; Tue, 3 Dec 2024 12:40:54 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWFJk1QKFjKdkiaOcUT14QkfBd6w7wiVqPsivPVmjpysIdQ+XTz3kb9YvPcz6Fl4P2KvlgDdg==@linaro.org X-Google-Smtp-Source: AGHT+IFhBLqFDeRu4sg4ObAsB6C/w0g9Ua0zW+PXmcQ+Ncx9CwSpKYEtND0UuGx3gtC5CLBWi1Z0 X-Received: by 2002:a05:6214:5186:b0:6d8:8416:9c54 with SMTP id 6a1803df08f44-6d8b7366b8dmr65936006d6.16.1733258454780; Tue, 03 Dec 2024 12:40:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733258454; cv=none; d=google.com; s=arc-20240605; b=LEHDZeC+8u7B6Mno1aRGogYZBTCudwMiYEki1h7KGitcBAW451MEx48PToFpjhTgS/ hOyYEP/A5Y0Gp+hUFCK1hmLny2TT4ZQCTuhGWlEe8aaHBsYZUxcL1LpaT7RE2XiSmkJ/ xWmlU3jcZimrGqoA3ve/YZRuhhSohnzXPsNo05TeIpw0+NmfFZEAEcoGrGUzqcWRvNF2 2aTnT1gDbvB6HAzKIaeLTtWVQZfCVfQ+atxaNnOlfJtTguiws76EdTuXbsjz8l+2TOSy Pvd591IAxH2WCxT5s0awvsjc/TT0EW3E8GYodvAQ3m9WYPvcTK4IQDko6KMUYNUh++oN ERLA== 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=YMdz/R/XzxtV9sRyJPrRUrTNoKD74mGu1MDMytu4Vg0=; fh=UQCixiNfr28ZOrfhmxiGPA65dFhly8CmRsnoYC6xI9k=; b=HruesLlmydah36o5yycRAoiMSNdzmi1A93pexpY4/OTsesz5AgyzZjxA1OyANJ8mLH PxYy5lPp1LTmveYjsx63VqI3ky+hHlndyBcBjBbVD836y874ipDcDG/Ov5m/k5XYZ+BU aqDLRPvjEw2o7/ZYAWA44uHXzAOshGznJ+uuFSqzFdh1fJmJpvTI6id5IiXUIWGRn+9I dEmMyv38A6VEkrjU9BRZ6bHvKNi0NnQgGx9bFgcOBZWjaEK+LJ9udexPxh49GxxzVSCv yz2uybT4ArqgOyaNBLaia82JLxFcfLf1pD550IWDr6yA86aieFgJeDVM9XaX3D0LiPMv /kyA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TTiIIk6N; 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-6d8890a67fcsi111275736d6.379.2024.12.03.12.40.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Dec 2024 12:40:54 -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=TTiIIk6N; 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 1tIZgi-0001QM-6t; Tue, 03 Dec 2024 15:40:04 -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 1tIZga-0001KX-1c for qemu-devel@nongnu.org; Tue, 03 Dec 2024 15:39:56 -0500 Received: from mail-oi1-x230.google.com ([2607:f8b0:4864:20::230]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tIZgX-0003AR-GI for qemu-devel@nongnu.org; Tue, 03 Dec 2024 15:39:54 -0500 Received: by mail-oi1-x230.google.com with SMTP id 5614622812f47-3ead60cedb7so1477411b6e.1 for ; Tue, 03 Dec 2024 12:39:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733258392; x=1733863192; 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=YMdz/R/XzxtV9sRyJPrRUrTNoKD74mGu1MDMytu4Vg0=; b=TTiIIk6NaGfk3LhEM/KLPoJQXiWM5kDXTRN650gvoqBggpK8Qk+oUu1hyIz9lE2E9C xK2G+aJLKjKoLhBrziUZ/51eR5pUuNlA2JsQPp1HcnpWHFCRXUKCRySXr3C7GsWICXuM 81Nx5JIkD4uFhyBP4hFCqhAhU9opK88Q72dr/onvcZWgTPHqGt48YY1vz9AIw8jRH0Gm E2OHdy80yCeTJJp+TFnIivsd6WUL1vuhj51uXuIWSNtJn5E3K10pwbInro7vaCddolER zfTVLkAi+ULPWPSAHv5cMGsUeV0+h32tKIdid5Y5I2TPAQssmrDKWDNHW9IcQSuaJklf yTIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733258392; x=1733863192; 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=YMdz/R/XzxtV9sRyJPrRUrTNoKD74mGu1MDMytu4Vg0=; b=bkhQ0WZsON8uB3XCcdY7NQWpPMj7GLkZAXhc4HNCJESQWzAcdrol4Eglezywx13QWJ +aeC/knCBKnvZBFlQYLgXAlQBBxmeLHpAh8qbIooOMamSDOtZ5EbomEuDB1pjFm5ZaMO ZdC6LOER8uvSxMm8hr3KUpaM+Me2Mt1dkctqt4e/uECBX4qu2RjnBs53m4ic6eX+PtpP Kf/QLHZ0XcFfh817l/CunsD8+ZvB6VH66HIcbOXAdIBIfGL30s5u1MIaTZ/Pr/eifa+W tBDRT7ORMs66cgbXAgY9qUaxm6NRZlVmo0wehxYPjCanzZiPj0HqCXCth716syVZZ0pK v7BA== X-Gm-Message-State: AOJu0YyiGe36MYNIsQgWEZWYk/yxUDDl42HM46RohNCE9wGWbjbK5K4G ZiLm1s+t8ctcQ+0ZDe5g2D8ka6tFTA+Nz47hjYX24opOXURwHmxDUmHMeseKgtZJIiUvhD097G1 z8Ns= X-Gm-Gg: ASbGncvawp/8hlufWCVKZzRyOVyMEq/C+aNpL1uboTqVuVoDUaM83cwoJ1sutgv9iE7 ZhZO56GZOSiA1V5B/KG44ALFmRHFQkBStl7BND/v5H6D/BdlPlz5eN9ZAvXmBUI5qOKNeOHLXEL ThGTubd4pF/2XQ3PbKUpRdLg4CIjEmnmqfS51xSMJ01GUFAf66qigk1rthowonAPkUsNj/Bboi5 sS/YJ1B4FiqmrakiwG9dXXCC58Lef1/l3ybDz7unP4raYb3X5Fs1eNbwo71mf3syHU7L2h7zJfq 4OQ24T4+snMFiy8/Ly9Z/YPL8BPkaCPWHyAk X-Received: by 2002:a05:6870:ed8d:b0:287:4904:7125 with SMTP id 586e51a60fabf-29e885f8734mr4425833fac.14.1733258392167; Tue, 03 Dec 2024 12:39:52 -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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 12:39:51 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Subject: [PATCH 01/11] target/arm: Copy entire float_status in is_ebf Date: Tue, 3 Dec 2024 14:39:38 -0600 Message-ID: <20241203203949.483774-2-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=2607:f8b0:4864:20::230; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x230.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 Now that float_status has a bunch of fp parameters, it is easier to copy an existing structure than create one from scratch. Begin by copying the structure that corresponds to the FPSR and make only the adjustments required for BFloat16 semantics. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- target/arm/tcg/vec_helper.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/target/arm/tcg/vec_helper.c b/target/arm/tcg/vec_helper.c index e825d501a2..ad6f26545a 100644 --- a/target/arm/tcg/vec_helper.c +++ b/target/arm/tcg/vec_helper.c @@ -2813,25 +2813,19 @@ bool is_ebf(CPUARMState *env, float_status *statusp, float_status *oddstatusp) * no effect on AArch32 instructions. */ bool ebf = is_a64(env) && env->vfp.fpcr & FPCR_EBF; - *statusp = (float_status){ - .tininess_before_rounding = float_tininess_before_rounding, - .float_rounding_mode = float_round_to_odd_inf, - .flush_to_zero = true, - .flush_inputs_to_zero = true, - .default_nan_mode = true, - }; + + *statusp = env->vfp.fp_status; + set_default_nan_mode(true, statusp); if (ebf) { - float_status *fpst = &env->vfp.fp_status; - set_flush_to_zero(get_flush_to_zero(fpst), statusp); - set_flush_inputs_to_zero(get_flush_inputs_to_zero(fpst), statusp); - set_float_rounding_mode(get_float_rounding_mode(fpst), statusp); - /* EBF=1 needs to do a step with round-to-odd semantics */ *oddstatusp = *statusp; set_float_rounding_mode(float_round_to_odd, oddstatusp); + } else { + set_flush_to_zero(true, statusp); + set_flush_inputs_to_zero(true, statusp); + set_float_rounding_mode(float_round_to_odd_inf, statusp); } - return ebf; } 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. From patchwork Tue Dec 3 20:39:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 846972 Delivered-To: patch@linaro.org Received: by 2002:a5d:44cd:0:b0:385:e875:8a9e with SMTP id z13csp714911wrr; Tue, 3 Dec 2024 12:40:46 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCW5zAk9hkKwZrqEXJLfDkYfeaVA+QeRyhL2uY9Z4JS6WTclozjjMY+bi2YyuBOOAyrTeX6WOA==@linaro.org X-Google-Smtp-Source: AGHT+IHrNzokT9MCl1bNDwVdHF/YI4C1myeow8nrfzC9AcOi12ggGvoMsnn0QBH1Ig1+djIurUyH X-Received: by 2002:a05:620a:3902:b0:7a9:8679:993 with SMTP id af79cd13be357-7b6a5d52142mr393304485a.13.1733258446271; Tue, 03 Dec 2024 12:40:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733258446; cv=none; d=google.com; s=arc-20240605; b=U1tLlQxq5wh4cIvIC2wboGydUL1qJQdR7ZYYTKfEODltXS0pLsWDuDAXeQDo8rTZMI IcsSJyh6SutxO3cjQwAYJxbpvnwzfMCWh0whwvvYmL4Fbix9lZxBZVE5MOQ7K2RFGHgf sX4ZgIsccSktV0T+d9VyCSJ/jd3P1sZ/cQeeT7wT41PMBQy11mK7w1qdyueSIG5g300O tZTwLE3FsAXT0hqVaBTDE2VyNMFJUzSRv3N50uioUWZVroJWugmK4IVT6KkyPmYIWcud 5AT0tZhSpomEbqJ8i73Ic36iwA72xfX00Dyrk1hxnssnC1aQOmZ3wp+UVhm6yaP+euE3 NsuQ== 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=D37F/cHBY8ajgMOC8jexCpS0iZn1VRkSiMEiE7b+toE=; fh=UQCixiNfr28ZOrfhmxiGPA65dFhly8CmRsnoYC6xI9k=; b=Jsby7e0oo/gaqB2/N65qioo8sY8TlbUviiWWWW1KPdlYbYMmTfBes3XbYCIqtTBoBL 9AC+wuAk68r55n0yX4Lpq422SVtYL13Dp1S4taYL+4C3DrbuOReNws138WIwr1RsqpDh Fp8AGcgjtdm8b6NftZ0J1cvaMLUHPAB4IH1//pXCcVkoPzU5d0WkleHNlYwuCuZowJQU F9Tj0xHGrLQEFu0bomkJOe57AIbxBQW8UStblIAsxmFg2aQwgZEE6iEM1kAzJ6ibrt1q 21D9mgVW2PnwP3wDsCLNVTzieyfw/0eEc45746bVuciFh/6bVhE3ZaPmEWcNZyyF72qD sY6A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MR1+ZZs+; 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-7b6849b4070si1527662285a.260.2024.12.03.12.40.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Dec 2024 12:40:46 -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=MR1+ZZs+; 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 1tIZgi-0001Pq-7E; Tue, 03 Dec 2024 15:40:04 -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 1tIZgc-0001LA-Et for qemu-devel@nongnu.org; Tue, 03 Dec 2024 15:39:58 -0500 Received: from mail-oa1-x2b.google.com ([2001:4860:4864:20::2b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tIZgZ-0003Am-Qo for qemu-devel@nongnu.org; Tue, 03 Dec 2024 15:39:57 -0500 Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-27d0e994ae3so3547645fac.3 for ; Tue, 03 Dec 2024 12:39:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733258394; x=1733863194; 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=D37F/cHBY8ajgMOC8jexCpS0iZn1VRkSiMEiE7b+toE=; b=MR1+ZZs+2k9oa+xItIcaW7I2AzopaIp4ICpGuUnmU/BpxjKTDq7rcfq0+WU5FZI1n/ 7CTwtDkPpJBxc759AaaRZb4n+tVWP0w8OcxhyF1N4ZzuXVQfyoZe2MQyRNqMOnpb2jfu kVD667SnxQVtP0CCQOUyDpXzbalidc4mUcNUYf7g+w0MxNxaPqlaUDhNkCWfOPlR+xt+ saZTeJpG819RnMD+7O8cb1lBOxUQ8413u5v1eoxXXNB0qcbYrG7c2QMZf5Dqwrjo253m Y5NvSegyje0EBYNC3pt8v2vX2fzZ5xDek/AB8Rk2Bsydj3wv1A+Blbd9TseJcaHH+TwI GBkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733258394; x=1733863194; 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=D37F/cHBY8ajgMOC8jexCpS0iZn1VRkSiMEiE7b+toE=; b=YEdeyg22mETCgiMzIhMAqeKxIoo3YNYU6fHv2zGRTM9/18ebA/6Asp5A12C+b08Ppm 0UPUaNtWDPYIEvo6EiJb1he/FH3HNthgVTwFMB9oUVmk3keJGr9fZwTXBLG8m4h64eAu guMrRxYAVqKtNWqqGgRknkgSh9WgW00C76drjRyy5f3U9tCLvOe65mHkt+OnEq2UNUZ1 Iq2/lZckXndnch85CoRdnDQ2YbWmSe7akfb90UDrWifgg2579Hg17slzsQxwdFHpazL/ sTHnm3IJz8nLTwiJwQcKyjggC0buDCXAM2piC9fDZt8BNHhvl0/O9dJAZe8tLTO9jnjb 8Bgw== X-Gm-Message-State: AOJu0YzBKBVwmk/SJCdHN7xrJhJGXG/H4ZCNTdPHY1abRcjbBD204RUZ NIg1c/yzedAa36vUNrO+4K0C8gjNNXPdg4pjMXWkbGFO8mod6orTXVLCeoBHjwoJyz5PjeA0NSQ yq3c= X-Gm-Gg: ASbGnctxm9fUWN5+n6RM/5e0ynzaAmbdRWIHVhDEMZvpHboACP4i31WKmJZZe6bXmNP sww9uQEmvWKtj1D9VWLqwF8k2KVsRP44sLlbBhVdu7GEfRGqFrxONhXq/erHZDPZLcGhM46o75u uEzN6HpbRvm3TMsbeym7fMVFa4IQO9EKeQkINM6sDPA6Ylnql/b+AZrhhXU0fNpsFCrDgQ7Fnzw PSfcW+Vni/uQUL/VE0x9Sh4xDkEPJ5nzeB8sJOgGW2Pk6FpVq8amQ4aeSAdpWpQZvvo7sn6rH+a wICPEmFgiJ6iN6TnToj8Qq/J/q1Uq34FY7fe X-Received: by 2002:a05:6870:e0c8:b0:29e:3345:74ff with SMTP id 586e51a60fabf-29e886baf81mr5215810fac.23.1733258394221; Tue, 03 Dec 2024 12:39:54 -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.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 12:39:53 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Subject: [PATCH 03/11] softfloat: Use goto for default nan case in pick_nan_muladd Date: Tue, 3 Dec 2024 14:39:40 -0600 Message-ID: <20241203203949.483774-4-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::2b; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2b.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 Remove "3" as a special case for which and simply branch to return the desired value. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- fpu/softfloat-parts.c.inc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc index f5c6b21fee..6423e12406 100644 --- a/fpu/softfloat-parts.c.inc +++ b/fpu/softfloat-parts.c.inc @@ -79,7 +79,7 @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, } if (s->default_nan_mode) { - which = 3; + goto default_nan; } else if (infzero) { /* * Inf * 0 + NaN -- some implementations return the @@ -87,17 +87,18 @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, */ switch (s->float_infzeronan_rule) { case float_infzeronan_dnan_never: - which = 2; break; case float_infzeronan_dnan_always: - which = 3; - break; + goto default_nan; case float_infzeronan_dnan_if_qnan: - which = is_qnan(c->cls) ? 3 : 2; + if (is_qnan(c->cls)) { + goto default_nan; + } break; default: g_assert_not_reached(); } + which = 2; } else { FloatClass cls[3] = { a->cls, b->cls, c->cls }; Float3NaNPropRule rule = s->float_3nan_prop_rule; @@ -117,11 +118,6 @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, } } - if (which == 3) { - parts_default_nan(a, s); - return a; - } - switch (which) { case 0: break; @@ -138,6 +134,10 @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, parts_silence_nan(a, s); } return a; + + default_nan: + parts_default_nan(a, s); + return a; } /* From patchwork Tue Dec 3 20:39:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 846982 Delivered-To: patch@linaro.org Received: by 2002:a5d:44cd:0:b0:385:e875:8a9e with SMTP id z13csp715453wrr; Tue, 3 Dec 2024 12:42:20 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXoRejoFsBs0wUNLYkqmW3PfdBfUlN6Z6poOfyo7TF2ljJ3171Z/saOSL0FBoHft/3vGTx/lg==@linaro.org X-Google-Smtp-Source: AGHT+IGz4YSTh19BNcLuv49x0viY+gjxTfoOaqD+QHbHc3l/KLcpfO7k+bHIOSwStDwvOIPHcmJ/ X-Received: by 2002:a05:6359:45a4:b0:1ca:9dcc:e6b8 with SMTP id e5c5f4694b2df-1caeaaa518emr428944055d.10.1733258540113; Tue, 03 Dec 2024 12:42:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733258540; cv=none; d=google.com; s=arc-20240605; b=Dd4/7mCig9cDVxxNPcHaw2qnRZL2saDClNUkv16DqFvHdtuGdozGv2JBwVVvSCwilA 2wDsXS1CG6sKn7D39JGk+IFxPRdG+0aw5y2PgKHs0JFD+kLDQd4rClq5FT5Q0yAqgJmy j4VfbPlVp3AvNlV+8Zm6zmk1EVoAbKrAvdBNVKlBdArQTGhLi2BoHClQKzTCPeDvQvkD eVgQLmGpciDFKvdGSFYHN6skY/NuDbwIgRfWlw8u48/8jEtadh27ziv1aq0CEunNCnHW AG16Xw9imk5ptwGwEcilusbP2E33Ajkj31YTBAMF9LQyq6smRUIVfi+rvnF4UFj8C9a/ GfRA== 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=HxoUNyLc0dEDDQUspYmsgb0BaeY/3JixWBMZpMBDUos=; fh=UQCixiNfr28ZOrfhmxiGPA65dFhly8CmRsnoYC6xI9k=; b=OZEPzCLcmcL1PmutHBeRVg7ZmWZuMEP/Viv+528dgoIPpVtUu1Az8se1raUWth/Qcq brZ10fp98UfKVdbMsNWtIEcNDF6EhcaS8ea8DKyQHTocPq8W6xbztFXMTU6QwpQyenYg ym7a0RqBVLfF5bYDb4xM9L/TrVcuaZM2qwK/0YH4qM8cHsXDuoiuPIZ1rvLSr43WyMDQ tAs7Vl0FL6b6276WjE4erSgFWpJzwvGjoGqqP5T+++leyQupHpGjD6o3NSF2jWebbqf4 RpiAzYBHUDfp679N5us8eEJGrnvD1Oaw1U8soZBlem2DwNntw1PXd7+FxYBzQp1ug11E UTCg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="p/drL0Th"; 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-466c4256b2csi142070081cf.525.2024.12.03.12.42.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Dec 2024 12:42:20 -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="p/drL0Th"; 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-0001Yu-3z; 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 1tIZgd-0001LT-2E for qemu-devel@nongnu.org; Tue, 03 Dec 2024 15:40:00 -0500 Received: from mail-oa1-x2d.google.com ([2001:4860:4864:20::2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tIZga-0003As-UV for qemu-devel@nongnu.org; Tue, 03 Dec 2024 15:39:58 -0500 Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-29e5bf419ebso1564515fac.1 for ; Tue, 03 Dec 2024 12:39:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733258395; x=1733863195; 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=HxoUNyLc0dEDDQUspYmsgb0BaeY/3JixWBMZpMBDUos=; b=p/drL0ThAQJr0KFGIuGN9wo88HHdKek9SKBBvVsiAUvsgbDMiEPqANFG/Thu6Ls15+ IRz3+vyQMTwNAeRjSVpjdM1Amm1JzyGuZuGVjavg2kvxmeIXG5bk6TAyUDf8uRNejLT9 9pt/8JGfh97I5Lsn0sb7vorj1K7K6N6HKnPOt73YcZEKwLzPKt2pdq8vqcDyrBvcMESL zo5KDY3S4bMfLLY7Anxfm167NBJ2tzbsWG9joGELIJc0z/1hz1oaeer8KNKTA2vcavJ8 5bT71ITohoF0HgM0ztoT9ScG6j3E5SRpz8yP+l+nqQ5bscKNlyASJxsK/WIyvIK8Fbok IrrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733258395; x=1733863195; 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=HxoUNyLc0dEDDQUspYmsgb0BaeY/3JixWBMZpMBDUos=; b=Ej3dl1yMs+MqzNNX4RyT651tWu1kmbSYrXYnRGQla2dCBlcV3ASa3QUq5ThfFljuoO syTUmvdbblRHwJwOAO8SYAWl4187Njw8KWRhBGpipUz6Hf+NWS9ZVCd8UAY8s57oOBRx 69RZTNyHZwh/aegWOIthhs/5I8V2eNz7wbXkJMGOekfyKAdRc95DQarMerR5TBsTn8nG xxGPQlHJJR/fni0LTYHbiits3yXW6AGPF6RLElXAC8vpE7tUqy9pnYh7vQ0ub7R08FMw ec6lFk2MNx6C1DCpXBT0miHJOrOy1Ro0stwD/bX9hzpMOhqEOLAEqfVwc1l4eWIcbY7/ E7qg== X-Gm-Message-State: AOJu0YxjOvyRFu9338/DD98lrGM9r0guMJWiicpwzYL8N4QLjD8VE6CT 3+VSkS41bLYMPejqQPUeGKfvHnyl9jaBBjLJBMYHg63GmV7pki9DMu7elgC+ibpXF7Vxz+5ZWC4 Q4iI= X-Gm-Gg: ASbGncuAFjJenIWjnbEhW96VktYNpgfaCQaph+f3Ps69C/p0Nl0JQVPmYUzQjqLxd0r ZjinwZnR0NmVG9HpN5n09he9BVRmTd+4Pfe1UvUDFb90x8QwRrjt91H7B2qxTibtf6Ect/AsCXB NLbnU28mqu2KhkVl/D9Jn6M9SQH71Vlqgz/uQwXd5y13v2syeQrihlks5nwG/AeES7btMrm5/a0 VnhuS6m5axOKGNoCBkk9H5GE2SH4gLIow0mqoDvTIzHZTPPDTZJie8PDHg9fVrI8mXyycFX63IE Et/3bNy/CX19+1zx7qdDQc0o8IPxFQcTBKne X-Received: by 2002:a05:6871:10d:b0:29e:20c4:2217 with SMTP id 586e51a60fabf-29e888949cfmr4315626fac.33.1733258394905; Tue, 03 Dec 2024 12:39:54 -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.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 12:39:54 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Subject: [PATCH 04/11] softfloat: Remove which from parts_pick_nan_muladd Date: Tue, 3 Dec 2024 14:39:41 -0600 Message-ID: <20241203203949.483774-5-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::2d; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2d.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 Assign the pointer return value to 'a' directly, rather than going through an intermediary index. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- fpu/softfloat-parts.c.inc | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc index 6423e12406..77f16ac158 100644 --- a/fpu/softfloat-parts.c.inc +++ b/fpu/softfloat-parts.c.inc @@ -65,9 +65,9 @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, FloatPartsN *c, float_status *s, int ab_mask, int abc_mask) { - int which; bool infzero = (ab_mask == float_cmask_infzero); bool have_snan = (abc_mask & float_cmask_snan); + FloatPartsN *ret; if (unlikely(have_snan)) { float_raise(float_flag_invalid | float_flag_invalid_snan, s); @@ -98,42 +98,30 @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, default: g_assert_not_reached(); } - which = 2; + ret = c; } else { - FloatClass cls[3] = { a->cls, b->cls, c->cls }; + FloatPartsN *val[3] = { a, b, c }; 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; + ret = val[rule & R_3NAN_1ST_MASK]; rule >>= R_3NAN_1ST_LENGTH; - } while (!is_snan(cls[which])); + } while (!is_snan(ret->cls)); } else { do { - which = rule & R_3NAN_1ST_MASK; + ret = val[rule & R_3NAN_1ST_MASK]; rule >>= R_3NAN_1ST_LENGTH; - } while (!is_nan(cls[which])); + } while (!is_nan(ret->cls)); } } - switch (which) { - case 0: - break; - case 1: - a = b; - break; - case 2: - a = c; - break; - default: - g_assert_not_reached(); + if (is_snan(ret->cls)) { + parts_silence_nan(ret, s); } - if (is_snan(a->cls)) { - parts_silence_nan(a, s); - } - return a; + return ret; default_nan: parts_default_nan(a, s); From patchwork Tue Dec 3 20:39:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 846981 Delivered-To: patch@linaro.org Received: by 2002:a5d:44cd:0:b0:385:e875:8a9e with SMTP id z13csp715451wrr; Tue, 3 Dec 2024 12:42:20 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWQ9HfVBIZ1tAllezkusdQknM93PZK1ITW1anTZVPZLw56DSkTmAMbq30toVaNSZY7exbFMVQ==@linaro.org X-Google-Smtp-Source: AGHT+IFgFvHT4lt3qEMr05QtEZelE0lnMsnvU+IMcj9iHCFj6TGT0QDP50JNnd5fBosDQQEVXxtu X-Received: by 2002:ad4:596c:0:b0:6d8:b594:c590 with SMTP id 6a1803df08f44-6d8b72e08cemr52777106d6.6.1733258539852; Tue, 03 Dec 2024 12:42:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733258539; cv=none; d=google.com; s=arc-20240605; b=MWxdnUauWUzIuMT7Bw5wWRz6BCrN1xY18V1+uR5h35S3wwH821gDmAMwQfpudJTpzI DvAH42UZKAue4umzbuvxqUAQcBklc5Y+f2XHxiiXaHkn9J2C7MyJLbKAWMbqzr6Kyvyo JmLtxDru9YP8NkA8MXaYAKiRmSePBKUAAkJJdcOhtjytf93amYmem6T7gjISTKdbtZCF oVXImIV5PKY6kfh+qGyAddbyNiCbrMTg5uMuaXvPYO4S8hVvQR0pIqbnajoFm3g6MTwF uuRf2/d6wgVcf6XO2UB8BDo6u9/iYo6VR2z9/akjmVcql+dT1DCxkyc9DNmccSyMCcsF LcdQ== 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=VtJU01uIPGdmdncl+3eL+uuul8VbLmsEdgS8yMmO9ow=; fh=UQCixiNfr28ZOrfhmxiGPA65dFhly8CmRsnoYC6xI9k=; b=LSq8qOo4zJv+jZiMQnmP7DVil+2RvVua/ie+PM0k2qJvEpgErlLLz/uQjZ8aX2pBBC QN5caVkxU+VgchhnPuSahDVYh8XqvvUiB8TOVtF4o9jrNAqHVEdfr3ztT92pgsVH7SfD a06CNcG0Q+1P5MRps7BH2+6S29CVNIL5NSF38G8vfQBaSA4arMVqn3aL5FBTC5D9uFPf i8GaHxG2wTVQTfNSwLIP0Hr8IQcMZ5tN51PdsYv0jwEUZSMwPnE8l6F1+n75Y73rJsjh bhfYrWTBVV1Z6cdT3olRwchf1z6wRyB7Ufe4NBF1YSt+VXYXc3MHuEDYml+0ZLvUqy7Z bdcg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VbhBZIMA; 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-6d88570a35asi123811346d6.294.2024.12.03.12.42.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Dec 2024 12:42:19 -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=VbhBZIMA; 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-0001bp-DJ; 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 1tIZgd-0001LU-2h for qemu-devel@nongnu.org; Tue, 03 Dec 2024 15:40:00 -0500 Received: from mail-oa1-x31.google.com ([2001:4860:4864:20::31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tIZga-0003B7-VH for qemu-devel@nongnu.org; Tue, 03 Dec 2024 15:39:58 -0500 Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-29e61fcc3d2so2551078fac.2 for ; Tue, 03 Dec 2024 12:39:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733258395; x=1733863195; 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=VtJU01uIPGdmdncl+3eL+uuul8VbLmsEdgS8yMmO9ow=; b=VbhBZIMAD/9Q6LJbcateQyqFgJJcYmArYdsGIRKYMX4smux/tHs3e6f9wBcdmGJ/mH i0LMp8xypiszFbkdi2F4/t/B8j3eEeZHYmqwAgPc3ZGbynFWAapWHrwwyx7PoVONHUWg StAQwfAKpPE8R2jhDFsF/3X6mXmJSmuU/S0DFsF9wHDjmUjtWGDLx/D5R+YDufduK1l8 evZ7SqofsAOXr3CgiPgj3l6beOylWkmbGTVHfaNlaU7E8C45P7praVaUTd8dPQFO6miq LtfHcnxwqgY6anexMJUgd+4h05FceI+afHxNuGXX05yM0Quh1SY9vbKTuwRfj7ZeuOa/ ArGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733258395; x=1733863195; 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=VtJU01uIPGdmdncl+3eL+uuul8VbLmsEdgS8yMmO9ow=; b=bkiVeUdsFW6wkphJZEQrG2uSoS2rNO6cqAJD+m+yVWvHYA4ZRJ6jdzcEEDwjBtiIij vYo0IpfsBOiMpgFAjjYKAenMEJwytLGtMM7Ybo+qo/MT16RiHBNKspimDgfFYlR4O/x+ SDBZbWyA44SQIuyZ6IHcAQucc3E1fwzg4nlsyAMMUvO9Exw/6UXi9rUdMX+esRwMTQmc xFndwD2DxV/EMvvcHl1JBgror7+c2AtLcbnvy4Xi/bOYBeeRu4WjR/lGJqk2vDGwVlpD 3kunL/WfX4QETOk4MXKMvVMzOpaM/av9bI6rsVKW8cHZQ0edJpYorg4if1V75xRNAljC SYjA== X-Gm-Message-State: AOJu0YyWZE1+3/LbQRROaJaylWAVRvmUrF8Mtra7EXfnFJn+l94/nEaq vOPUldwhI6ngCiJI81vKWuzE5Dqufg7hL2tXzBn6Gtg+n4DobqFu10jcfgIQ8jXUChq+hQZ8rgP A2SM= X-Gm-Gg: ASbGncu0xL2LjRxX1bbo8IKITudx8WaFBjZAPfGEX+aSwjThu27tyo6t6NeazrlZNws e6yO4/sTMaPoWl+TowvRgcYclKW2Cj7kIbcE4L9vK/6kSJ1F+fYC6HJ8wk2aCMTV2lhhLR7YRgu eKWR2nMVFIDIYCKslU0KwMIZSgF58Uu76N5Md1WaiAKLOMO50x5xKGngQ/FxtoUmJp8tN2LeUAA QmL+5Rph9jKiNH1oZB0njNSvV5aEvD1GFdpV/tNpsPmHJHfOA8Qc6AMSX7XOPW9gfWbDzwfXEzx tICCfhqtczStROAbEb+Tr+bSFfTn/0BjRTc3 X-Received: by 2002:a05:6870:4944:b0:29d:c5e8:e41f with SMTP id 586e51a60fabf-29e88576409mr4735052fac.5.1733258395680; Tue, 03 Dec 2024 12:39:55 -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.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 12:39:55 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Subject: [PATCH 05/11] softfloat: Pad array size in pick_nan_muladd Date: Tue, 3 Dec 2024 14:39:42 -0600 Message-ID: <20241203203949.483774-6-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::31; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x31.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 While all indices into val[] should be in [0-2], the mask applied is two bits. To help static analysis see there is no possibility of read beyond the end of the array, pad the array to 4 entries, with the final being (implicitly) NULL. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- fpu/softfloat-parts.c.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc index 77f16ac158..06cfc6abb5 100644 --- a/fpu/softfloat-parts.c.inc +++ b/fpu/softfloat-parts.c.inc @@ -100,7 +100,7 @@ static FloatPartsN *partsN(pick_nan_muladd)(FloatPartsN *a, FloatPartsN *b, } ret = c; } else { - FloatPartsN *val[3] = { a, b, c }; + FloatPartsN *val[R_3NAN_1ST_MASK + 1] = { a, b, c }; Float3NaNPropRule rule = s->float_3nan_prop_rule; assert(rule != float_3nan_prop_none); From patchwork Tue Dec 3 20:39:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 846979 Delivered-To: patch@linaro.org Received: by 2002:a5d:44cd:0:b0:385:e875:8a9e with SMTP id z13csp715356wrr; Tue, 3 Dec 2024 12:42:01 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVLJE/ZIis6Lt7+SfrKgJbrk45P5Uo3ZqnhVTfZW2q6gR18e0zue2NMnxfIICrd4rLfNk2a+w==@linaro.org X-Google-Smtp-Source: AGHT+IEsJcYd4kLBhC60KmNwY1LpHWdpjAufOQWyJ/uCBb4YH1bsdsGW9vmcJfAVTcnG/8cz9YMO X-Received: by 2002:a05:622a:252:b0:45f:788:b1b1 with SMTP id d75a77b69052e-4670c0b884fmr42489931cf.25.1733258520679; Tue, 03 Dec 2024 12:42:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733258520; cv=none; d=google.com; s=arc-20240605; b=EcP4kt3zk7R7B9AFn1CpEGHCfH+47WAk+J8J7/LbTju3AGdJEVQMG0QlFD/lDRCSgi o6Mxmm9Q4wlV/nS9UeGvp8audTJluWP/JcflyHIWnsXScg9my/Mg5Dt5MyPpfMgIKVkc vi8BZfzw6dwraBcQ+lCtxq8d4H79Dkw7P6U3TS2p0OVKyhXbdhj5gCKo17eddEdKqqbi eQoz0jfFGtZKsWyBybkwDtI3nl0QUr0Ty2xNu8y+kcdDKQwBq6HehGR8SFOxonM92mZ4 ZNGpGUhEr5QegalyjqMuLanff7v+e80q6GVXSsTKepR4/9eKC5wzbcwjQCnaWr6Dnn3o ACbg== 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=O/WrKqelHnCbtbsQVD2Xt769eF5XVcZugiQlkdqiXsE=; fh=UQCixiNfr28ZOrfhmxiGPA65dFhly8CmRsnoYC6xI9k=; b=XHAwZpEAnbyMgVEGBLW/I/KrOw7YNgWPqgtJGsgdNi31dorvu+F8LYMn674u6gflqA 2ynwLuiL6nQZdjRszYvY8lkrsYW7NX+9GGxRV6FflDfNnw1yhxE5kG4oiYF/kjGQ6Rx3 wsdy4aX3hdpxBB2nDPmWWY+PnDNT2NKwO5yvk8A73NJkwcfbDvbyywvq92hg0JT0PLLC 4sIKg++uz1zIxuAmJXnAV9xtZbHwVmdmFlXlFzFh8PmeqX0RLagLK4V5Bhtws2p53Hew F8eNvdaDYn/Kz7gQ2JBr0TnHm/uNLM2Peu517EDIIuI+2N5aPiLPsszgUlO+GW00sLKT ZZEQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WuoUtc+k; 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-466c4104d03si152346821cf.350.2024.12.03.12.42.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Dec 2024 12:42:00 -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=WuoUtc+k; 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 1tIZhE-0001hM-Lu; Tue, 03 Dec 2024 15:40: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 1tIZge-0001OX-7l for qemu-devel@nongnu.org; Tue, 03 Dec 2024 15:40:00 -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 1tIZgc-0003BH-7R for qemu-devel@nongnu.org; Tue, 03 Dec 2024 15:40:00 -0500 Received: by mail-oa1-x2e.google.com with SMTP id 586e51a60fabf-29e5c0c46c3so2265677fac.3 for ; Tue, 03 Dec 2024 12:39:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733258397; x=1733863197; 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=O/WrKqelHnCbtbsQVD2Xt769eF5XVcZugiQlkdqiXsE=; b=WuoUtc+kGPc9t0t7a+YlRfqJ6rgPr2QZWU/oiGcmwPjZZ5c+31ubnjgB+GPENwQNka X2Hqa4wKL1jGBoed8LWfaQ+k1jA455xGsedbbJjDGQm1AlVKZLR+hCxew84AgTEtjPjP JPqlNiZ4UaIhaE4nXS1i+AwtAZ6FcWb07QmlvLYNIuVMIy++WKoXHzEd7W36i16QB+Jm CLpRfaopU5kyS2J00UImVr7cxvVw4wHcmMNEh9ugfKcNdDQB7B9/n4a/JgyWUowArk3N py42ncLmeOsbLnhYLPezHfTs0xX3L90KLAeOhKJEwTxHuRK128jHGf3hV52L7XsFu6R+ C1Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733258397; x=1733863197; 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=O/WrKqelHnCbtbsQVD2Xt769eF5XVcZugiQlkdqiXsE=; b=umQYbtL1838Gb/RkjEIwxFgMGFPYIPFLnujDMa3/WFkl9+YzG28DTzeiDyjZhEbYIK bYe2CEVFC68bS3skNv5TVSYsfYanFAryq9+ep8C5HebtomSMFBvHmhPNy1wcKS6V4Tjv Q+5Hr02phyZP2vr6UWsgPbfUmaVTGBU+efwBwBpNLZ4gCvEBZVP8m/BgcIs4Y4RMe3nP R6J2MIaz4JuX44jjQ7S4AhO7pxMYhT1kFCHASo6xFXlyZC7bPtWx4WCccKcLlocFBoI0 D+/Fcw2LXxvctBm/zBOfnMUU7xzdIGLkn+MMn30le4Rl1rpbVSPTYwDLEcrzZvUanSwD XuBw== X-Gm-Message-State: AOJu0YxmSmARcBsaNoMPO/ZqTvaxoj/FtFzTRMPEXM562cU1ugTT3gKI kPBDbBxq72b+DOwy2ORpcBLemv4glgD/idvxKpUQSny8uYiHSQFjjKrL+IhJx/xBIl0+abdXdbT mKdE= X-Gm-Gg: ASbGncsPb3UA4LcpTvEQ84Z/pxghRIJ/LQFLAlC7OulqRCmTUHqlniB+bdTxwLDr1df gkvIBeBAAWn1ZG8uO99F+Tmaa/EK8BPqUQDZhwW/GENJXdGLhRepCQhNBIZaLug8+oHK2dpzHh0 iOlYG7GKHe/Z5V6s7WikaD5SCOV0B1t1J5rdLiP4zs7OwbmhZmuMFhFPAed5dMFwhheG2PcNgfd pMh0jP5pCTFESYWAGh0Gcj2bBsu4Te+Ah7Lvwg9DRHgSDj1SGu1p/QohlvZ7og3u3Tr4zCIuwEk tNbdP/mgx2dDleaRQ8rKPBXNrYEwOMUG60di X-Received: by 2002:a05:6870:8a08:b0:29e:5a89:8ed8 with SMTP id 586e51a60fabf-29e8863a36emr4100834fac.11.1733258396717; Tue, 03 Dec 2024 12:39:56 -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.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 12:39:56 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Subject: [PATCH 06/11] softfloat: Move propagateFloatx80NaN to softfloat.c Date: Tue, 3 Dec 2024 14:39:43 -0600 Message-ID: <20241203203949.483774-7-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 This function is part of the public interface and is not "specialized" to any target in any way. Signed-off-by: Richard Henderson --- fpu/softfloat.c | 52 ++++++++++++++++++++++++++++++++++ fpu/softfloat-specialize.c.inc | 52 ---------------------------------- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 027a8e576d..6ba1cfd32a 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -4920,6 +4920,58 @@ void normalizeFloatx80Subnormal(uint64_t aSig, int32_t *zExpPtr, *zExpPtr = 1 - shiftCount; } +/*---------------------------------------------------------------------------- +| Takes two extended double-precision floating-point values `a' and `b', one +| of which is a NaN, and returns the appropriate NaN result. If either `a' or +| `b' is a signaling NaN, the invalid exception is raised. +*----------------------------------------------------------------------------*/ + +floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b, float_status *status) +{ + bool aIsLargerSignificand; + FloatClass a_cls, b_cls; + + /* 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) { + 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; + } +} + /*---------------------------------------------------------------------------- | Takes an abstract floating-point value having sign `zSign', exponent `zExp', | and extended significand formed by the concatenation of `zSig0' and `zSig1', diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc index f26458eaa3..f7a320f6ff 100644 --- a/fpu/softfloat-specialize.c.inc +++ b/fpu/softfloat-specialize.c.inc @@ -551,58 +551,6 @@ floatx80 floatx80_silence_nan(floatx80 a, float_status *status) return a; } -/*---------------------------------------------------------------------------- -| Takes two extended double-precision floating-point values `a' and `b', one -| of which is a NaN, and returns the appropriate NaN result. If either `a' or -| `b' is a signaling NaN, the invalid exception is raised. -*----------------------------------------------------------------------------*/ - -floatx80 propagateFloatx80NaN(floatx80 a, floatx80 b, float_status *status) -{ - bool aIsLargerSignificand; - FloatClass a_cls, b_cls; - - /* 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) { - 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; - } -} - /*---------------------------------------------------------------------------- | Returns 1 if the quadruple-precision floating-point value `a' is a quiet | NaN; otherwise returns 0. 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 --- 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); } /*---------------------------------------------------------------------------- From patchwork Tue Dec 3 20:39:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 846973 Delivered-To: patch@linaro.org Received: by 2002:a5d:44cd:0:b0:385:e875:8a9e with SMTP id z13csp714926wrr; Tue, 3 Dec 2024 12:40:48 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWPae0cRmZ/gtGoC+eskpfbSn94EgBj7eLlG3fwLVmCpaYAa/mdRR/N8W5XacbMn19zBWbjqw==@linaro.org X-Google-Smtp-Source: AGHT+IFPyfHkf/85JOzJ/fa9+s2GNlpXQjgIcaZK6wzVcCMSzcroxhsROMTHlAVWaMn9AnGs9ys5 X-Received: by 2002:a05:622a:6203:b0:466:afb6:6602 with SMTP id d75a77b69052e-46717cdfafcmr31274681cf.49.1733258448036; Tue, 03 Dec 2024 12:40:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733258448; cv=none; d=google.com; s=arc-20240605; b=TvjcL+efo2oINoF18eI1e3xVTQSzovHmpN/4MfsRCFTxHVOkV0PAnHlmyyQ5x+fj+q QNPG/kJ+SjIfydB7KeL91q0Q6RAoi8zsPPcjK/QY539ZVy8BNnEvR40wKa9dxYQeypce 7yAPSIliCT1Y3wBeUWirlDkJyuHREBhfITvNwr4WmQLqF81mwZqJNxLbjVQcuKmEW6/4 rtvLMkSoAnosnoKrwYAL39W0LfY/AwhC4xnVpgijMcvNKDMr7TNCn9M7XshUVgqxyb0e xpbuP39vgGsoF2XUCoYDU9vP15mp8jh6D3u3d6gX09N0d4no7crtxp7Eblu4HOwBYUvk UFdA== 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=vE9Xl02UsRFXlQRaYTkoaksxQH+Xcw8LkQwIo9WLMj4=; fh=UQCixiNfr28ZOrfhmxiGPA65dFhly8CmRsnoYC6xI9k=; b=QVHpwILTbPS5+X2ZoxO0LOnyC0v87RvQK4Q4GtAeogBcqeB2FxFn6bQaBv0cfJpCGs rJiVqJMpUJ22FuYLg4KgCqX1JkNGhnUAox+DCErY5ATQK6MjHPUaAGdp9q3k+cNoom1U jZfvP9HdqXc7t1v+Ileipm5ByC6JAHiomQay3KBDF0P/4e/C+MVxfFQ/Ke89vO/misNC y0imwZe3l67pBvDyQehatfH3V9sJrNNmZDoQ1D5DmwZzCUSIi2SOqoy8qyNedqnDA1tw tnN89rVu/8zBvcTYbg8+6AgPysZnrs7TrrP/yL+OSkRM9Aw97j0hLgLRgP1Ibfsf1S7i BRaw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Aqdk3YRo; 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-466d78322e6si129286931cf.127.2024.12.03.12.40.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Dec 2024 12:40:48 -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=Aqdk3YRo; 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 1tIZh9-0001cd-0h; Tue, 03 Dec 2024 15:40:31 -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 1tIZgh-0001Qo-L9 for qemu-devel@nongnu.org; Tue, 03 Dec 2024 15:40:04 -0500 Received: from mail-oi1-x22b.google.com ([2607:f8b0:4864:20::22b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tIZgd-0003Bu-V5 for qemu-devel@nongnu.org; Tue, 03 Dec 2024 15:40:01 -0500 Received: by mail-oi1-x22b.google.com with SMTP id 5614622812f47-3ea36b05654so3055760b6e.1 for ; Tue, 03 Dec 2024 12:39:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733258399; x=1733863199; 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=vE9Xl02UsRFXlQRaYTkoaksxQH+Xcw8LkQwIo9WLMj4=; b=Aqdk3YRoihF5I5Sm2EzaMdqKOmvHTL3Oy9a7UT13m6rwgmuggvay56dC+6Bdp8wIcH Z6r3+TJFb3uGHNuWl/fV/36JPNGlq6nLnnwzzqVmEzbtJBBX3H/7a5gSFVJ3DLNwuhkF j5EgG3PeI2x9a1YTRZZOqwznNn6mkqcFa+H+Up1BLl31qOtf3Tmc/ftCPTchLd+fAnws XTenH01nhpBAMJDQkhGzr4Yo4QRwm/tiaRxn47LICuXaplTWZiTsvsGnvlqbCJlSDXeX n3kj471hpgG9ggtiR9yQu+16I18QveuDNpjVXYuTx6ilzX231GvZ72o3dHI4kCXfrfdm IiSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733258399; x=1733863199; 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=vE9Xl02UsRFXlQRaYTkoaksxQH+Xcw8LkQwIo9WLMj4=; b=vv9gfK2S6hzRk4mPIC9up7ZkjFWPF9HKQZKCuL1Cg1NvlOqKIoa/pXM8reT/8F6e79 X9f27QuJpwPJx4kW6ZXKTotUUZZEnfw790cdVMh3C6ZSeYSBWntRpiNnKlItt1Y6rVJy Sq6V31y8u2RzUsEmdxCjWDqVfN8gl6dLEb+6lQDM0HG5zaWcikRpiRo2KfMYIjRCsEU+ OvPRZPvu3b+Io4Yh8n5/kdJFZVOIcknhlU3xLNbmyJ+2fA1HmtyuR7/Lkb6WJoICW6JO JsglCr6kBmzTWR6EB1M+e6scvz+T5A4pkgYi3QM0k9hd8cI2t6Pwr09a6V0w4aU128BD jKHw== X-Gm-Message-State: AOJu0YxCjF9Y0dSZaivkLIiFrfa2iPO6Z7VTkf2QZWB7nyUXsDY2gatt MbcgI3NtPUE5u0s7jqK4bH8vVmb2PQ06jSO3Fc50kRHKjON0Ss9UO4p3X5xPnf8uQlNk2YQnpR3 Gvio= X-Gm-Gg: ASbGnctIy/8RA/q368xORJB3wWjOWbE9W4DK31aMcUw8bld1tvV9pZe7+63Py8YZk1U is3YRYs6DKHJAXRCeKZvHoSU0BDVXUL047y1FBr6yfTM+QKUnRY3lZHiO2Es/M7kRm9F+fhr5wa UOZZn90rcCjdw7E7meb96BOPYKd4/XOguEZW031BY+oQUr8yB2L4MKgAX7g1F/18+S+8LVp/uuH GIp/CxBBFgBQW+pfsnHcpqUnS21AY79wJbEH7brnFTVmsPSQdESfsp/VT9F1EYjphds0fPvh3CI jNBJ6K6usZnI5mnZQwNEYLniUa+LGkeIq87p X-Received: by 2002:a05:6808:17a8:b0:3e7:5af6:af0f with SMTP id 5614622812f47-3eaf04252cbmr910702b6e.39.1733258398717; Tue, 03 Dec 2024 12:39:58 -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.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 12:39:58 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Subject: [PATCH 08/11] softfloat: Inline pickNaN Date: Tue, 3 Dec 2024 14:39:45 -0600 Message-ID: <20241203203949.483774-9-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=2607:f8b0:4864:20::22b; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x22b.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 pickNaN 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 | 82 +++++++++++++++++++++++++---- fpu/softfloat-specialize.c.inc | 96 ---------------------------------- 2 files changed, 73 insertions(+), 105 deletions(-) diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc index 06cfc6abb5..de51097dcf 100644 --- a/fpu/softfloat-parts.c.inc +++ b/fpu/softfloat-parts.c.inc @@ -39,24 +39,88 @@ static void partsN(return_nan)(FloatPartsN *a, float_status *s) static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b, float_status *s) { + int cmp, which; + if (is_snan(a->cls) || is_snan(b->cls)) { float_raise(float_flag_invalid | float_flag_invalid_snan, s); } if (s->default_nan_mode) { parts_default_nan(a, s); - } else { - int cmp = frac_cmp(a, b); - if (cmp == 0) { - cmp = a->sign < b->sign; - } + return a; + } - if (pickNaN(a->cls, b->cls, cmp > 0, s)) { - a = b; - } + cmp = frac_cmp(a, b); + if (cmp == 0) { + cmp = a->sign < b->sign; + } + + switch (s->float_2nan_prop_rule) { + case float_2nan_prop_s_ab: if (is_snan(a->cls)) { - parts_silence_nan(a, s); + which = 0; + } else if (is_snan(b->cls)) { + which = 1; + } else if (is_qnan(a->cls)) { + which = 0; + } else { + which = 1; } + break; + case float_2nan_prop_s_ba: + if (is_snan(b->cls)) { + which = 1; + } else if (is_snan(a->cls)) { + which = 0; + } else if (is_qnan(b->cls)) { + which = 1; + } else { + which = 0; + } + break; + case float_2nan_prop_ab: + which = is_nan(a->cls) ? 0 : 1; + break; + case float_2nan_prop_ba: + which = is_nan(b->cls) ? 1 : 0; + break; + case float_2nan_prop_x87: + /* + * This implements x87 NaN propagation rules: + * SNaN + QNaN => return the QNaN + * two SNaNs => return the one with the larger significand, silenced + * two QNaNs => return the one with the larger significand + * SNaN and a non-NaN => return the SNaN, silenced + * QNaN and a non-NaN => return the QNaN + * + * If we get down to comparing significands and they are the same, + * return the NaN with the positive sign bit (if any). + */ + if (is_snan(a->cls)) { + if (is_snan(b->cls)) { + which = cmp > 0 ? 0 : 1; + } else { + which = is_qnan(b->cls) ? 1 : 0; + } + } else if (is_qnan(a->cls)) { + if (is_snan(b->cls) || !is_qnan(b->cls)) { + which = 0; + } else { + which = cmp > 0 ? 0 : 1; + } + } else { + which = 1; + } + break; + default: + g_assert_not_reached(); + } + + if (which) { + a = b; + } + if (is_snan(a->cls)) { + parts_silence_nan(a, s); } return a; } diff --git a/fpu/softfloat-specialize.c.inc b/fpu/softfloat-specialize.c.inc index f7a320f6ff..cbbbab52ba 100644 --- a/fpu/softfloat-specialize.c.inc +++ b/fpu/softfloat-specialize.c.inc @@ -352,102 +352,6 @@ bool float32_is_signaling_nan(float32 a_, float_status *status) } } -/*---------------------------------------------------------------------------- -| Select which NaN to propagate for a two-input operation. -| IEEE754 doesn't specify all the details of this, so the -| algorithm is target-specific. -| The routine is passed various bits of information about the -| two NaNs and should return 0 to select NaN a and 1 for NaN b. -| Note that signalling NaNs are always squashed to quiet NaNs -| by the caller, by calling floatXX_silence_nan() before -| returning them. -| -| aIsLargerSignificand is only valid if both a and b are NaNs -| of some kind, and is true if a has the larger significand, -| or if both a and b have the same significand but a is -| positive but b is negative. It is only needed for the x87 -| tie-break rule. -*----------------------------------------------------------------------------*/ - -static int pickNaN(FloatClass a_cls, FloatClass b_cls, - bool aIsLargerSignificand, float_status *status) -{ - /* - * 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 via set_float_2nan_prop_rule(). - */ - assert(!status->default_nan_mode); - - switch (status->float_2nan_prop_rule) { - case float_2nan_prop_s_ab: - if (is_snan(a_cls)) { - return 0; - } else if (is_snan(b_cls)) { - return 1; - } else if (is_qnan(a_cls)) { - return 0; - } else { - return 1; - } - break; - case float_2nan_prop_s_ba: - if (is_snan(b_cls)) { - return 1; - } else if (is_snan(a_cls)) { - return 0; - } else if (is_qnan(b_cls)) { - return 1; - } else { - return 0; - } - break; - case float_2nan_prop_ab: - if (is_nan(a_cls)) { - return 0; - } else { - return 1; - } - break; - case float_2nan_prop_ba: - if (is_nan(b_cls)) { - return 1; - } else { - return 0; - } - break; - case float_2nan_prop_x87: - /* - * This implements x87 NaN propagation rules: - * SNaN + QNaN => return the QNaN - * two SNaNs => return the one with the larger significand, silenced - * two QNaNs => return the one with the larger significand - * SNaN and a non-NaN => return the SNaN, silenced - * QNaN and a non-NaN => return the QNaN - * - * If we get down to comparing significands and they are the same, - * return the NaN with the positive sign bit (if any). - */ - if (is_snan(a_cls)) { - if (is_snan(b_cls)) { - return aIsLargerSignificand ? 0 : 1; - } - return is_qnan(b_cls) ? 1 : 0; - } else if (is_qnan(a_cls)) { - if (is_snan(b_cls) || !is_qnan(b_cls)) { - return 0; - } else { - return aIsLargerSignificand ? 0 : 1; - } - } else { - return 1; - } - default: - g_assert_not_reached(); - } -} - /*---------------------------------------------------------------------------- | Returns 1 if the double-precision floating-point value `a' is a quiet | NaN; otherwise returns 0. From patchwork Tue Dec 3 20:39:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 846976 Delivered-To: patch@linaro.org Received: by 2002:a5d:44cd:0:b0:385:e875:8a9e with SMTP id z13csp714989wrr; Tue, 3 Dec 2024 12:40:58 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV91+YF0dhWT2E151R7CzVNdj3TrFjPX9f2KFykqpVurdDxAk0iKam7qQQNDRvSAzCTLb95fw==@linaro.org X-Google-Smtp-Source: AGHT+IGJyZuzK+xAJGgeGJgehwmtRP0+4sBESTVfYmBUs39adWMwb/lFHjVZirRVv3OITT+L2kAA X-Received: by 2002:a05:6214:d8e:b0:6d8:9e64:c9d3 with SMTP id 6a1803df08f44-6d8b742be52mr61518216d6.30.1733258457993; Tue, 03 Dec 2024 12:40:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733258457; cv=none; d=google.com; s=arc-20240605; b=UY6lw3s2jw/eusQ/qMGMopfgTULj9hjJA7wmU0nYXG+poNSAmjT5NjOJAumcBCGD+6 QHFoPyCqeGU2jAJ3vtIFBkPfxo9uEJGVN5BkN0TxeVyG2L1M7rcr1yLDMaAe9Xcb0OpH VlH7LFPZ9JIAodr0hpv/6KQrA08gSh8CglsR6bcP7VIihmQcHZEnNDJqnWP8nQbDp6ye QYPpTX2PfqxQhRc1W8KeTO9l+KLKMqpJ2RNpIhEOBfExsDkJzgxQ/TaEXKRIiQhJ4/dh TCBAQxCvwlYw5LPuErRnZkyHKKnvLoLi2bqy4C+SmhZn1626DGgj+6qzfzLNGjMy/tsZ K/+Q== 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=KydR7DthtTuF26Sa++zJDQx95A57XILxzyCBnopfb7Y=; fh=UQCixiNfr28ZOrfhmxiGPA65dFhly8CmRsnoYC6xI9k=; b=HwDZEyIJW2P2jIzVrkooNeGvNuMlFsUMbVtSd6dY9vhIInqCYWVKtHgpujfs8EVxQZ wil2V3+6uhLO+s6sY9EHUtFs6SCfLceqDMHvBoC/G+qqNjeDdXLcUtpFlAidawBCJlv3 ViqSPapm5cKqtGzTla0mlceVclk+kmcvoBcu2E8OlInzCdP3RZ0EHuPb0/yfC169ujNh 8EWLVCC4kbxTzNfoHGL1mpTPzrfyhiLKT6D2BBXIA0Ub/VquW26cFLGovJaubAn6+uvY xWGJ2suyrDcuZMrHqiJBBtI2DZMqa/bHfSvalmDgN7yFJ/9H9WBTNH8ExF1OABoUAFkf jQsA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vzGecq+L; 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-6d89cb3cf76si81107316d6.231.2024.12.03.12.40.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Dec 2024 12:40:57 -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=vzGecq+L; 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 1tIZh6-0001c8-6c; Tue, 03 Dec 2024 15:40: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 1tIZgi-0001SM-WE for qemu-devel@nongnu.org; Tue, 03 Dec 2024 15:40:06 -0500 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tIZgh-0003CB-D3 for qemu-devel@nongnu.org; Tue, 03 Dec 2024 15:40:04 -0500 Received: by mail-oi1-x229.google.com with SMTP id 5614622812f47-3ea49cc8b88so3034783b6e.2 for ; Tue, 03 Dec 2024 12:40:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733258400; x=1733863200; 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=KydR7DthtTuF26Sa++zJDQx95A57XILxzyCBnopfb7Y=; b=vzGecq+LZKxbqMgehCDzmK0dbnPbzPu+FG/gjxG1geq1Lprl52OX+Bc7kv8tJ83Yu8 OvKrT3PtjcDk3vO4U3Ds54WeS0zajM31SXWwZEOiwromhdjKz+HGLCD60YXqO7aFZDW4 M8X7m0Zhl3fcY13yURWJhWzY2b2bg3nC1aUVJaF7ZxauOOWpLao2w4HnlpN/qFfxytW8 SVgP9zDSiFu/vT3hgFelneBJkd8cDt/koieSfa37zT1IUqo19xNVIwYZrK/BqZDByK+k o5dd6yMTGtZ6/zhfRHETn9cF6krz998fxNvFPGHyAe/ffIKWwtC5sc4WYFHGocfdVII8 mUFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733258400; x=1733863200; 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=KydR7DthtTuF26Sa++zJDQx95A57XILxzyCBnopfb7Y=; b=rtn44EsQYqTq6bMv1jbsxXl2QhXdGDF8chVNAQs06l4z/QnIh++GdwLE7SHzG6xVmA u0CDTN8EpoKykXAvNNZvd0t7n41z1n/RuT3VzeWD8cwO4nWi0rkU86UiSyDvQpCLn+Xw ff2n3wjL3jI0dFCKBOigX2qTNwB0OGKqIZvDat9/i9BiQRXK/BBK0PKlHEwI3tMjNnF7 EovgBwN/SBwBDpJmjWpHSCFo9XoL/G9NMdtJrEBB7pNXPjgyfEAy28jJBiu8/E9zC/Qa dnSNLuxRGdw994POX0NHNK4Ou/vAwyAFFe277eZpQzZXcDDE25WXz/hMLPVrfxwITqo9 O2pg== X-Gm-Message-State: AOJu0YxkrV4dJXRaGieHNWr0sgAh4p5+wsbBYz6v8NzyCGWvl265x29T BlDt41iv1p8Itj58+g3mEfQsTnS8T1xt/jhFs5jeuMKZpPhlXrc76b66yp9pNDpDm8pgqA4Un23 ZK9g= X-Gm-Gg: ASbGnct+6HyMNSdSlCXv6o5QOX5q3fNf4KeERqc5gbYSRl+I+aWH4ZtF3T6sETo+YB0 58313Wg4EqIw2bGm0R3Aa0peXLIBCvYJEfOVRMCMBSHYuDhDNQHD9z4gCQbnA9MW0iEfz/ocIVA KJT4AgmPN7KYrqcKNpofyGBTqsN6uTZIg9bbrQ7JlPYmfUgtxPWypfigwzMdfIGMsS5uPcwXOlq Rj6iK+p/qS9mbIEeSYgjStbgHaQUTOpLIqsEm7VhRHU4JZqGFnVCaiUxdttN/7DKQMO1tLi6UTK +eaf75Cn9fKBpSB7GaK6vDg1pp5rJmfdnOLZ X-Received: by 2002:a05:6808:191e:b0:3e7:9f1f:b84a with SMTP id 5614622812f47-3eae4f87a19mr3559095b6e.21.1733258400045; Tue, 03 Dec 2024 12:40:00 -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.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 12:39:59 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Subject: [PATCH 09/11] softfloat: Share code between parts_pick_nan cases Date: Tue, 3 Dec 2024 14:39:46 -0600 Message-ID: <20241203203949.483774-10-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=2607:f8b0:4864:20::229; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x229.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 Remember if there was an SNaN, and use that to simplify float_2nan_prop_s_{ab,ba} to only the snan component. Then, fall through to the corresponding float_2nan_prop_{ab,ba} case to handle any remaining nans, which must be quiet. Signed-off-by: Richard Henderson --- fpu/softfloat-parts.c.inc | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc index de51097dcf..099f1c48ef 100644 --- a/fpu/softfloat-parts.c.inc +++ b/fpu/softfloat-parts.c.inc @@ -39,10 +39,12 @@ static void partsN(return_nan)(FloatPartsN *a, float_status *s) static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b, float_status *s) { + bool have_snan = false; int cmp, which; if (is_snan(a->cls) || is_snan(b->cls)) { float_raise(float_flag_invalid | float_flag_invalid_snan, s); + have_snan = true; } if (s->default_nan_mode) { @@ -57,30 +59,20 @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b, switch (s->float_2nan_prop_rule) { case float_2nan_prop_s_ab: - if (is_snan(a->cls)) { - which = 0; - } else if (is_snan(b->cls)) { - which = 1; - } else if (is_qnan(a->cls)) { - which = 0; - } else { - which = 1; + if (have_snan) { + which = is_snan(a->cls) ? 0 : 1; + break; } - break; - case float_2nan_prop_s_ba: - if (is_snan(b->cls)) { - which = 1; - } else if (is_snan(a->cls)) { - which = 0; - } else if (is_qnan(b->cls)) { - which = 1; - } else { - which = 0; - } - break; + /* fall through */ case float_2nan_prop_ab: which = is_nan(a->cls) ? 0 : 1; break; + case float_2nan_prop_s_ba: + if (have_snan) { + which = is_snan(b->cls) ? 1 : 0; + break; + } + /* fall through */ case float_2nan_prop_ba: which = is_nan(b->cls) ? 1 : 0; break; From patchwork Tue Dec 3 20:39:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 846978 Delivered-To: patch@linaro.org Received: by 2002:a5d:44cd:0:b0:385:e875:8a9e with SMTP id z13csp715268wrr; Tue, 3 Dec 2024 12:41:45 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWm4eNZnYE59krzbXixzvJRCkIOMMa2yDpn+i/kM5/k08Aclj+qFuWhGFjRjJN1XyrcQuRd4w==@linaro.org X-Google-Smtp-Source: AGHT+IGzGHNjcIfETph+2he2ljJkQMZFeluCKSgZhcL3hMM2qz6sCPPx66sCfnFXAKCxw4qHQBl+ X-Received: by 2002:a05:620a:28d4:b0:7b6:6d9f:c91f with SMTP id af79cd13be357-7b6a620a22dmr473499785a.61.1733258504994; Tue, 03 Dec 2024 12:41:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733258504; cv=none; d=google.com; s=arc-20240605; b=EkYBUfrMWOrvnYRsLJXE0PEInM7Soj2W9gq8dhBa9pd9v0hkufJ98FZekKQuuCfgfm QLo+EqHCc/ouAAfMxQtfbFSInp7KNhH4czQl5uYmBM0Q7qv7zprxSSsgUZjFK/RI/tyM x2c38ftoLbrggh94TS+y6KML6v2AeVpQ5j/aEmzwzvlPKDF3UrgE19hwnsvaGWmMCIhu AdWAoVtF8yId52RbqyDJ88PqYjVHUs1dUwLxK9aLdjpa5oueDVQs13TxtIgxp5Alm2fV jKPG7xyFVBFz3MjN2ZYNZDSEmTJJ8gOTmRxa2oTg5TBXyYpudcuHx8AoEykfXIpJqak1 jQ9A== 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=9CTXOrxugfzuYrJxFKkXFLZxqqX/88/ScAMxLj979U8=; fh=UQCixiNfr28ZOrfhmxiGPA65dFhly8CmRsnoYC6xI9k=; b=jEcm/zp4B6rC79ehBP983Dsb2wYixy1liQwUoaBS64WwCbt/si71lY9iP3NQHO1gRf jGzaKzf+5yS26DvIgjy0rMs8u4NyBbHGX5qQG4/cPkqMCqZyvcflK1lJxb0f9v5G9ngs snrfLUM+9Gz2jDJsqAcHIQ1jHfU8QREmJp91G2iKMza1rCMB3Ba4M+1Rlt36lbctr5oi xRq52YdPyP2Qa+nJyiebV5VX5a8lCCvHfrmGkKvhbkd5MU/CgUSVUCN3DEYBxQuukx+6 lWxzZbTfvJB8cmDVjB3fvXuBsL0v76Mt+qSg+Hj0JFFVVWMo1W6AO4nIRkAIArIzLdF3 SHzg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="X4/LBCLm"; 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-7b6849f76eesi1536126385a.668.2024.12.03.12.41.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Dec 2024 12:41:44 -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="X4/LBCLm"; 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 1tIZhF-0001ko-Ll; Tue, 03 Dec 2024 15:40:37 -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 1tIZgj-0001SO-3k for qemu-devel@nongnu.org; Tue, 03 Dec 2024 15:40:06 -0500 Received: from mail-oa1-x2f.google.com ([2001:4860:4864:20::2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tIZgh-0003CQ-Df for qemu-devel@nongnu.org; Tue, 03 Dec 2024 15:40:04 -0500 Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-29e8a0323c5so754717fac.0 for ; Tue, 03 Dec 2024 12:40:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733258401; x=1733863201; 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=9CTXOrxugfzuYrJxFKkXFLZxqqX/88/ScAMxLj979U8=; b=X4/LBCLmeX1yY3NJUwMuAE83mgYKPNtB8AiTYNxoUDYCYVFC5XA7l/sSHtcJ/OsvLb KpfW0mFesyruGDxYcNysb9dD6muvcR969dPi2KFpNXoes8zzf2AnFMcQn47N7SBNpSCS El+tfNjFnByE2Fs4k6nzurczdpy5CLvw6EsMt3pgUnlBz+Y1YKtxBHqSG8MEuHdH4I0V wvbH0FZrXcg9EVit+pPhx6qaVrF2/lORjuWqSva0NbID1fjFowfE7qFdeMeiUUeLG9IB Y0bwu/0yYkORp/D8PupqWngsZfSS5jyWAeYdWpyoRBZYZ1ye3FA+I4TVa5SnyWzADwxK Fz7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733258401; x=1733863201; 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=9CTXOrxugfzuYrJxFKkXFLZxqqX/88/ScAMxLj979U8=; b=dvdlsXsqZaCSudnB/yoa3iN0sHgarQI/H4Mu/0HOIoO7coVxxBdRiv/lx9dqaIgfN2 IU7Bf9kE7z+V53zORCqzQj2QNfg0UIwN0ichKeDPlGWFaL40RQmTEvMnN5Y4sxidD0wY PPuHHSqdZ7WhiZIGhFjq6m+qLXzVZ66SIlDJ9b1s7S2zzEFZwC/n/BGbNMHNekDxoiPh xtMVxdBAVBEemC6nMJEZXF+j2zhYCZtGkeIq55v6omy3RFOy9nx5qAhFZN+d1gXXLPVy GugjM2SHx+a8segslF0TKdfdFmcMtdzoWZiYnADFCDb6QnCrTDaUEB3Qo9VFww9uLqpZ bfag== X-Gm-Message-State: AOJu0YwQ39MRV/6WQvhbSfDoPGc776srznuvMkPd0anTqmT5Hda5e0Ab fm1q+4dypP26E6j1NXUzVaAvXUzzSkpjbo6xDQc1NZTXLe78s0cF2z/hAEbGvRwnl9p+VRGMvwO I/wg= X-Gm-Gg: ASbGncvPk4g3Pab9RfIapWlO3mN59nAVGYQzbuP+/DT2JKmwyTyZK81wdd5i8bXwbII 78gI2X2FlmYUaS5Vy4FB2ZyBSjhP/QBWHG63dEp7VOW+lVfyLk3+AsGA/F7U+d56bMIny7LF+gt NhZRoKkVr43Tki9fCwvgaovg3xcVlEKHuDCXLqjneuOS9j2jbEkcwsoktww2KD1I64tHwOfgdPY V/Pht6ejm8e9mGYIQJk59x/gPrcWkuigbLhgKqGsRWEFmU9Swowb7dnYRpDGZLU7gBcMPBR/5yy 83iIvmPvEyo6RlBL6UXzKnvBkvy6TW90w2dA X-Received: by 2002:a05:6870:f14a:b0:297:2376:9b17 with SMTP id 586e51a60fabf-29e887045edmr4033744fac.19.1733258401068; Tue, 03 Dec 2024 12:40:01 -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.40.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 12:40:00 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Subject: [PATCH 10/11] softfloat: Sink frac_cmp in parts_pick_nan until needed Date: Tue, 3 Dec 2024 14:39:47 -0600 Message-ID: <20241203203949.483774-11-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::2f; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x2f.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 Move the fractional comparison to the end of the float_2nan_prop_x87 case. This is not required for any other 2nan propagation rule. Reorganize the x87 case itself to break out of the switch when the fractional comparison is not required. Signed-off-by: Richard Henderson --- fpu/softfloat-parts.c.inc | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc index 099f1c48ef..9a2287095c 100644 --- a/fpu/softfloat-parts.c.inc +++ b/fpu/softfloat-parts.c.inc @@ -52,11 +52,6 @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b, return a; } - cmp = frac_cmp(a, b); - if (cmp == 0) { - cmp = a->sign < b->sign; - } - switch (s->float_2nan_prop_rule) { case float_2nan_prop_s_ab: if (have_snan) { @@ -89,20 +84,24 @@ static FloatPartsN *partsN(pick_nan)(FloatPartsN *a, FloatPartsN *b, * return the NaN with the positive sign bit (if any). */ if (is_snan(a->cls)) { - if (is_snan(b->cls)) { - which = cmp > 0 ? 0 : 1; - } else { + if (!is_snan(b->cls)) { which = is_qnan(b->cls) ? 1 : 0; + break; } } else if (is_qnan(a->cls)) { if (is_snan(b->cls) || !is_qnan(b->cls)) { which = 0; - } else { - which = cmp > 0 ? 0 : 1; + break; } } else { which = 1; + break; } + cmp = frac_cmp(a, b); + if (cmp == 0) { + cmp = a->sign < b->sign; + } + which = cmp > 0 ? 0 : 1; break; default: g_assert_not_reached(); From patchwork Tue Dec 3 20:39:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 846977 Delivered-To: patch@linaro.org Received: by 2002:a5d:44cd:0:b0:385:e875:8a9e with SMTP id z13csp715126wrr; Tue, 3 Dec 2024 12:41:24 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCV7TzbwOoODSiHAS8er6aW9wJUM84HEdC7DvcF/u5PVPah9fBUqJYeDDGkhK1dVivGBg34mXg==@linaro.org X-Google-Smtp-Source: AGHT+IGjvLXl8KYkdieQefGFKDJuipastLXb71z38jBxCvOt2phgcY4htfOWPzk+HPCV1w72uV3T X-Received: by 2002:a05:6214:5007:b0:6d4:1d7e:bc72 with SMTP id 6a1803df08f44-6d8b927a3b1mr62749146d6.12.1733258484097; Tue, 03 Dec 2024 12:41:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1733258484; cv=none; d=google.com; s=arc-20240605; b=jtvBDNyC1ALiN2d7LXXUizELK312/YFuOx+Yg99sCJzSD/NSAFLp5AKskVzh101T9d 7xE0lIAQ/MIfdF+KzVHTxQzcEAhj7KlWyPtASTEtRS/969x2T+pLx2F3XmUpC7ucG4LE ZyITmxNcMfcvHIjru5wqLEoxA7v8kdAjRzymwXGUQwNIfNqwTgrpTIwRuTgsRD/jJEKt BXRj6vdL3tuB9jLn6yLi4/7z+p/mBZCTK8TFB1P5ZuNlB4KUhfFxK/8OGhSfHT86z/rc hz94g+IxVigo0p4WwedbOXBc4eBj/I+P9o/0+DgfIG1O2VTARDHytez8VbV6bSN8scjF PZLw== 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=xxwQYUCgdJ75izA3vVBTRu+vsh+0fdcxFYY32CHBmJU=; fh=UQCixiNfr28ZOrfhmxiGPA65dFhly8CmRsnoYC6xI9k=; b=PB7Dpg8IhLeuvejBeFma/DgqdC2x/iqSVLlt02Vsej1zwREG+8SV7bIcBgj677auJK DFvtoLaTPlwrZGPNSOMmCrLrCjmBVddeTqmoOUvpayki7sRNBF6cDAX5CxWZ7kGUTUkz vQnyv9EnhB1ACbqnqE5FVmKtOL3XIDv9I4wnz77aXt3FG6EEWGttRD/w+jeOkrN+zCaO 3N3FukwRGqs8THFz72m7wxgbB6SClqFGPL6mQQVVR8Miuc9PWxu5C59wTtNKIfn3d4h6 mWH/6XjeGOsOCh6BDHveAGka1/CkGP+dtxThqk7KHkfCdKHxvLVS3aA4N83IFSzI8UZ5 pyJQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=M13DV7xs; 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-6d8a5d9c6b4si60260576d6.314.2024.12.03.12.41.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Dec 2024 12:41: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=M13DV7xs; 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 1tIZhG-0001me-ME; Tue, 03 Dec 2024 15:40:38 -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 1tIZgm-0001Vk-Vf for qemu-devel@nongnu.org; Tue, 03 Dec 2024 15:40:09 -0500 Received: from mail-oa1-x32.google.com ([2001:4860:4864:20::32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tIZgh-0003Cv-Dg for qemu-devel@nongnu.org; Tue, 03 Dec 2024 15:40:08 -0500 Received: by mail-oa1-x32.google.com with SMTP id 586e51a60fabf-29654932226so118749fac.0 for ; Tue, 03 Dec 2024 12:40:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1733258402; x=1733863202; 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=xxwQYUCgdJ75izA3vVBTRu+vsh+0fdcxFYY32CHBmJU=; b=M13DV7xsaUuByWP1UsVF5CXtH1nUYLSP7gUMyX1yHbuHa84FFts7CpdnMb9uitZdTG TlaO4dhbL1te4yxkSD+oba/8KggLvLTQvDK2uaKNQNiYlBfi633H78o4k9hj/uD0HU9r bPSfBS3d6YYSYwFUwHHDFZ5QE8oXmmWIzDdGtfddNUxZPbSW0aaTWYTArimhvwyOLnCW KGYIjo1oq0nk1eSVcxf0HKcH2OozQUI0aBuSWh9L37IaXeaPWFLWO7rh2Qlkmdi9zEmD t4Eh+a7GWTfDjqPrELyKbgVpJ+QcvrAQ0t1S7LyNEl6po++tveUAqU+PxRwfrVX0H/6J m1Fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733258402; x=1733863202; 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=xxwQYUCgdJ75izA3vVBTRu+vsh+0fdcxFYY32CHBmJU=; b=hg5L0VkYMBL8gM8aHpOjWnHRaT1UMPtFD1WbZrXDxDhpVy2Qm9vWvImQL6IYJp1xVF dmDQYHpSwhBrNZee2o0vTas/97EuBpF4iy5sQIwuzfJVu86XLT7gjicqUom0DXb50m74 i9OQbcUDmBknxGqe2+5WBcHeogE0WnwQOyYC5jORNpF2PUM+e8aiibJxX+CirSq11yQO 4DJ8hNRWeCU7eXrKdZsQAl6b/BpaYRJcWsONfQLoMpJJn6ANq/b8JAfmA7O5t9dPHguo hBirA4bXvqDV52q801qpizq0U5TkjHYa+l8COUHCyvaA4mJdzKefqtbChrCRo4wy5eZ4 d9Gg== X-Gm-Message-State: AOJu0YykpXT1hn0KlsMdx3q9er/sP5oETQf4GRlENfOXQ0MoMRZMS0CF 3Vkt2NEpDpML+v+/QcCa0FsE2I9S3GPhFD70OLFD4GbTqVGHMOMfWrZ2TYDxn5EfA0TAkkKSUOj Jaj8= X-Gm-Gg: ASbGncuxr2EzqemT703u6twBnMrdTajRpIo02/SYS/R26x1QuZ3qAgr4f/OUhhYVAun IZQJq6QkRBdVw+93+RETkHEipmHpj8mAtzB2VdkRwaacMglkuLSX9PKxsSOOBZgJjzXQaE/0zpj TUdx1pT/GurbBF1nlXbwe/AGv5u7sgKMt/JqiHeiw0OLW3lf3lriVxSygIo+1xWfrGXzHpVUD20 qENT2peDS54FuAWJ9ngmH9iGX46I/J49+rUXlszJSuIyIRHemYHYN/BhyZ3p5S0Y/0SDDi1GHHC tDQI/2tW7k5W2M/3vX8sOxVu+cV2IdyRuS3W X-Received: by 2002:a05:6870:c14c:b0:29e:37af:a943 with SMTP id 586e51a60fabf-29e88b5a9aamr2422020fac.18.1733258401824; Tue, 03 Dec 2024 12:40:01 -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.40.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Dec 2024 12:40:01 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org Subject: [PATCH 11/11] softfloat: Replace WHICH with RET in parts_pick_nan Date: Tue, 3 Dec 2024 14:39:48 -0600 Message-ID: <20241203203949.483774-12-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::32; envelope-from=richard.henderson@linaro.org; helo=mail-oa1-x32.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 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é --- 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 9a2287095c..e51c9827d9 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,