From patchwork Fri Oct 25 18:21:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 838390 Delivered-To: patch@linaro.org Received: by 2002:adf:e287:0:b0:37d:45d0:187 with SMTP id v7csp445341wri; Fri, 25 Oct 2024 11:32:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVvCF9ci105WOqDReYV68SYgnTPmdWfSMOoq9D3g17BBk5q7WZS2oBf/SntHUU0+0GSTj6S8Q==@linaro.org X-Google-Smtp-Source: AGHT+IFYJ/LOnl9XlJpYgHdLZxrNuzqJlrzlz5F5UcTDw2sTih5EDL/nsYpmoV4/Etqih38PLuIb X-Received: by 2002:a05:6214:5d0a:b0:6cb:e453:590 with SMTP id 6a1803df08f44-6d1858375camr3692016d6.37.1729881138070; Fri, 25 Oct 2024 11:32:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1729881138; cv=pass; d=google.com; s=arc-20240605; b=EJXdYCHAGkkN7I7hNOixnFfIElbcyDCMBynSxWQWicXrz+qXSF+h/axKtZ1T1Zaz5N hEeLpjfaGbaBxK9kRhvZdhCfa1PGUmqzQ9+sSleevZpJdwEPdK8sXruEMsSEwhnSwfL+ pfcdkf/qEMzFsYTJ/CCBIxC//T5EZgutP/Wp3pd+Yz3aBnwOGR+PInSito9IXW9wsqwC Jk4uDqRp/yMmO/4iGU9PRfxUOntaphofsTZIcgMBtubJVSeLKg3epkp4SM0y4DDeIncF tvkPS+lgmq0gv+xn7vPI0Ocnu7oVw7LhDZExN+/vjBoTRz3isHHkH9Xuj6zX4PCD0Svf 4X4g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=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:arc-filter:dmarc-filter:delivered-to; bh=Zjl8a2kjFZa4yK8gXQLN2kGl9ztVVa31ulGKFj+rqQE=; fh=t7K9SrKfAVamsrcTQr7hpJTc6WX7Vbl5hwH62Vkp0W0=; b=ZcjqK3Jy7jFlEnQCVel5nF8BDwfS1/xmoq+IJPsNH3LXqBmSeEG4VenDqgD3m3W565 ande2Qxlh4y0byeT5plrCfrpL9A2vUPiv9fSo5REe3uLocEDs5a711IOTaQlLQ7ovyPz SiO+e8+WH+27muhRaGjp03DXpQoLdpBhfKGMdQHv8o5+FkfUrLX3639d6p5OH/yi8Mag wVirUhBHi1OcNqC883cFmRVojGlUjbM/33x91lEZjMyQ7jtatk5f+KjZxnvDI9xfQ4fG dfIt8NMebA2fNG/3m0nDYQSWvJbytlnbboK6+yBVmvFreXv3G62Rdd4qmPJWcnt+ANYf J4dw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rSKoC0hr; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id 6a1803df08f44-6d1799004e8si20815156d6.132.2024.10.25.11.32.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 11:32:18 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=rSKoC0hr; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="libc-alpha-bounces~patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B4C7F3858C5F for ; Fri, 25 Oct 2024 18:32:17 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by sourceware.org (Postfix) with ESMTPS id 5490A385840F for ; Fri, 25 Oct 2024 18:27:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5490A385840F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5490A385840F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729880844; cv=none; b=XHq2W5c3QWq7/LgL0omP3t65pmilh7BhkO1MpiC5hyay9WgGkMG0OTc15xMCAmC/+pncZOhTdTnauEbQIT+kq1sKQYvmz5pCu9A3aNCM2ryWj+t9frwVp5L3cJur05uedqNfAR/S0FAmbXRj/v3KZEcx7XcmoxTk9jdtV2/PcAQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729880844; c=relaxed/simple; bh=1KAFhPxefaNE2gUtpV2zXxYc+MIjPXJYS97OgzYqHls=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=aVBjOGcShhNWQcauViWZFr18ZA0Q5UuCNvkrGrkfuugmi5Rh1kRnj1f3QYWEV5a2QXMKSxlsgCjwyfhaPh3qlC+os/05xM824ugnIqodfICGtzhW2b3jD8RGptBS9OHOALP4bu/DAB4Lo/7sa7AXd3nxHn02TZjMfuykcjA098E= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-20c8b557f91so20183625ad.2 for ; Fri, 25 Oct 2024 11:27:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729880838; x=1730485638; darn=sourceware.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=Zjl8a2kjFZa4yK8gXQLN2kGl9ztVVa31ulGKFj+rqQE=; b=rSKoC0hrIJ+VWrQiSFuQ75RJ0SNz7lNteq/29O3DX2IBz0A7zaDynxZqFP7V51LcRm EZZ5N8kw2oTcAD4eIAxqM7uuMSkJ6Vi+FY7o/u0k+Gk1YZwuV2P4SzsGBfGi/HxpURWD dSXGVH7/PHWSs+6r/ZGVfSKUgfpJy+IsETpKKW9zUcxOClY2tqgGHU3LIhQfuhznRAhT EpRCaQMsT9r5GMxzr6Fj+FBWEw+5ClGKRiO199RFeYvSa4zbyxHv+vrcoe/UCTDnVa/6 dE+zkmnpCRTTe1pCREQv1XQ/It3aT5R4//IQUhConq0dPbc7N5DbArlNbpLOYxp8W+m3 jyVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729880838; x=1730485638; 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=Zjl8a2kjFZa4yK8gXQLN2kGl9ztVVa31ulGKFj+rqQE=; b=EB3EY3MWZoqDSYhR+Jy6MToYEmiV4YHJ9EaDdq/XAoNm2p28551+RilI47TnKkXWUN o6EO6E6xEypEIlUt2bvbeixyzGlqla02XC+SoR/cqLswlvft2mB1pVHq4oQvzKkj4siS fojxnr0yG0iak7TJunBKTK5oJ10U6nu9NkNL2MXj1uOcBQSEGtWC54g4ojLtrMbTZhuQ Gr7wfEkD8ViYkRj4JXzd00QcWqDYZaU9qmGIhTvGdDLzGXqZEUoLk8I2XFTuuwxomLVr hrre8etCFm5WTYZUSi5VxYwZF6LOlcb0DXmv0aABnpjwh5P7OTKQIz7dlokC+SrU9dS2 C6cA== X-Gm-Message-State: AOJu0YxcyqF0CgZsKcMXQOqlHbt3M6veLcqOjWRVrDcdbOaKB0ltEdZE bA7c6X+jGgBC4hRW5NuMJ2tzycSCpfPeFVDPoC2bSWqezoQM3RgYOX/t5LKZohI9IpjopDsaAFl h X-Received: by 2002:a17:902:fc45:b0:20b:9f8c:e9d3 with SMTP id d9443c01a7336-210c6ccfa73mr536115ad.55.1729880837864; Fri, 25 Oct 2024 11:27:17 -0700 (PDT) Received: from mandiga.. ([2804:1b3:a7c3:a8a8:cb9e:64f4:66fb:5ca2]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-210bbf44550sm12314075ad.14.2024.10.25.11.27.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 11:27:17 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Paul Zimmermann , Alexei Sibidanov Subject: [PATCH 15/17] math: Use log10p1f from CORE-MATH Date: Fri, 25 Oct 2024 15:21:53 -0300 Message-ID: <20241025182614.2022697-16-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241025182614.2022697-1-adhemerval.zanella@linaro.org> References: <20241025182614.2022697-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patch=linaro.org@sourceware.org The CORE-MATH implementation is correctly rounded (for any rounding mode) and shows slight better performance to the generic log10p1f. The code was adapted to glibc style and to use the definition of math_config.h (to handle errno, overflow, and underflow). Benchtest on x64_64 (Ryzen 9 5900X, gcc 14.2.1), aarch64 (M1, gcc 13.2.1), and powerpc (POWER10, gcc 13.2.1): Latency master patched improvement x86_64 68.5251 32.2627 52.92% x86_64v2 68.8912 32.7887 52.41% x86_64v3 59.3427 27.0521 54.41% i686 162.026 103.383 36.19% aarch64 26.8513 14.5695 45.74% power10 12.7426 8.4929 33.35% powerpc 16.6768 9.29135 44.29% reciprocal-throughput master patched improvement x86_64 26.0969 12.4023 52.48% x86_64v2 25.0045 11.0748 55.71% x86_64v3 20.5610 10.2995 49.91% i686 89.8842 78.5211 12.64% aarch64 17.1200 9.4832 44.61% power10 6.7814 6.4258 5.24% powerpc 15.769 7.6825 51.28% Signed-off-by: Alexei Sibidanov Signed-off-by: Paul Zimmermann Signed-off-by: Adhemerval Zanella --- sysdeps/aarch64/libm-test-ulps | 4 - sysdeps/arc/fpu/libm-test-ulps | 4 - sysdeps/arc/nofpu/libm-test-ulps | 1 - sysdeps/arm/libm-test-ulps | 4 - sysdeps/hppa/fpu/libm-test-ulps | 4 - sysdeps/i386/fpu/libm-test-ulps | 4 - .../i386/i686/fpu/multiarch/libm-test-ulps | 4 - sysdeps/ieee754/flt-32/s_log10p1f.c | 182 ++++++++++++++++++ sysdeps/loongarch/lp64/libm-test-ulps | 4 - sysdeps/mips/mips32/libm-test-ulps | 4 - sysdeps/mips/mips64/libm-test-ulps | 4 - sysdeps/powerpc/fpu/libm-test-ulps | 4 - sysdeps/powerpc/nofpu/libm-test-ulps | 4 - sysdeps/riscv/nofpu/libm-test-ulps | 1 - sysdeps/riscv/rvd/libm-test-ulps | 4 - sysdeps/s390/fpu/libm-test-ulps | 4 - sysdeps/sparc/fpu/libm-test-ulps | 4 - sysdeps/x86_64/fpu/libm-test-ulps | 4 - 18 files changed, 182 insertions(+), 62 deletions(-) create mode 100644 sysdeps/ieee754/flt-32/s_log10p1f.c diff --git a/sysdeps/aarch64/libm-test-ulps b/sysdeps/aarch64/libm-test-ulps index 5700c712ff..c523d45802 100644 --- a/sysdeps/aarch64/libm-test-ulps +++ b/sysdeps/aarch64/libm-test-ulps @@ -1346,22 +1346,18 @@ ldouble: 1 Function: "log10p1": double: 2 -float: 2 ldouble: 3 Function: "log10p1_downward": double: 2 -float: 3 ldouble: 4 Function: "log10p1_towardzero": double: 3 -float: 2 ldouble: 3 Function: "log10p1_upward": double: 2 -float: 3 ldouble: 4 Function: "log1p": diff --git a/sysdeps/arc/fpu/libm-test-ulps b/sysdeps/arc/fpu/libm-test-ulps index 54dc4d6760..c12e241c48 100644 --- a/sysdeps/arc/fpu/libm-test-ulps +++ b/sysdeps/arc/fpu/libm-test-ulps @@ -968,19 +968,15 @@ float: 4 Function: "log10p1": double: 2 -float: 2 Function: "log10p1_downward": double: 2 -float: 3 Function: "log10p1_towardzero": double: 3 -float: 2 Function: "log10p1_upward": double: 2 -float: 3 Function: "log1p": double: 1 diff --git a/sysdeps/arc/nofpu/libm-test-ulps b/sysdeps/arc/nofpu/libm-test-ulps index f6d1ef062c..d0cfa46c3d 100644 --- a/sysdeps/arc/nofpu/libm-test-ulps +++ b/sysdeps/arc/nofpu/libm-test-ulps @@ -234,7 +234,6 @@ float: 2 Function: "log10p1": double: 1 -float: 2 Function: "log1p": double: 1 diff --git a/sysdeps/arm/libm-test-ulps b/sysdeps/arm/libm-test-ulps index 502680ff1b..6cdd3d53d6 100644 --- a/sysdeps/arm/libm-test-ulps +++ b/sysdeps/arm/libm-test-ulps @@ -958,19 +958,15 @@ float: 2 Function: "log10p1": double: 1 -float: 2 Function: "log10p1_downward": double: 2 -float: 3 Function: "log10p1_towardzero": double: 3 -float: 2 Function: "log10p1_upward": double: 2 -float: 3 Function: "log1p": double: 1 diff --git a/sysdeps/hppa/fpu/libm-test-ulps b/sysdeps/hppa/fpu/libm-test-ulps index b56f512b39..021a2a482c 100644 --- a/sysdeps/hppa/fpu/libm-test-ulps +++ b/sysdeps/hppa/fpu/libm-test-ulps @@ -981,19 +981,15 @@ float: 2 Function: "log10p1": double: 2 -float: 2 Function: "log10p1_downward": double: 2 -float: 3 Function: "log10p1_towardzero": double: 3 -float: 2 Function: "log10p1_upward": double: 2 -float: 3 Function: "log1p": double: 1 diff --git a/sysdeps/i386/fpu/libm-test-ulps b/sysdeps/i386/fpu/libm-test-ulps index 63ef3569b4..a77ded2648 100644 --- a/sysdeps/i386/fpu/libm-test-ulps +++ b/sysdeps/i386/fpu/libm-test-ulps @@ -1414,25 +1414,21 @@ ldouble: 1 Function: "log10p1": double: 1 -float: 2 float128: 3 ldouble: 4 Function: "log10p1_downward": double: 2 -float: 3 float128: 4 ldouble: 8 Function: "log10p1_towardzero": double: 2 -float: 1 float128: 3 ldouble: 8 Function: "log10p1_upward": double: 2 -float: 3 float128: 4 ldouble: 6 diff --git a/sysdeps/i386/i686/fpu/multiarch/libm-test-ulps b/sysdeps/i386/i686/fpu/multiarch/libm-test-ulps index f6393dbdf1..a9cd01bf03 100644 --- a/sysdeps/i386/i686/fpu/multiarch/libm-test-ulps +++ b/sysdeps/i386/i686/fpu/multiarch/libm-test-ulps @@ -1417,25 +1417,21 @@ ldouble: 1 Function: "log10p1": double: 1 -float: 2 float128: 3 ldouble: 4 Function: "log10p1_downward": double: 2 -float: 1 float128: 4 ldouble: 8 Function: "log10p1_towardzero": double: 2 -float: 1 float128: 3 ldouble: 8 Function: "log10p1_upward": double: 2 -float: 2 float128: 4 ldouble: 6 diff --git a/sysdeps/ieee754/flt-32/s_log10p1f.c b/sysdeps/ieee754/flt-32/s_log10p1f.c new file mode 100644 index 0000000000..29dad2ea94 --- /dev/null +++ b/sysdeps/ieee754/flt-32/s_log10p1f.c @@ -0,0 +1,182 @@ +/* Correctly-rounded biased argument base-10 logarithm function for binary32 value. + +Copyright (c) 2022-2023 Alexei Sibidanov. + +This file is part of the CORE-MATH project +project (file src/binary32/log10p1/log10p1f.c revision bc385c2). + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#include +#include +#include +#include +#include "math_config.h" + +static __attribute__ ((noinline)) float +as_special (float x) +{ + uint32_t ux = asuint (x); + if (ux == 0x7f800000u) + return x; /* +inf */ + uint32_t ax = ux << 1; + if (ax == 0x17fu << 24) + /* x+1 = 0.0 */ + return __math_divzerof (1); + if (ax > 0xff000000u) + return x + x; /* nan */ + return __math_invalidf (x); +} + +float +__log10p1f (float x) +{ + static const double tr[] = + { + 0x1p+0, 0x1.f81f82p-1, 0x1.f07c1fp-1, 0x1.e9131acp-1, + 0x1.e1e1e1ep-1, 0x1.dae6077p-1, 0x1.d41d41dp-1, 0x1.cd85689p-1, + 0x1.c71c71cp-1, 0x1.c0e0704p-1, 0x1.bacf915p-1, 0x1.b4e81b5p-1, + 0x1.af286bdp-1, 0x1.a98ef6p-1, 0x1.a41a41ap-1, 0x1.9ec8e95p-1, + 0x1.999999ap-1, 0x1.948b0fdp-1, 0x1.8f9c19p-1, 0x1.8acb90fp-1, + 0x1.8618618p-1, 0x1.8181818p-1, 0x1.7d05f41p-1, 0x1.78a4c81p-1, + 0x1.745d174p-1, 0x1.702e05cp-1, 0x1.6c16c17p-1, 0x1.6816817p-1, + 0x1.642c859p-1, 0x1.605816p-1, 0x1.5c9882cp-1, 0x1.58ed231p-1, + 0x1.5555555p-1, 0x1.51d07ebp-1, 0x1.4e5e0a7p-1, 0x1.4afd6ap-1, + 0x1.47ae148p-1, 0x1.446f865p-1, 0x1.4141414p-1, 0x1.3e22cbdp-1, + 0x1.3b13b14p-1, 0x1.3813814p-1, 0x1.3521cfbp-1, 0x1.323e34ap-1, + 0x1.2f684bep-1, 0x1.2c9fb4ep-1, 0x1.29e412ap-1, 0x1.27350b9p-1, + 0x1.2492492p-1, 0x1.21fb781p-1, 0x1.1f7047ep-1, 0x1.1cf06aep-1, + 0x1.1a7b961p-1, 0x1.1811812p-1, 0x1.15b1e5fp-1, 0x1.135c811p-1, + 0x1.1111111p-1, 0x1.0ecf56cp-1, 0x1.0c9715p-1, 0x1.0a6810ap-1, + 0x1.0842108p-1, 0x1.0624dd3p-1, 0x1.041041p-1, 0x1.0204081p-1, + 0.5 + }; + static const double tl[] = + { + 0x1.562ec497ef351p-43, 0x1.b9476892ea99cp-8, 0x1.b5e909c959eecp-7, + 0x1.45f4f59ec84fp-6, 0x1.af5f92cbcf2aap-6, 0x1.0ba01a6069052p-5, + 0x1.3ed119b99dd41p-5, 0x1.714834298a088p-5, 0x1.a30a9d98309c1p-5, + 0x1.d41d51266b9d9p-5, 0x1.02428c0f62dfcp-4, 0x1.1a23444eea521p-4, + 0x1.31b30543f2597p-4, 0x1.48f3ed39bd5e7p-4, 0x1.5fe8049a0bd06p-4, + 0x1.769140a6a78eap-4, 0x1.8cf1836c96595p-4, 0x1.a30a9d5551a84p-4, + 0x1.b8de4d1ee5b21p-4, 0x1.ce6e4202c7bc9p-4, 0x1.e3bc1accaa6eap-4, + 0x1.f8c9683b584b7p-4, 0x1.06cbd68ca86ep-3, 0x1.11142f19de3a2p-3, + 0x1.1b3e71fa795fp-3, 0x1.254b4d37a3354p-3, 0x1.2f3b6912cab79p-3, + 0x1.390f6831144f7p-3, 0x1.42c7e7fffb21ap-3, 0x1.4c65808c779aep-3, + 0x1.55e8c507508c7p-3, 0x1.5f52445deb049p-3, 0x1.68a288c3efe72p-3, + 0x1.71da17bdef98bp-3, 0x1.7af9736089c4bp-3, 0x1.84011952a11ebp-3, + 0x1.8cf1837a7d6d1p-3, 0x1.95cb2891e3048p-3, 0x1.9e8e7b0f85651p-3, + 0x1.a73beaa5d9dfep-3, 0x1.afd3e39454544p-3, 0x1.b856cf060c662p-3, + 0x1.c0c5134de0c6dp-3, 0x1.c91f1371bb611p-3, 0x1.d1652ffcd2bc5p-3, + 0x1.d997c6f634ae6p-3, 0x1.e1b733ab8fbadp-3, 0x1.e9c3ceadab4c8p-3, + 0x1.f1bdeec438f77p-3, 0x1.f9a5e7a5f906fp-3, 0x1.00be05ac02564p-2, + 0x1.04a054d81990cp-2, 0x1.087a083594e33p-2, 0x1.0c4b457098b4fp-2, + 0x1.101431aa1f48ap-2, 0x1.13d4f08b98411p-2, 0x1.178da53edaecbp-2, + 0x1.1b3e71e9f9391p-2, 0x1.1ee777defd526p-2, 0x1.2288d7b48d874p-2, + 0x1.2622b0f52dad8p-2, 0x1.29b522a4c594cp-2, 0x1.2d404b0e305b9p-2, + 0x1.30c4478f3f21dp-2, 0x1.34413509f6f4dp-2 + }; + static const union + { + float f; + uint32_t u; + } st[] = + { + { 0x0p+0 }, { 0x1.2p+3 }, { 0x1.8cp+6 }, + { 0x1.f38p+9 }, { 0x1.3878p+13 }, { 0x1.869fp+16 }, + { 0x1.e847ep+19 }, { 0x1.312cfep+23 } + }; + double z = x; + uint32_t ux = asuint (x); + if (__glibc_unlikely (ux >= 0x17fu << 23)) /* x <= -1 */ + return as_special (x); + uint32_t ax = ux & (~0u >> 1); + if (__glibc_unlikely (ax == 0)) + return copysign (0, x); + if (__glibc_unlikely (ax >= (0xff << 23))) /* +inf, nan */ + return as_special (x); + int ie = ux; + ie >>= 23; + unsigned int je = ie - 126; + je = (je * 0x9a209a8) >> 29; + if (__glibc_unlikely (ux == st[je].u)) + return je; + + uint64_t tz = asuint64 (z + 1.0); + uint64_t m = tz & (~(uint64_t) 0 >> 12); + int32_t e = (tz >> 52) - 1023, j = ((m + ((int64_t) 1 << 45)) >> 46); + tz = m | ((uint64_t) 0x3ff << 52); + double ix = tr[j], l = tl[j]; + double off = e * 0x1.34413509f79ffp-2 + l; + double v = asdouble (tz) * ix - 1; + + static const double h[] = + { + 0x1.bcb7b150bf6d8p-2, -0x1.bcb7b1738c07ep-3, + 0x1.287de19e795c5p-3, -0x1.bca44edc44bc4p-4 + }; + double v2 = v * v; + double f = (h[0] + v * h[1]) + v2 * (h[2] + v * h[3]); + double r = off + v * f; + float ub = r; + float lb = r + 0x1.5cp-42; + if (__glibc_unlikely (ub != lb)) + { + if (__glibc_unlikely (ax < 0x3d32743eu)) + { /* 0x1.64e87cp-5f */ + if (__glibc_unlikely (ux == 0xa6aba8afu)) + return -0x1.2a33bcp-51f + 0x1p-76f; + if (__glibc_unlikely (ux == 0xaf39b9a7u)) + return -0x1.42a342p-34f + 0x1p-59f; + if (__glibc_unlikely (ux == 0x399a7c00u)) + return 0x1.0c53cap-13f + 0x1p-38f; + z /= 2.0 + z; + double z2 = z * z, z4 = z2 * z2; + static const double c[] = + { + 0x1.bcb7b1526e50fp-1, 0x1.287a76370129dp-2, + 0x1.63c62378fa3dbp-3, 0x1.fca4139a42374p-4 + }; + float ret = z * ((c[0] + z2 * c[1]) + z4 * (c[2] + z2 * c[3])); + if (x != 0.0f && ret == 0.0) + __set_errno (ERANGE); + return ret; + } + if (__glibc_unlikely (ux == 0x7956ba5eu)) + return 0x1.16bebap+5f + 0x1p-20f; + if (__glibc_unlikely (ux == 0xbd86ffb9u)) + return -0x1.e53536p-6f + 0x1p-31f; + static const double c[] = + { + 0x1.bcb7b1526e50ep-2, -0x1.bcb7b1526e53dp-3, 0x1.287a7636f3fa2p-3, + -0x1.bcb7b146a14b3p-4, 0x1.63c627d5219cbp-4, -0x1.2880736c8762dp-4, + 0x1.fc1ecf913961ap-5 + }; + f = v + * ((c[0] + v * c[1]) + + v2 * ((c[2] + v * c[3]) + v2 * (c[4] + v * c[5] + v2 * c[6]))); + f += l - tl[0]; + double el = e * 0x1.34413509f79ffp-2; + r = el + f; + ub = r; + } + return ub; +} +libm_alias_float (__log10p1, log10p1) diff --git a/sysdeps/loongarch/lp64/libm-test-ulps b/sysdeps/loongarch/lp64/libm-test-ulps index 846ddb4b3e..ecd9cc5873 100644 --- a/sysdeps/loongarch/lp64/libm-test-ulps +++ b/sysdeps/loongarch/lp64/libm-test-ulps @@ -1195,22 +1195,18 @@ ldouble: 1 Function: "log10p1": double: 2 -float: 2 ldouble: 3 Function: "log10p1_downward": double: 2 -float: 3 ldouble: 4 Function: "log10p1_towardzero": double: 3 -float: 2 ldouble: 3 Function: "log10p1_upward": double: 2 -float: 3 ldouble: 4 Function: "log1p": diff --git a/sysdeps/mips/mips32/libm-test-ulps b/sysdeps/mips/mips32/libm-test-ulps index 2ba46a0749..c319e0642c 100644 --- a/sysdeps/mips/mips32/libm-test-ulps +++ b/sysdeps/mips/mips32/libm-test-ulps @@ -955,19 +955,15 @@ float: 2 Function: "log10p1": double: 1 -float: 2 Function: "log10p1_downward": double: 2 -float: 3 Function: "log10p1_towardzero": double: 3 -float: 2 Function: "log10p1_upward": double: 2 -float: 3 Function: "log1p": double: 1 diff --git a/sysdeps/mips/mips64/libm-test-ulps b/sysdeps/mips/mips64/libm-test-ulps index f73f95cdad..365b860c54 100644 --- a/sysdeps/mips/mips64/libm-test-ulps +++ b/sysdeps/mips/mips64/libm-test-ulps @@ -1200,22 +1200,18 @@ ldouble: 1 Function: "log10p1": double: 1 -float: 2 ldouble: 3 Function: "log10p1_downward": double: 2 -float: 3 ldouble: 4 Function: "log10p1_towardzero": double: 3 -float: 2 ldouble: 3 Function: "log10p1_upward": double: 2 -float: 3 ldouble: 4 Function: "log1p": diff --git a/sysdeps/powerpc/fpu/libm-test-ulps b/sysdeps/powerpc/fpu/libm-test-ulps index 48a3ea10db..8d0c18eed1 100644 --- a/sysdeps/powerpc/fpu/libm-test-ulps +++ b/sysdeps/powerpc/fpu/libm-test-ulps @@ -1497,25 +1497,21 @@ ldouble: 2 Function: "log10p1": double: 2 -float: 2 float128: 3 ldouble: 3 Function: "log10p1_downward": double: 2 -float: 3 float128: 4 ldouble: 6 Function: "log10p1_towardzero": double: 3 -float: 2 float128: 3 ldouble: 6 Function: "log10p1_upward": double: 2 -float: 3 float128: 4 ldouble: 6 diff --git a/sysdeps/powerpc/nofpu/libm-test-ulps b/sysdeps/powerpc/nofpu/libm-test-ulps index ec9104806a..20036c779c 100644 --- a/sysdeps/powerpc/nofpu/libm-test-ulps +++ b/sysdeps/powerpc/nofpu/libm-test-ulps @@ -1257,22 +1257,18 @@ ldouble: 2 Function: "log10p1": double: 1 -float: 2 ldouble: 3 Function: "log10p1_downward": double: 2 -float: 3 ldouble: 6 Function: "log10p1_towardzero": double: 3 -float: 2 ldouble: 6 Function: "log10p1_upward": double: 2 -float: 3 ldouble: 6 Function: "log1p": diff --git a/sysdeps/riscv/nofpu/libm-test-ulps b/sysdeps/riscv/nofpu/libm-test-ulps index 0189fc5bd0..cccc864a7a 100644 --- a/sysdeps/riscv/nofpu/libm-test-ulps +++ b/sysdeps/riscv/nofpu/libm-test-ulps @@ -1167,7 +1167,6 @@ ldouble: 1 Function: "log10p1": double: 1 -float: 1 ldouble: 3 Function: "log1p": diff --git a/sysdeps/riscv/rvd/libm-test-ulps b/sysdeps/riscv/rvd/libm-test-ulps index a0b43761a2..14fc7633af 100644 --- a/sysdeps/riscv/rvd/libm-test-ulps +++ b/sysdeps/riscv/rvd/libm-test-ulps @@ -1195,22 +1195,18 @@ ldouble: 1 Function: "log10p1": double: 2 -float: 2 ldouble: 3 Function: "log10p1_downward": double: 2 -float: 3 ldouble: 4 Function: "log10p1_towardzero": double: 3 -float: 2 ldouble: 3 Function: "log10p1_upward": double: 2 -float: 3 ldouble: 4 Function: "log1p": diff --git a/sysdeps/s390/fpu/libm-test-ulps b/sysdeps/s390/fpu/libm-test-ulps index 658752c41e..288054aafc 100644 --- a/sysdeps/s390/fpu/libm-test-ulps +++ b/sysdeps/s390/fpu/libm-test-ulps @@ -1196,22 +1196,18 @@ ldouble: 1 Function: "log10p1": double: 2 -float: 2 ldouble: 3 Function: "log10p1_downward": double: 2 -float: 3 ldouble: 4 Function: "log10p1_towardzero": double: 3 -float: 2 ldouble: 3 Function: "log10p1_upward": double: 2 -float: 3 ldouble: 4 Function: "log1p": diff --git a/sysdeps/sparc/fpu/libm-test-ulps b/sysdeps/sparc/fpu/libm-test-ulps index 4c4d8ff238..6ea02058e9 100644 --- a/sysdeps/sparc/fpu/libm-test-ulps +++ b/sysdeps/sparc/fpu/libm-test-ulps @@ -1200,22 +1200,18 @@ ldouble: 1 Function: "log10p1": double: 1 -float: 2 ldouble: 3 Function: "log10p1_downward": double: 2 -float: 3 ldouble: 4 Function: "log10p1_towardzero": double: 3 -float: 2 ldouble: 3 Function: "log10p1_upward": double: 2 -float: 3 ldouble: 4 Function: "log1p": diff --git a/sysdeps/x86_64/fpu/libm-test-ulps b/sysdeps/x86_64/fpu/libm-test-ulps index ef9ef51e5e..e3c811549c 100644 --- a/sysdeps/x86_64/fpu/libm-test-ulps +++ b/sysdeps/x86_64/fpu/libm-test-ulps @@ -1798,25 +1798,21 @@ float: 1 Function: "log10p1": double: 2 -float: 2 float128: 3 ldouble: 4 Function: "log10p1_downward": double: 2 -float: 3 float128: 4 ldouble: 8 Function: "log10p1_towardzero": double: 3 -float: 2 float128: 3 ldouble: 8 Function: "log10p1_upward": double: 2 -float: 3 float128: 4 ldouble: 6