From patchwork Tue Dec 24 20:05:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 853263 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp4084177wrq; Tue, 24 Dec 2024 12:16:09 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX8mI52HUdH6YHWdpJYVlIvuoANFPO/dS5jpaTinfaqebLT+0O5H7lTB/jRTfhz24L+uDx+Eg==@linaro.org X-Google-Smtp-Source: AGHT+IFXY54+4vl73VbctlPQ2ilDc3gvp04OrzFidMCGX+Xd2E7MSJPpFJv7uOM+cwL2Hrz6AFnF X-Received: by 2002:a05:622a:13d4:b0:467:6fa1:9e2a with SMTP id d75a77b69052e-46a4a97817emr302277921cf.40.1735071369197; Tue, 24 Dec 2024 12:16:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1735071369; cv=none; d=google.com; s=arc-20240605; b=k6UDJHMx5B+uMnY+hjDCeYhleRoHmdTq3b+qBXlAH97ExuoQnAi4xnBplApJ/0fDRT 8x8Y/+VuXOoDUZ/Ux2ochUF2bznZ6g0yOq07bTJAN2xsVUnJ1nnZpEqML/52JG3tLBoC OcMtyU9qtcN56qvhUAhU0JA8uT6FULm6gOw0YkzHhtVH4cJgGFvzKr3JRjhWa/8gM7jw D6tLtFTbLUgjzTeoTYVM+7lr6rGo8eQ5AxRMNJvLsj8CLQxrsyVcd/9ikiqt3hHpjYYj cwz/EQXnH4EycWUEz4OdhyUf3MCFVyLGduXXO7o2EAe3LkX2PcZQdVYHwHmCfxfp9XMV otOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=qMWHCU8E787jJTfENdcTGiVxd4zzSlvdX30p3jl01M4=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=N7GJUsSZJzeEqgHCe2aWtxjqXJ9b9zoMghGul3NiRihXokDxwsmlGaCwj/WJeEQcHV IBnMyN5sRkYl2OfPNmWwNtkUx/bj2EFtK9j3m7xNIonEc/YdHW6wBTHiXHxFDXmAM4vp hpMFQJ2cEGqf3E/VADKvLpYRS6kGOf3Y4Nv9/cxvO7qrVMqYX+AvkamLrg5T9gWHx4md tO1gD46m8zfwQPBdqt8VI6KDO6tP9tK2pQjsV7KadnBQbSeFFORd1GsYF646eemh/DUW Ltw9Z0VTo24/90JfeMPWh4WDZPNM6HkYCyIJ6G55osSfiWeYv2n1+vh+2E1MBm29aP3u O+KA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GffYiqBN; 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-46a3ebd8367si134630951cf.614.2024.12.24.12.16.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Dec 2024 12:16:09 -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=GffYiqBN; 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 1tQBDo-0000Mn-Ok; Tue, 24 Dec 2024 15:09:40 -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 1tQBDW-000732-Jv for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:23 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQBDU-0002yf-Tp for qemu-devel@nongnu.org; Tue, 24 Dec 2024 15:09:22 -0500 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-216634dd574so40016175ad.2 for ; Tue, 24 Dec 2024 12:09:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1735070960; x=1735675760; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=qMWHCU8E787jJTfENdcTGiVxd4zzSlvdX30p3jl01M4=; b=GffYiqBNLAzxx3KVZWPF2Dj7oSAR+LbBeZkxm7SDygpT4kYdh37DH7aO8rDMykmEyQ iVAyJ1NAiRsCGpIPQxMugFyt65Daprwv2dJz3oSgnM2uG3JlK1rEiZxtdmUfg6jVseet o9rWkaUeY6/8vmFqY4yJtvzgYMYpB8UKom/4rL1nNv8WHrGWqHyHpwQb1KCDSfMSzFGp q8zV11EihlFqEGxLFMNsHmucUdvIS2H+gfkLVEBz8cJVBEZybMBBYid3e/EncpDhqydS 9KaIB8V4f/I8JIRygOJDHvAaE/xCOI8+hynTlWmf1NftX1h+oQJMeyUlJa7eIXh+DizD cCMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735070960; x=1735675760; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qMWHCU8E787jJTfENdcTGiVxd4zzSlvdX30p3jl01M4=; b=WCtj3/uewzLnK9FHss2dCGWIS6R0SD6GpV7CVR7DgWz12eFW5ZcTZESsamcbWz48WY Sbv7TDMp+ru+noiKaHozqG3WUCcSFDozGDAgWJfijkWLYFB5hyxBY2u8+ogjKBYtvVIl BezkvyoKZKdDxdf9XpYAeH5Zh18EJUAzqeP9TIItXInz01Ld/4GZDSNXpbYxA3cu3SQA ZrkP/garK5s5q59S5RHGqIhGx6y+mzvCmFmmtwTZSv+yi/c2ILLsRbBf5upo31tWFXwn bQ60nHOFPAcFmFJ7Qre039I3UmIr6zWIIkG0PPyLEElZuFwZN6C6bkXR6+vpJoOpJd2K tzdA== X-Gm-Message-State: AOJu0Yw9bn0h6GMn+sitm2SMKk8X0ywEJ05PfUv1OeXK9DrR+roafQXt n+QCK+hsENcZMxlyYZ11jdTDMHnb0PQlqp/8w+KtOZIHnwa35hlTNv5aVZSN3KnaYEpCgR4SRkw yNwA= X-Gm-Gg: ASbGncvAOqoNs49svkejSzHMNH0epRhNbK/2siSNljhNMy2JEHah7cZmsHaQ+eb5vUA ZrfShC9nNeDXxLnO6WDEcCXAQqxY/wjUkTblHE2OC78HLtoxbMIXt91R1bww5jHuqj1hObeaPwx wQ+zErjKPgULD/jw6TYHHcdtMPcZgiWWR6g5xIn8C4FHRTtuj77i08eOOCIqQOd0CGC5R56ACN1 4gUudfZLoguaLzcTaLfxeb/2OjJQjyc7M98VlyGCj3Fpk3VzIL/0gVElC6oqfV5yuKrEgcGBy5s s9yqqhd/wGn+vsIMBygYeJFs0w== X-Received: by 2002:a05:6a21:6f87:b0:1db:c20f:2c4d with SMTP id adf61e73a8af0-1e5e044b1c1mr27570093637.2.1735070959723; Tue, 24 Dec 2024 12:09:19 -0800 (PST) Received: from stoup.. (syn-156-019-246-023.biz.spectrum.com. [156.19.246.23]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72aad8309acsm10033521b3a.45.2024.12.24.12.09.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Dec 2024 12:09:19 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PULL 60/72] softfloat: Add float_muladd_suppress_add_product_zero Date: Tue, 24 Dec 2024 12:05:09 -0800 Message-ID: <20241224200521.310066-61-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241224200521.310066-1-richard.henderson@linaro.org> References: <20241224200521.310066-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::634; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x634.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 Certain Hexagon instructions suppress changes to the result when the product of fma() is a true zero. Signed-off-by: Richard Henderson --- include/fpu/softfloat.h | 5 +++++ fpu/softfloat.c | 3 +++ fpu/softfloat-parts.c.inc | 4 +++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/fpu/softfloat.h b/include/fpu/softfloat.h index aa69aecfb0..09a40b4310 100644 --- a/include/fpu/softfloat.h +++ b/include/fpu/softfloat.h @@ -120,11 +120,16 @@ bfloat16 bfloat16_squash_input_denormal(bfloat16 a, float_status *status); | Using these differs from negating an input or output before calling | the muladd function in that this means that a NaN doesn't have its | sign bit inverted before it is propagated. +| +| With float_muladd_suppress_add_product_zero, if A or B is zero +| such that the product is a true zero, then return C without addition. +| This preserves the sign of C when C is +/- 0. Used for Hexagon. *----------------------------------------------------------------------------*/ enum { float_muladd_negate_c = 1, float_muladd_negate_product = 2, float_muladd_negate_result = 4, + float_muladd_suppress_add_product_zero = 8, }; /*---------------------------------------------------------------------------- diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 6967fb5c9f..8d75d66817 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -2274,6 +2274,9 @@ float32_muladd(float32 xa, float32 xb, float32 xc, int flags, float_status *s) if (unlikely(!can_use_fpu(s))) { goto soft; } + if (unlikely(flags & float_muladd_suppress_add_product_zero)) { + goto soft; + } float32_input_flush3(&ua.s, &ub.s, &uc.s, s); if (unlikely(!f32_is_zon3(ua, ub, uc))) { diff --git a/fpu/softfloat-parts.c.inc b/fpu/softfloat-parts.c.inc index 37d046cfe9..ebde42992f 100644 --- a/fpu/softfloat-parts.c.inc +++ b/fpu/softfloat-parts.c.inc @@ -615,7 +615,9 @@ static FloatPartsN *partsN(muladd_scalbn)(FloatPartsN *a, FloatPartsN *b, goto return_normal; } if (c->cls == float_class_zero) { - if (a->sign != c->sign) { + if (flags & float_muladd_suppress_add_product_zero) { + a->sign = c->sign; + } else if (a->sign != c->sign) { goto return_sub_zero; } goto return_zero;