From patchwork Fri Oct 25 18:21:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 838384 Delivered-To: patch@linaro.org Received: by 2002:adf:e287:0:b0:37d:45d0:187 with SMTP id v7csp444161wri; Fri, 25 Oct 2024 11:29:55 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU4zxrNspv7prL2TYvffgk8fb9PjgdjQueujcDRhLx8DUYEoUx8sSEvIsdIzMlP2CerZui7hA==@linaro.org X-Google-Smtp-Source: AGHT+IEMQw40XL+R6dy817L3Qe8mqYagmfBHqDhDSfnfmNkmF7AHGtLlmNI6qxqBjj7T14Dzuc6a X-Received: by 2002:a05:622a:351:b0:458:3a65:1d0d with SMTP id d75a77b69052e-4613bfc86acmr2797501cf.6.1729880995647; Fri, 25 Oct 2024 11:29:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1729880995; cv=pass; d=google.com; s=arc-20240605; b=Ew6SGv+kXejMObAGAnt5AqBttUI+BddcMhxZMmtYW0TVJGRyfHM/8BRIkQZ7DaGUe7 BhtTgGQ50wjYY47fvA5CZToQKAGnmTGsaQlBpXWVBvbZZ52lAcf4kkLo/+xTD99q+BQQ HzvGOnF3tfoHHwOBnnrrLtel0+tAXbjKU6HCYS9ZMNvc7inBITSfXyAcptuc1vOUvNer uGz+maqNQpvd+OBPM8MFrpZtwZmsva4YycebikCDooRa23hosMln+wtuFWnyHx+IJwzM NH2nWEhHxQGIQpahuaG32MFf9Qt7m/pMwA5XqjDVKyEljmKYc0Qd1fSc0VvXytTJuMd9 Znfw== 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=dzCRLMc5v1YiRcBqIyOPLOytM90MbN38e5scntyeR00=; fh=t7K9SrKfAVamsrcTQr7hpJTc6WX7Vbl5hwH62Vkp0W0=; b=IURMCVyzBy3nGbfdV8MUE5p9um3jYsYdIPQhLDKSxphTS1UHRlAKOY+i6shrg+eh5U IBYv/gL0vVGrOiUIS8lNPsD928vU39ociueTuRZCR2oOKgo6JLWUBV69oL948zMRuGYH dZQWUfSDhtpMS+ivypgy3PeUVDvq7Ib/ZQ68V/PyEWCY3IBAMKDAicDXZ/mknW77jnKl KdJOwy1q6R2UU0PJveAzpqAZ+kYfsn+QDt8Opwn+mieiN/LCSmub7VuNhRiCkFZT0So4 5GUDDJjuIA2Wk3N20WY2DyPpgchoipO3JoDp3QnCAgA8czivixHDKS/evXEnrdDwirwb H6+w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="R/XKU1SR"; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 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. [8.43.85.97]) by mx.google.com with ESMTPS id d75a77b69052e-461323d68e9si22266641cf.632.2024.10.25.11.29.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 11:29:55 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="R/XKU1SR"; arc=pass (i=1); spf=pass (google.com: domain of libc-alpha-bounces~patch=linaro.org@sourceware.org designates 8.43.85.97 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 40CCA385842C for ; Fri, 25 Oct 2024 18:29:55 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by sourceware.org (Postfix) with ESMTPS id A8CB6385841C for ; Fri, 25 Oct 2024 18:27:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A8CB6385841C 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 A8CB6385841C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729880835; cv=none; b=Tge6RL5X+TM2StegPnAj5FLvQmFZ8KzRNVY+VHNy1LcvjlbchClxKC002BtvN5KVR2gKRGWJFDv0NugK1fwJKxbQWB/DP45lWqDm6Nxy+v3OaghexWWPfpVYF3ZKqq9F7BrU9FXC+Wl1E++uNcoCxRLQmyyMtJiWd6kegsbN7S4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729880835; c=relaxed/simple; bh=9Z70Pdy3z9wVFrkyKHPaAFhA/BcnUfa1W2ZYRsQT+NQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=kuSbXCzgw1PwUF5D+AKD3RF6YqeKgYGBCOLncZfa9y79SZHSE55mubscxKmMOH8LTw0Zlp9P68l5LXxrIs86//RX27C5lk5FieHjNAouW2Zl8J+L4kW1dk6NCoPKJ2Rw9oEupUIBEtQnNUrolEcSarbp6Ff/TiaaTPD5sXFhhxE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-207115e3056so20262945ad.2 for ; Fri, 25 Oct 2024 11:27:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729880828; x=1730485628; 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=dzCRLMc5v1YiRcBqIyOPLOytM90MbN38e5scntyeR00=; b=R/XKU1SRIdX35sjuG0vWDcjHXGN1jYQHMG83Fe9tdWuRlkJCX198wC0M/OVd+F+0jM smJXEM4tbzloZmH5T4vI/3FyDowVGb+2U4P99dJ6GWuSGobeDSC97J19fgA/MoE+EGP8 56wipqzRjH/9qih05ivDpS0qGVROW0S2yuRJp4xz6YjDqKsJZtpO2WC9vYwnbVfBFkse o3JGAkGrRO/YpTV6aDNtcioYmsoKBHLdGFGCD63oWT9urmzZUgg4LnMmgVUMD99rTUt7 VpPQvtLTM5/NoLjpARO4edCvgZOkFJoFr/fRMKqDyu6k4wH1bWsIoik8g3e3FGMnZxJ0 68Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729880828; x=1730485628; 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=dzCRLMc5v1YiRcBqIyOPLOytM90MbN38e5scntyeR00=; b=Bs57jHAdsCe7WfkEQlGR0rsUZbfBsRcPRzQ16/uIQ2hPmGSIlxSbI+lCBOumayrmlt XVVEcdd6LXEBVUBk7L1qyZNNWNXBMkzzUT6RJO68710d0JW4U6QX0sFzbaovPpPyHM5G dXJILBi2HdS2sNRh7hSBXeXG0+xeyzayAQEhnzSrTjaVZBZyuOchTAKx0Qc1JJjk5TPr ICImWs37yaNLL8ILlIF8588VEjEc+0PQ4iMPEXwudZ+RNnxzIIGtRfRXADCDo9uY0HsW /UOK7cHnbpH9eX3d/iHt5vmYRMprXkaocPBUNz52N57nYlJEk8uw4l6OjXVjK798uLM8 8Iiw== X-Gm-Message-State: AOJu0Yx1qDa4zHwvqCJHklOEWRhyD+yP5I+Rn/a+PgQ+GwCsISfk8MPQ D8YChkqpTTtSdyJCeC/DB8u+uvicJeEYQB+KQcOKHR67/6F9m7uhyaAPNISQjNcWP4pXBneSvUC Q X-Received: by 2002:a17:902:da8f:b0:20c:c1bc:2253 with SMTP id d9443c01a7336-210c69edbeamr868215ad.32.1729880828094; Fri, 25 Oct 2024 11:27:08 -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.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Oct 2024 11:27:07 -0700 (PDT) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Paul Zimmermann , Alexei Sibidanov Subject: [PATCH 10/17] math: Use exp2m1f from CORE-MATH Date: Fri, 25 Oct 2024 15:21:48 -0300 Message-ID: <20241025182614.2022697-11-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 better performance compared to the generic exp2m1f. The code was adapted to glibc style and to use the definition of math_config.h (to handle errno, overflow, and underflow). The only change is to handle FLT_MAX_EXP for FE_DOWNWARD or FE_TOWARDZERO. The benchmark inputs are based on exp2f ones. Benchtest on x64_64 (Ryzen 9 5900X, gcc 14.2.1), aarch64 (Neoverse-N1, gcc 13.3.1), and powerpc (POWER10, gcc 13.2.1): Latency master patched improvement x86_64 40.6042 48.7104 -19.96% x86_64v2 40.7506 35.9032 11.90% x86_64v3 35.2301 31.7956 9.75% i686 102.094 94.6657 7.28% aarch64 18.2704 15.1387 17.14% power10 11.9444 8.2402 31.01% reciprocal-throughput master patched improvement x86_64 20.8683 16.1428 22.64% x86_64v2 19.5076 10.4474 46.44% x86_64v3 19.2106 10.4014 45.86% i686 56.4054 59.3004 -5.13% aarch64 12.0781 7.3953 38.77% power10 6.5306 5.9388 9.06% The generic implementation calls __ieee754_exp2f and x86_64 provides an optimized ifunc version (built with -mfma -mavx2, not correctly rounded). This explains the performance difference for x86_64. Same for i686, where the ABI provides an optimized __ieee754_exp2f version built with '-msse2 -mfpmath=sse'. When built wth same flags, the new algorithm shows a better performance: master patched improvement latency 102.094 91.2823 10.59% reciprocal-throughput 56.4054 52.7984 6.39% Signed-off-by: Alexei Sibidanov Signed-off-by: Paul Zimmermann Signed-off-by: Adhemerval Zanella --- SHARED-FILES | 4 + 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_exp2m1f.c | 192 ++++++++++++++++++ sysdeps/loongarch/lp64/libm-test-ulps | 4 - sysdeps/m68k/m680x0/fpu/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 - 20 files changed, 196 insertions(+), 66 deletions(-) create mode 100644 sysdeps/ieee754/flt-32/s_exp2m1f.c diff --git a/SHARED-FILES b/SHARED-FILES index a1dd3878f9..5e771cd1c4 100644 --- a/SHARED-FILES +++ b/SHARED-FILES @@ -235,3 +235,7 @@ sysdeps/ieee754/flt-32/s_exp10m1f.c (file src/binary32/exp10m1/exp10m1f.c in CORE_MATH) - The code was adapted to use glibc code style and internal functions to handle errno, overflow, and underflow. +sysdeps/ieee754/flt-32/s_exp2m1f.c + (file src/binary32/exp2m1/exp2m1f.c in CORE_MATH) + - The code was adapted to use glibc code style and internal + functions to handle errno, overflow, and underflow. diff --git a/sysdeps/aarch64/libm-test-ulps b/sysdeps/aarch64/libm-test-ulps index 00832393f6..29ccd1dfe9 100644 --- a/sysdeps/aarch64/libm-test-ulps +++ b/sysdeps/aarch64/libm-test-ulps @@ -1127,22 +1127,18 @@ ldouble: 2 Function: "exp2m1": double: 2 -float: 2 ldouble: 2 Function: "exp2m1_downward": double: 3 -float: 3 ldouble: 3 Function: "exp2m1_towardzero": double: 3 -float: 2 ldouble: 4 Function: "exp2m1_upward": double: 3 -float: 3 ldouble: 5 Function: "exp_advsimd": diff --git a/sysdeps/arc/fpu/libm-test-ulps b/sysdeps/arc/fpu/libm-test-ulps index ad4ae4c632..fd6d4181f8 100644 --- a/sysdeps/arc/fpu/libm-test-ulps +++ b/sysdeps/arc/fpu/libm-test-ulps @@ -818,19 +818,15 @@ float: 1 Function: "exp2m1": double: 2 -float: 2 Function: "exp2m1_downward": double: 3 -float: 3 Function: "exp2m1_towardzero": double: 3 -float: 2 Function: "exp2m1_upward": double: 3 -float: 3 Function: "exp_downward": double: 1 diff --git a/sysdeps/arc/nofpu/libm-test-ulps b/sysdeps/arc/nofpu/libm-test-ulps index 4cecea6919..574ae8b8be 100644 --- a/sysdeps/arc/nofpu/libm-test-ulps +++ b/sysdeps/arc/nofpu/libm-test-ulps @@ -200,7 +200,6 @@ double: 1 Function: "exp2m1": double: 2 -float: 2 Function: "expm1": double: 1 diff --git a/sysdeps/arm/libm-test-ulps b/sysdeps/arm/libm-test-ulps index bcbe82ca34..28718c7d2c 100644 --- a/sysdeps/arm/libm-test-ulps +++ b/sysdeps/arm/libm-test-ulps @@ -807,19 +807,15 @@ float: 1 Function: "exp2m1": double: 2 -float: 2 Function: "exp2m1_downward": double: 3 -float: 3 Function: "exp2m1_towardzero": double: 3 -float: 2 Function: "exp2m1_upward": double: 3 -float: 3 Function: "exp_downward": double: 1 diff --git a/sysdeps/hppa/fpu/libm-test-ulps b/sysdeps/hppa/fpu/libm-test-ulps index 3dc1f2f8c3..338ca77ade 100644 --- a/sysdeps/hppa/fpu/libm-test-ulps +++ b/sysdeps/hppa/fpu/libm-test-ulps @@ -826,19 +826,15 @@ float: 1 Function: "exp2m1": double: 2 -float: 2 Function: "exp2m1_downward": double: 3 -float: 3 Function: "exp2m1_towardzero": double: 3 -float: 2 Function: "exp2m1_upward": double: 3 -float: 3 Function: "exp_downward": double: 1 diff --git a/sysdeps/i386/fpu/libm-test-ulps b/sysdeps/i386/fpu/libm-test-ulps index 96d02334e4..98a5a538ff 100644 --- a/sysdeps/i386/fpu/libm-test-ulps +++ b/sysdeps/i386/fpu/libm-test-ulps @@ -1194,25 +1194,21 @@ ldouble: 1 Function: "exp2m1": double: 2 -float: 1 float128: 2 ldouble: 3 Function: "exp2m1_downward": double: 3 -float: 3 float128: 3 ldouble: 6 Function: "exp2m1_towardzero": double: 3 -float: 2 float128: 4 ldouble: 5 Function: "exp2m1_upward": double: 3 -float: 3 float128: 5 ldouble: 6 diff --git a/sysdeps/i386/i686/fpu/multiarch/libm-test-ulps b/sysdeps/i386/i686/fpu/multiarch/libm-test-ulps index c18e2bc8de..9afb63bc0f 100644 --- a/sysdeps/i386/i686/fpu/multiarch/libm-test-ulps +++ b/sysdeps/i386/i686/fpu/multiarch/libm-test-ulps @@ -1197,25 +1197,21 @@ ldouble: 1 Function: "exp2m1": double: 2 -float: 1 float128: 2 ldouble: 3 Function: "exp2m1_downward": double: 3 -float: 3 float128: 3 ldouble: 6 Function: "exp2m1_towardzero": double: 3 -float: 2 float128: 4 ldouble: 6 Function: "exp2m1_upward": double: 3 -float: 3 float128: 5 ldouble: 6 diff --git a/sysdeps/ieee754/flt-32/s_exp2m1f.c b/sysdeps/ieee754/flt-32/s_exp2m1f.c new file mode 100644 index 0000000000..f899152d2a --- /dev/null +++ b/sysdeps/ieee754/flt-32/s_exp2m1f.c @@ -0,0 +1,192 @@ +/* Correctly-rounded base-2 exponent function biased by 1 for binary32 value. + +Copyright (c) 2022-2024 Alexei Sibidanov. + +The original version of this file was copied from the CORE-MATH +project (file src/binary32/exp2m1/exp2m1f.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 "math_config.h" +#include +#include +#include + +float +__exp2m1f (float x) +{ + double z = x; + uint32_t ux = asuint (x); + uint32_t ax = ux & (~0u >> 1); + if (__glibc_unlikely (ux >= 0xc1c80000u)) + { /* x <= -25 */ + if (ax > (0xffu << 23)) + return x + x; /* nan */ + return (ux == 0xff800000) ? -0x1p+0 : -0x1p+0 + 0x1p-26f; + } + else if (__glibc_unlikely (ax >= 0x43000000u)) + { /* x >= 128 */ + if (ax >= asuint (INFINITY)) + return x + x; /* +Inf or NaN */ + /* exp2m1 (MAX_EXP) should not overflow when rounding towards zero + or towards -Inf. We round FLT_MAX + 2^103 which is in the middle + between FLT_MAX and 2^128 (the next number with unbounded range). */ + float ret = math_narrow_eval (FLT_MAX + 0x1p103f); + if (x == FLT_MAX_EXP && ret == FLT_MAX) + return ret; + return __math_oflowf (0); + } + else if (__glibc_unlikely (ax < 0x3df95f1fu)) + { /* |x| < 8.44e-2/log(2) */ + double z2 = z * z, r; + if (__glibc_unlikely (ax < 0x3d67a4ccu)) + { /* |x| < 3.92e-2/log(2) */ + if (__glibc_unlikely (ax < 0x3caa2feeu)) + { /* |x| < 1.44e-2/log(2) */ + if (__glibc_unlikely (ax < 0x3bac1405u)) + { /* |x| < 3.64e-3/log(2) */ + if (__glibc_unlikely (ax < 0x3a358876u)) + { /* |x| < 4.8e-4/log(2) */ + if (__glibc_unlikely (ax < 0x37d32ef6u)) + { /* |x| < 1.745e-5/log(2) */ + if (__glibc_unlikely (ax < 0x331fdd82u)) + { /* |x| < 2.58e-8/log(2) */ + if (__glibc_unlikely (ax < 0x2538aa3bu)) + /* |x| < 1.60171e-16 */ + r = 0x1.62e42fefa39efp-1; + else + r = 0x1.62e42fefa39fp-1 + + z * 0x1.ebfbdff82c58fp-3; + } + else + { + if (__glibc_unlikely (ux == 0xb3d85005u)) + return -0x1.2bdf76p-24 - 0x1.8p-77; + if (__glibc_unlikely (ux == 0x3338428du)) + return 0x1.fee08ap-26 + 0x1p-80; + static const double c[] = + { + 0x1.62e42fefa39efp-1, 0x1.ebfbdff8548fdp-3, + 0x1.c6b08d704a06dp-5 + }; + r = c[0] + z * (c[1] + z * c[2]); + } + } + else + { + if (__glibc_unlikely (ux == 0x388bca4fu)) + return 0x1.839702p-15 - 0x1.8p-68; + static const double c[] = + { + 0x1.62e42fefa39efp-1, 0x1.ebfbdff82c58fp-3, + 0x1.c6b08dc82b347p-5, 0x1.3b2ab6fbad172p-7 + }; + r = (c[0] + z * c[1]) + z2 * (c[2] + z * c[3]); + } + } + else + { + static const double c[] = + { + 0x1.62e42fefa39efp-1, 0x1.ebfbdff82c068p-3, + 0x1.c6b08d704a6dcp-5, 0x1.3b2ac262c3eedp-7, + 0x1.5d87fe7af779ap-10 + }; + r = (c[0] + z * c[1]) + + z2 * (c[2] + z * (c[3] + z * c[4])); + } + } + else + { + static const double c[] = + { + 0x1.62e42fefa39fp-1, 0x1.ebfbdff82c58dp-3, + 0x1.c6b08d7011d13p-5, 0x1.3b2ab6fbd267dp-7, + 0x1.5d88a81cea49ep-10, 0x1.430912ea9b963p-13 + }; + r = (c[0] + z * c[1]) + + z2 * ((c[2] + z * c[3]) + z2 * (c[4] + z * c[5])); + } + } + else + { + static const double c[] = + { + 0x1.62e42fefa39efp-1, 0x1.ebfbdff82c639p-3, + 0x1.c6b08d7049f1cp-5, 0x1.3b2ab6f5243bdp-7, + 0x1.5d87fe80a9e6cp-10, 0x1.430d0b9257fa8p-13, + 0x1.ffcbfc4cf0952p-17 + }; + r = (c[0] + z * c[1]) + + z2 * ((c[2] + z * c[3]) + + z2 * (c[4] + z * (c[5] + z * c[6]))); + } + } + else + { + static const double c[] = + { + 0x1.62e42fefa39efp-1, 0x1.ebfbdff82c591p-3, + 0x1.c6b08d704cf6bp-5, 0x1.3b2ab6fba00cep-7, + 0x1.5d87fdfdaadb4p-10, 0x1.4309137333066p-13, + 0x1.ffe5e90daf7ddp-17, 0x1.62c0220eed731p-20 + }; + r = ((c[0] + z * c[1]) + z2 * (c[2] + z * c[3])) + + (z2 * z2) * ((c[4] + z * c[5]) + z2 * (c[6] + z * c[7])); + } + r *= z; + return r; + } + else + { + static const double c[] = + { + 0x1.62e42fefa398bp-5, 0x1.ebfbdff84555ap-11, + 0x1.c6b08d4ad86d3p-17, 0x1.3b2ad1b1716a2p-23, + 0x1.5d7472718ce9dp-30, 0x1.4a1d7f457ac56p-37 + }; + static const double tb[] = + { + 0x1p+0, 0x1.0b5586cf9890fp+0, 0x1.172b83c7d517bp+0, + 0x1.2387a6e756238p+0, 0x1.306fe0a31b715p+0, 0x1.3dea64c123422p+0, + 0x1.4bfdad5362a27p+0, 0x1.5ab07dd485429p+0, 0x1.6a09e667f3bcdp+0, + 0x1.7a11473eb0187p+0, 0x1.8ace5422aa0dap+0, 0x1.9c49182a3f09p+0, + 0x1.ae89f995ad3adp+0, 0x1.c199bdd85529cp+0, 0x1.d5818dcfba487p+0, + 0x1.ea4afa2a490dap+0 + }; + double a = 16.0 * z; + double ia = floor (a); + double h = a - ia; + double h2 = h * h; + int64_t i = ia, j = i & 0xf, e = i - j; + e >>= 4; + double s = tb[j]; + s *= asdouble ((e + 0x3ffull) << 52); + double c0 = c[0] + h * c[1]; + double c2 = c[2] + h * c[3]; + double c4 = c[4] + h * c[5]; + c0 += h2 * (c2 + h2 * c4); + double w = s * h; + return (s - 1.0) + w * c0; + } +} +libm_alias_float (__exp2m1, exp2m1) diff --git a/sysdeps/loongarch/lp64/libm-test-ulps b/sysdeps/loongarch/lp64/libm-test-ulps index de7e526008..c6fc9fd4ed 100644 --- a/sysdeps/loongarch/lp64/libm-test-ulps +++ b/sysdeps/loongarch/lp64/libm-test-ulps @@ -1010,22 +1010,18 @@ ldouble: 2 Function: "exp2m1": double: 2 -float: 2 ldouble: 2 Function: "exp2m1_downward": double: 3 -float: 3 ldouble: 3 Function: "exp2m1_towardzero": double: 3 -float: 2 ldouble: 4 Function: "exp2m1_upward": double: 3 -float: 3 ldouble: 5 Function: "exp_downward": diff --git a/sysdeps/m68k/m680x0/fpu/libm-test-ulps b/sysdeps/m68k/m680x0/fpu/libm-test-ulps index 96cd7b3fd5..7fef8942ae 100644 --- a/sysdeps/m68k/m680x0/fpu/libm-test-ulps +++ b/sysdeps/m68k/m680x0/fpu/libm-test-ulps @@ -903,19 +903,15 @@ double: 1 Function: "exp2m1": double: 1 -float: 1 Function: "exp2m1_downward": double: 2 -float: 1 Function: "exp2m1_towardzero": double: 2 -float: 1 Function: "exp2m1_upward": double: 1 -float: 1 Function: "exp_upward": double: 1 diff --git a/sysdeps/mips/mips32/libm-test-ulps b/sysdeps/mips/mips32/libm-test-ulps index 829da3ebf1..d8daca6326 100644 --- a/sysdeps/mips/mips32/libm-test-ulps +++ b/sysdeps/mips/mips32/libm-test-ulps @@ -807,19 +807,15 @@ float: 1 Function: "exp2m1": double: 2 -float: 2 Function: "exp2m1_downward": double: 3 -float: 3 Function: "exp2m1_towardzero": double: 3 -float: 2 Function: "exp2m1_upward": double: 3 -float: 3 Function: "exp_downward": double: 1 diff --git a/sysdeps/mips/mips64/libm-test-ulps b/sysdeps/mips/mips64/libm-test-ulps index 5c7b050b11..39e94d5480 100644 --- a/sysdeps/mips/mips64/libm-test-ulps +++ b/sysdeps/mips/mips64/libm-test-ulps @@ -1014,22 +1014,18 @@ ldouble: 2 Function: "exp2m1": double: 2 -float: 2 ldouble: 2 Function: "exp2m1_downward": double: 3 -float: 3 ldouble: 3 Function: "exp2m1_towardzero": double: 3 -float: 2 ldouble: 4 Function: "exp2m1_upward": double: 3 -float: 3 ldouble: 5 Function: "exp_downward": diff --git a/sysdeps/powerpc/fpu/libm-test-ulps b/sysdeps/powerpc/fpu/libm-test-ulps index 30ddbaf05f..dd25aaf94a 100644 --- a/sysdeps/powerpc/fpu/libm-test-ulps +++ b/sysdeps/powerpc/fpu/libm-test-ulps @@ -1227,25 +1227,21 @@ ldouble: 2 Function: "exp2m1": double: 2 -float: 2 float128: 2 ldouble: 3 Function: "exp2m1_downward": double: 3 -float: 3 float128: 3 ldouble: 7 Function: "exp2m1_towardzero": double: 3 -float: 2 float128: 4 ldouble: 8 Function: "exp2m1_upward": double: 3 -float: 3 float128: 5 ldouble: 9 diff --git a/sysdeps/powerpc/nofpu/libm-test-ulps b/sysdeps/powerpc/nofpu/libm-test-ulps index e15e1f8fc0..1e5bae039b 100644 --- a/sysdeps/powerpc/nofpu/libm-test-ulps +++ b/sysdeps/powerpc/nofpu/libm-test-ulps @@ -1023,22 +1023,18 @@ ldouble: 2 Function: "exp2m1": double: 2 -float: 2 ldouble: 2 Function: "exp2m1_downward": double: 3 -float: 3 ldouble: 7 Function: "exp2m1_towardzero": double: 3 -float: 2 ldouble: 8 Function: "exp2m1_upward": double: 3 -float: 3 ldouble: 9 Function: "exp_downward": diff --git a/sysdeps/riscv/nofpu/libm-test-ulps b/sysdeps/riscv/nofpu/libm-test-ulps index 2271e1ee6c..11f891988e 100644 --- a/sysdeps/riscv/nofpu/libm-test-ulps +++ b/sysdeps/riscv/nofpu/libm-test-ulps @@ -995,7 +995,6 @@ ldouble: 2 Function: "exp2m1": double: 1 -float: 1 ldouble: 1 Function: "exp_downward": diff --git a/sysdeps/riscv/rvd/libm-test-ulps b/sysdeps/riscv/rvd/libm-test-ulps index 0bc61bf3c8..7d303fcb6b 100644 --- a/sysdeps/riscv/rvd/libm-test-ulps +++ b/sysdeps/riscv/rvd/libm-test-ulps @@ -1010,22 +1010,18 @@ ldouble: 2 Function: "exp2m1": double: 2 -float: 2 ldouble: 2 Function: "exp2m1_downward": double: 3 -float: 3 ldouble: 3 Function: "exp2m1_towardzero": double: 3 -float: 2 ldouble: 4 Function: "exp2m1_upward": double: 3 -float: 3 ldouble: 5 Function: "exp_downward": diff --git a/sysdeps/s390/fpu/libm-test-ulps b/sysdeps/s390/fpu/libm-test-ulps index 860479f3ff..aa7a94a2be 100644 --- a/sysdeps/s390/fpu/libm-test-ulps +++ b/sysdeps/s390/fpu/libm-test-ulps @@ -1011,22 +1011,18 @@ ldouble: 2 Function: "exp2m1": double: 2 -float: 2 ldouble: 2 Function: "exp2m1_downward": double: 3 -float: 3 ldouble: 3 Function: "exp2m1_towardzero": double: 3 -float: 2 ldouble: 4 Function: "exp2m1_upward": double: 3 -float: 3 ldouble: 5 Function: "exp_downward": diff --git a/sysdeps/sparc/fpu/libm-test-ulps b/sysdeps/sparc/fpu/libm-test-ulps index 4d8064b543..e7b3da6f1c 100644 --- a/sysdeps/sparc/fpu/libm-test-ulps +++ b/sysdeps/sparc/fpu/libm-test-ulps @@ -1014,22 +1014,18 @@ ldouble: 2 Function: "exp2m1": double: 2 -float: 2 ldouble: 2 Function: "exp2m1_downward": double: 3 -float: 3 ldouble: 3 Function: "exp2m1_towardzero": double: 3 -float: 2 ldouble: 4 Function: "exp2m1_upward": double: 3 -float: 3 ldouble: 5 Function: "exp_downward": diff --git a/sysdeps/x86_64/fpu/libm-test-ulps b/sysdeps/x86_64/fpu/libm-test-ulps index 3f438c2090..71697e99e0 100644 --- a/sysdeps/x86_64/fpu/libm-test-ulps +++ b/sysdeps/x86_64/fpu/libm-test-ulps @@ -1495,25 +1495,21 @@ float: 1 Function: "exp2m1": double: 2 -float: 2 float128: 2 ldouble: 3 Function: "exp2m1_downward": double: 3 -float: 3 float128: 3 ldouble: 6 Function: "exp2m1_towardzero": double: 3 -float: 2 float128: 4 ldouble: 5 Function: "exp2m1_upward": double: 3 -float: 3 float128: 5 ldouble: 6